API and JavaDoc changes for Spatial Datatypes#752
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #752 +/- ##
============================================
- Coverage 48.32% 48.19% -0.14%
+ Complexity 2773 2765 -8
============================================
Files 116 116
Lines 27871 27831 -40
Branches 4631 4624 -7
============================================
- Hits 13469 13412 -57
- Misses 12218 12229 +11
- Partials 2184 2190 +6
Continue to review full report at Codecov.
|
| } | ||
|
|
||
| /** | ||
| * Returns the figuresAttribute value. |
There was a problem hiding this comment.
I am changing everything to be consistent. For getters, can you please say "Gets blah blah"?
| import java.text.MessageFormat; | ||
|
|
||
|
|
||
| public class Geography extends SQLServerSpatialDatatype { |
There was a problem hiding this comment.
needs class description
|
|
||
| /** | ||
| * Returns the X coordinate value. | ||
| * Gets the X coordinate value. |
There was a problem hiding this comment.
I am sorry I made you change.....we're now going with "Returns the something of this thing." as per new guideline. You can leave it if you want I'm changing all the other files to be consistent I can change this after you merge.
| protected void constructWKT(SQLServerSpatialDatatype sd, InternalSpatialDatatype isd, int pointIndexEnd, | ||
| int figureIndexEnd, int segmentIndexEnd, int shapeIndexEnd) throws SQLServerException { | ||
| if (null == points || numberOfPoints == 0) { | ||
| if (null == xpoints || numberOfPoints == 0) { |
There was a problem hiding this comment.
null=xpoints check is not needed. numberOfPoints is enough to be checked.
| int firstPointIndex = pointIndex * 2; | ||
| int secondPointIndex = firstPointIndex + 1; | ||
| int zValueIndex = pointIndex; | ||
| int mValueIndex = pointIndex; |
There was a problem hiding this comment.
Please remove these unwanted mValueIndex and zValueIndex too.
| protected double xpoints[]; | ||
| protected double ypoints[]; | ||
| protected double zValues[]; | ||
| protected double mValues[]; |
There was a problem hiding this comment.
All these 4 arrays form contain point coordinates, naming should be consistent.
|
|
||
| /** | ||
| * Constructs a Geography instance that represents a Point instance from its X and Y values and an SRID. | ||
| * Constructor for a Geography instance that represents a Point instance from its X and Y values and an SRID. |
There was a problem hiding this comment.
SRID = Spatial Reference System Identifier
Also add to the param tags in all functions
| @@ -203,8 +216,8 @@ public boolean hasZ() { | |||
| * @return double value that represents the X coordinate. | |||
| */ | |||
| public Double getX() { | |||
There was a problem hiding this comment.
Please rename getX() and getY() to getLatitude() and getLongitude() for Geography.
A Geographic Point should always reference them as Latitude and Longitude. There should be no API neither documentation for these co-ordinates as X or Y in context of Geography Point.
| * y coordinate | ||
| * @param srid | ||
| * SRID | ||
| * Spatial Reference Identifier Spatial Reference Identifier value |
| @@ -215,9 +216,9 @@ public boolean hasZ() { | |||
| * | |||
| * @return double value that represents the X coordinate. | |||
There was a problem hiding this comment.
Please fix Javadocs too. Also for getY() function
| * @param x | ||
| * x coordinate | ||
| * @param y | ||
| * y coordinate |
There was a problem hiding this comment.
Also fix params + javadocs for the constructor
| @@ -403,10 +417,11 @@ protected void parseWkb() { | |||
| } | |||
|
|
|||
| private void readPoints() { | |||
There was a problem hiding this comment.
Looks like a few methods are duplicated in both Geometry/Geography classes and they should be moved to SQLServerSpatialDatatype.
- parseWkb(), exact duplicate.
- readPoints(), serializeToWkb() - The only difference is you have to read yValues before xValues. Can you add some kind of a check and move these methods to SQLServerSpatialDatatype too?
- There is a lot of duplication in other methods too, please take a look and move to SQLServerSpatialDatatype when possible.
| throw new BatchUpdateException(e.getMessage(), null, 0, null); | ||
| } catch (IllegalArgumentException e) { | ||
| } | ||
| catch (IllegalArgumentException | StringIndexOutOfBoundsException e) { |
There was a problem hiding this comment.
I guess this change is not related to Spatial types? You probably need to update the comment below too.
There was a problem hiding this comment.
Please move this change out of this PR as we already have another active PR to track useBulkCopyWithBatchInsert API changes. It will be easier to track changes there.
|
|
||
| private void checkNegSize(int num) throws SQLServerException { | ||
| if (num < 0) { | ||
| MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_ParsingError")); |
There was a problem hiding this comment.
why don't you call throwIllegalWKB() instead here?
|
Approved, assuming we will improve the way we handle exceptions. |
| * Spatial Reference Identifier value | ||
| * @return Geography Geography instance | ||
| * @throws SQLServerException | ||
| * if an exception occurs |
There was a problem hiding this comment.
I guess you missed out on the method params: x and y should be changed to latitude/longitude respectively.
Refer: MS Docs
| @@ -22,17 +27,20 @@ public class Geometry extends SQLServerSpatialDatatype { | |||
| * if an exception occurs | |||
| */ | |||
| private Geometry(String WellKnownText, int srid) throws SQLServerException { | |||
There was a problem hiding this comment.
First character in param name must not be capitalized. Please change to 'wellKnownText'
| * Constructor for a Geometry instance from an Open Geospatial Consortium (OGC) Well-Known Text (WKT) | ||
| * representation. Spatial Reference Identifier is defaulted to 0. | ||
| * | ||
| * @param wkt |
There was a problem hiding this comment.
This method has param name as wkt, the other method has wellKnownText, can we generalize and use same name for all similar parameters?
| throw new BatchUpdateException(e.getMessage(), null, 0, null); | ||
| } catch (IllegalArgumentException e) { | ||
| } | ||
| catch (IllegalArgumentException | StringIndexOutOfBoundsException e) { |
There was a problem hiding this comment.
Please move this change out of this PR as we already have another active PR to track useBulkCopyWithBatchInsert API changes. It will be easier to track changes there.
| wkb = buf.array(); | ||
|
|
||
| } | ||
| return; |
There was a problem hiding this comment.
Do we need this return statement here? Also a blank line in the else block above looks unnecessary.
|
|
||
| package com.microsoft.sqlserver.jdbc; | ||
|
|
||
| import java.nio.BufferUnderflowException; |
There was a problem hiding this comment.
Do we still need to import this?
| coords[numOfCoordinates] = Double.NaN; | ||
| currentWktPos = currentWktPos + 4; | ||
| } else { | ||
| MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_illegalWKTposition")); |
There was a problem hiding this comment.
Please create a method throwIllegalWKTposition. There are at least 5 places where you construct the Exception.
* Update Snapshot for upcoming RTW release v7.0.0 * Change order of logic for checking the condition for using Bulk Copy API (#736) Fix | Change order of logic for checking the condition for using Bulk Copy API (#736) * Update CHANGELOG.md * Merge pull request #732 from cheenamalhotra/module (Export driver in automatic module) Introduce Automatic Module Name in POM. * Update CHANGELOG.md * Change Sha1HashKey to CityHash128Key for generating PreparedStatement handle and metadata cache keys (#717) * Change Sha1HashKey to CityHash128Key * Formatted code * Prepared statement performance fixes 1) Further speedups to prepared statement hashing 2) Caching of '?' chararacter positiobs in prepared statements to speed parameter substitution * String compare for hash keys added missing line for bulkcopy tests. * comment change * Move CityHash class to a separate file * spacings fixes cleaner code & logic * Add | Adding useBulkCopyForBatchInsert property to Request Boundary methods (#739) * Apply the collation name change to UTF8SupportTest * Package changes for CityHash with license information (#740) * Reformatted Code + Updated formatter (#742) * Reformatted Code + Updated formatter * Fix policheck issue with 'Country' keyword (#745) * Adding a new test for beginRequest()/endRequest() (#746) * Add | Adding a new test to notify the developers to consider beginRequest()/endRequest() when adding a new Connection API * Fix | Fixes for issues reported by static analysis tools (SonarQube + Fortify) (#747) * handle buffer reading for invalid buffer input by user * Revert "handle buffer reading" This reverts commit 11e2bf4. * updated javadocs (#754) * fixed some typos in javadocs (#760) * API and JavaDoc changes for Spatial Datatypes (#752) Add | API and JavaDoc changes for Spatial Datatypes (#752) * Disallow non-parameterized queries for Bulk Copy API for batch insert (#756) fix | Disallow non-parameterized queries for Bulk Copy API for batch insert (#756) * Formatting | Change scope of unwanted Public APIs + Code Format (#757) * Fix unwanted Public APIs. * Updated formatter to add new line to EOF + formatted project * Release | Release 7.0 changelog and version update (#748) * Updated Changelog + release version changes * Changelog entry updated as per review. * Updated changelog for new changes * Terminology update: request boundary declaration APIs * Trigger Appveyor * Update Samples and add new samples for new features (#761) * Update Samples and add new Samples for new features * Update samples from Peter * Updated JavaDocs * Switch to block comment * Update License copyright (#767)
Changes needed after fuzz testing.