assertEquals(coords.length, layer.getIndex().count());
}
@Test
public void testIndexingExistingPointNodesWithMultipleLocations() {
GraphDatabaseService db = graphDb();
SpatialDatabaseService sdb = new SpatialDatabaseService(db);
double x_offset = 0.15, y_offset = 0.15;
SimplePointLayer layerA = sdb.createSimplePointLayer("my-points-A", "xa", "ya", "bbox_a");
SimplePointLayer layerB = sdb.createSimplePointLayer("my-points-B", "xb", "yb", "bbox_b");
Coordinate[] coords = makeCoordinateDataFromTextFile("NEO4J-SPATIAL.txt", testOrigin);
try (Transaction tx = db.beginTx()) {
for (Coordinate coordinate : coords) {
Node n = db.createNode();
n.setProperty("xa", coordinate.x);
n.setProperty("ya", coordinate.y);
n.setProperty("xb", coordinate.x + x_offset);
n.setProperty("yb", coordinate.y + y_offset);
layerA.add(n);
layerB.add(n);
tx.success();
}
}
saveLayerAsImage(layerA, 700, 70);
saveLayerAsImage(layerB, 700, 70);
Envelope bboxA = layerA.getIndex().getBoundingBox();
Envelope bboxB = layerB.getIndex().getBoundingBox();
double[] centreA = bboxA.centre();
double[] centreB = bboxB.centre();
List<SpatialDatabaseRecord> resultsA;
List<SpatialDatabaseRecord> resultsB;
try (Transaction tx = db.beginTx()) {
resultsA = GeoPipeline.startNearestNeighborLatLonSearch(layerA,
new Coordinate(centreA[0] + 0.1, centreA[1]), 10.0).toSpatialDatabaseRecordList();
resultsB = GeoPipeline.startNearestNeighborLatLonSearch(layerB,
new Coordinate(centreB[0] + 0.1, centreB[1]), 10.0).toSpatialDatabaseRecordList();
tx.success();