-
Notifications
You must be signed in to change notification settings - Fork 888
CASSJAVA-108 Update org.json (and very likely ESRI) dependency #2052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.x
Are you sure you want to change the base?
Changes from 7 commits
9869638
33ac076
657acc1
1e652b3
8977df0
5421b18
c84a4a3
a22b6f8
6deade2
06fefa4
1662665
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,9 @@ | |
| import com.datastax.dse.driver.api.core.data.geometry.LineString; | ||
| import com.datastax.dse.driver.api.core.data.geometry.Point; | ||
| import com.esri.core.geometry.ogc.OGCLineString; | ||
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.databind.node.ArrayNode; | ||
| import java.nio.ByteBuffer; | ||
| import java.nio.ByteOrder; | ||
| import org.junit.Test; | ||
|
|
@@ -101,8 +104,27 @@ public void should_parse_valid_geo_json() { | |
| } | ||
|
|
||
| @Test | ||
| public void should_convert_to_geo_json() { | ||
| assertThat(lineString.asGeoJson()).isEqualTo(json); | ||
| public void should_convert_to_geo_json() throws Exception { | ||
|
|
||
| ObjectMapper mapper = new ObjectMapper(); | ||
| JsonNode root = mapper.readTree(lineString.asGeoJson()); | ||
| assertThat(root.get("type").toString()).isEqualTo("\"LineString\""); | ||
|
|
||
| double expected[][] = {{30.0, 10.0}, {10.0, 30.0}, {40.0, 40.0}}; | ||
| JsonNode coordinatesNode = root.get("coordinates"); | ||
| assertThat(coordinatesNode.isArray()).isTrue(); | ||
| ArrayNode coordinatesArray = (ArrayNode) coordinatesNode; | ||
| assertThat(coordinatesArray.size()).isEqualTo(3); | ||
| for (int i = 0; i < expected.length; ++i) { | ||
|
|
||
| JsonNode elemNode = coordinatesArray.get(i); | ||
| assertThat(elemNode.isArray()).isTrue(); | ||
| ArrayNode elemArray = (ArrayNode) elemNode; | ||
| assertThat(elemArray.size()).isEqualTo(2); | ||
| assertThat(elemArray.get(0).asDouble()).isEqualTo(expected[i][0]); | ||
| assertThat(elemArray.get(1).asDouble()).isEqualTo(expected[i][1]); | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps the most contentious change in the whole PR. With this code we no longer concern ourselves with the format of the GeoJSON returned by ESRI... we only seek to confirm that we can find the fields we expect at the places we expect them. Any additional content or formatting isn't our concern. My rationale is that this is really the heart of the matter. We don't claim to follow a specific GeoJSON spec or that any responses will contain only some properties but not any others. With that in mind our objective should be to make sure we don't see any regressions on the props customers actually expect, specifically the "type" and "coordinates" fields.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: without this change you get failures like the following: |
||
| ; | ||
| } | ||
|
|
||
| @Test | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ESRI 1.2.1 used to test equality by a literal comparison across fields of OGCGeometry types. As of 2.2.4 this was changed to two distinct comparisons: equals(Object) (the standard Java equality op) and equals(OGCGeometry). The later was subsequently deprecated and moved to an Equals(OGCGeometry) method. The code above was calling the (now deprecated) method.
More info can be found on a thread starting from the relevant esri-geometry-api PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: without this change you get failures like the following: