Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public boolean equals(Object o) {
return false;
}
DefaultGeometry that = (DefaultGeometry) o;
return this.getOgcGeometry().equals(that.getOgcGeometry());
return this.getOgcGeometry().equals((Object) that.getOgcGeometry());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@

import com.datastax.dse.driver.api.core.data.geometry.LineString;
import com.datastax.dse.driver.api.core.data.geometry.Point;
import com.datastax.oss.driver.shaded.guava.common.collect.Streams;
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;
Expand Down Expand Up @@ -101,8 +105,25 @@ 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;
double[] arr = Streams.stream(elemArray.elements()).mapToDouble(JsonNode::asDouble).toArray();
assertThat(arr).isEqualTo(expected[i]);
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
import static org.assertj.core.api.Fail.fail;

import com.datastax.dse.driver.api.core.data.geometry.Point;
import com.datastax.oss.driver.shaded.guava.common.collect.Streams;
import com.esri.core.geometry.ogc.OGCPoint;
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;
Expand Down Expand Up @@ -83,8 +87,19 @@ public void should_parse_valid_geo_json() {
}

@Test
public void should_convert_to_geo_json() {
assertThat(point.asGeoJson()).isEqualTo(json);
public void should_convert_to_geo_json() throws Exception {

ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(point.asGeoJson());
assertThat(root.get("type").toString()).isEqualTo("\"Point\"");

double expected[] = {1.1, 2.2};
JsonNode coordinatesNode = root.get("coordinates");
assertThat(coordinatesNode.isArray()).isTrue();
ArrayNode coordinatesArray = (ArrayNode) coordinatesNode;
double[] arr =
Streams.stream(coordinatesArray.elements()).mapToDouble(JsonNode::asDouble).toArray();
assertThat(arr).isEqualTo(expected);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
import com.datastax.dse.driver.api.core.data.geometry.LineString;
import com.datastax.dse.driver.api.core.data.geometry.Point;
import com.datastax.dse.driver.api.core.data.geometry.Polygon;
import com.datastax.oss.driver.shaded.guava.common.collect.Streams;
import com.esri.core.geometry.ogc.OGCPolygon;
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;
Expand Down Expand Up @@ -109,8 +113,43 @@ public void should_parse_valid_geo_json() {
}

@Test
public void should_convert_to_geo_json() {
assertThat(polygon.asGeoJson()).isEqualTo(json);
public void should_convert_to_geo_json() throws Exception {

ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(polygon.asGeoJson());
assertThat(root.get("type").toString()).isEqualTo("\"Polygon\"");

/*
Note that the order of values in expected differs from the order of insertion when creating
the Polygon. OGC expects the "exterior" ring of the polygon to be listed in counter-clockwise
order... and that's what this sequence represents (draw it out on a graph if you don't believe me).

Weirdly this is the opposite of the order used for this test when we were using ESRI 1.2.1.
That fact (combined with the fact that only ESRI classes are used for serialization here) makes me
think that the earlier version was just doing it wrong... or at least doing it in a way that
didn't agree with the spec. Either way it is clearly correct that we should go counter-clockwise...
so that's what we're doing.
*/
double expected[][] = {{30.0, 10.0}, {40.0, 40.0}, {20.0, 40.0}, {10.0, 20.0}, {30.0, 10.0}};
JsonNode coordinatesNode = root.get("coordinates");
assertThat(coordinatesNode.isArray()).isTrue();
ArrayNode coordinatesArray = (ArrayNode) coordinatesNode;

// There's an extra layer here, presumably indicating the bounds of the polygon
assertThat(coordinatesArray.size()).isEqualTo(1);
JsonNode polygonNode = coordinatesArray.get(0);
assertThat(polygonNode.isArray()).isTrue();
ArrayNode polygonArray = (ArrayNode) polygonNode;

assertThat(polygonArray.size()).isEqualTo(5);
for (int i = 0; i < expected.length; ++i) {

JsonNode elemNode = polygonArray.get(i);
assertThat(elemNode.isArray()).isTrue();
ArrayNode elemArray = (ArrayNode) elemNode;
double[] arr = Streams.stream(elemArray.elements()).mapToDouble(JsonNode::asDouble).toArray();
assertThat(arr).isEqualTo(expected[i]);
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public void should_find_dependencies_from_file() {
expected.put("com.github.jnr:jffi", withUnverifiedRuntimeVersion("1.2.16"));
expected.put("io.netty:netty-buffer", withUnverifiedRuntimeVersion("4.0.56.Final"));
expected.put("org.ow2.asm:asm-commons", withUnverifiedRuntimeVersion("5.0.3"));
expected.put("org.json:json", withUnverifiedRuntimeVersion("20090211"));
expected.put("org.ow2.asm:asm-util", withUnverifiedRuntimeVersion("5.0.3"));
expected.put("com.github.jnr:jnr-ffi", withUnverifiedRuntimeVersion("2.1.7"));

Expand All @@ -91,7 +90,7 @@ public void should_find_dependencies_from_file() {
new PlatformInfoFinder(this::nullUrlProvider).fetchDependenciesFromFile(inputStream);

// then
assertThat(stringStringMap).hasSize(28);
assertThat(stringStringMap).hasSize(27);
assertThat(stringStringMap).isEqualTo(expected);
}

Expand Down
1 change: 0 additions & 1 deletion core/src/test/resources/insights/test-dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ The following files have been resolved:
org.ow2.asm:asm-analysis:jar:5.0.3:compile
com.github.jnr:jnr-x86asm:jar:1.0.2:compile
io.netty:netty-codec:jar:4.0.56.Final:compile
org.json:json:jar:20090211:compile
com.github.jnr:jffi:jar:native:1.2.16:runtime
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,10 @@ public static CompositeOption esriBundles() {
CoreOptions.wrappedBundle(
mavenBundle("com.esri.geometry", "esri-geometry-api").versionAsInProject())
.exports("com.esri.core.geometry.*")
.imports("org.json", "org.codehaus.jackson")
.imports("com.fasterxml.jackson.*", "com.fasterxml.jackson.databind.*")
.bundleSymbolicName("com.esri.core.geometry")
.overwriteManifest(WrappedUrlProvisionOption.OverwriteMode.FULL),
mavenBundle("org.json", "json").versionAsInProject(),
mavenBundle("org.codehaus.jackson", "jackson-core-asl").versionAsInProject(),
mavenBundle("com.fasterxml.jackson.core", "jackson-core").versionAsInProject(),
systemProperty("cassandra.geo").value("true"));
}

Expand Down
8 changes: 1 addition & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<hdrhistogram.version>2.1.12</hdrhistogram.version>
<metrics.version>4.1.18</metrics.version>
<netty.version>4.1.130.Final</netty.version>
<esri.version>1.2.1</esri.version>
<esri.version>2.2.4</esri.version>
<!--
When upgrading TinkerPop please upgrade the version matrix in
manual/core/integration/README.md
Expand All @@ -68,7 +68,6 @@
<slf4j.version>2.0.16</slf4j.version>
<!-- when changing version also update version in LICENSE_binary -->
<reactive-streams.version>1.0.3</reactive-streams.version>
<json.version>20230227</json.version>
<jackson.version>2.13.5</jackson.version>
<jackson-databind.version>${jackson.version}</jackson-databind.version>
<!-- optional dependencies -->
Expand Down Expand Up @@ -162,11 +161,6 @@
<artifactId>esri-geometry-api</artifactId>
<version>${esri.version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>${json.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-core</artifactId>
Expand Down
9 changes: 9 additions & 0 deletions upgrade_guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ under the License.

## Upgrade guide

### 4.19.3

#### Ordering of points in DefaultPolygon

This version includes an update to the ESRI dependency which appears to be more strict about following the OGC
requirement that points of a polygon should be returned in counter-clockwise order. It's possible that
previous versions of the driver could have returned these points in a different order so if your application
relies on the ordering of points in a polygon make sure to test this behaviour when upgrading.

### 4.18.1

#### Keystore reloading in DefaultSslEngineFactory
Expand Down