Skip to content

Commit f42214c

Browse files
committed
Adjustments after review
1 parent 816ca87 commit f42214c

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/main/java/org/neo4j/gis/spatial/encoders/NativePointsEncoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public Geometry decodeGeometry(Entity container) {
6363
.map(point -> {
6464
if (point.getCRS().getCode() != crs.getCode()) {
6565
throw new IllegalStateException(
66-
"Trying to decode geometry with wrong CRS: layer configured to crs=" + crs
66+
"Trying to decode geometry with wrong CRS: layer configured to crs=" + crs.getCode()
6767
+ ", but geometry has crs=" + point.getCRS().getCode());
6868
}
6969
double[] coordinate = point.getCoordinate().getCoordinate();

src/test/java/org/neo4j/gis/spatial/procedures/SpatialProceduresTest.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import static org.junit.jupiter.api.Assertions.assertEquals;
3030
import static org.junit.jupiter.api.Assertions.assertFalse;
3131
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
32+
import static org.junit.jupiter.api.Assertions.assertThrows;
3233
import static org.junit.jupiter.api.Assertions.assertTrue;
3334
import static org.junit.jupiter.api.Assertions.fail;
3435
import static org.neo4j.gis.spatial.Constants.LABEL_LAYER;
@@ -54,6 +55,7 @@
5455
import org.neo4j.gis.spatial.utilities.ReferenceNodes;
5556
import org.neo4j.graphdb.GraphDatabaseService;
5657
import org.neo4j.graphdb.Node;
58+
import org.neo4j.graphdb.QueryExecutionException;
5759
import org.neo4j.graphdb.Result;
5860
import org.neo4j.graphdb.Transaction;
5961
import org.neo4j.graphdb.spatial.Geometry;
@@ -1254,6 +1256,46 @@ public void testNativePoints() {
12541256
testCallCount(db, "CALL spatial.closest('line',{lon:5.1, lat:4.1}, 1.0)", null, 1);
12551257
}
12561258

1259+
@Test
1260+
public void testNativePoints3D() {
1261+
execute("CREATE (node:Foo { points: [point({latitude: 5.0, longitude: 4.0, height: 1.0}), point({latitude: 6.0, longitude: 5.0, height: 2.0})]})");
1262+
Exception exception = assertThrows(QueryExecutionException.class, () -> {
1263+
execute("CALL spatial.addLayer('line','NativePoints','points:bbox:Cartesian') YIELD node" +
1264+
" MATCH (n:Foo)" +
1265+
" WITH collect(n) AS nodes" +
1266+
" CALL spatial.addNodes('line', nodes) YIELD count RETURN count");
1267+
});
1268+
1269+
assertEquals(
1270+
"Failed to invoke procedure `spatial.addNodes`: Caused by: java.lang.IllegalStateException: Trying to decode geometry with wrong CRS: layer configured to crs=7203, but geometry has crs=4979",
1271+
exception.getMessage());
1272+
}
1273+
1274+
@Test
1275+
public void testNativePointsCartesian() {
1276+
execute("CREATE (node:Foo { points: [point({x: 5.0, y: 4.0}), point({x: 6.0, y: 5.0})]})");
1277+
execute("CALL spatial.addLayer('line','NativePoints','points:bbox:Cartesian') YIELD node" +
1278+
" MATCH (n:Foo)" +
1279+
" WITH collect(n) AS nodes" +
1280+
" CALL spatial.addNodes('line', nodes) YIELD count RETURN count");
1281+
testCallCount(db, "CALL spatial.closest('line',point({x:5.1, y:4.1}), 1.0)", null, 1);
1282+
}
1283+
1284+
@Test
1285+
public void testNativePointsCartesian3D() {
1286+
execute("CREATE (node:Foo { points: [point({x: 5.0, y: 4.0, z: 1}), point({x: 6.0, y: 5.0, z: 2})]})");
1287+
Exception exception = assertThrows(QueryExecutionException.class, () -> {
1288+
execute("CALL spatial.addLayer('line','NativePoints','points:bbox:Cartesian') YIELD node" +
1289+
" MATCH (n:Foo)" +
1290+
" WITH collect(n) AS nodes" +
1291+
" CALL spatial.addNodes('line', nodes) YIELD count RETURN count");
1292+
});
1293+
1294+
assertEquals(
1295+
"Failed to invoke procedure `spatial.addNodes`: Caused by: java.lang.IllegalStateException: Trying to decode geometry with wrong CRS: layer configured to crs=7203, but geometry has crs=9157",
1296+
exception.getMessage());
1297+
}
1298+
12571299
/*
12581300
12591301
@Test

0 commit comments

Comments
 (0)