vvavepacket
vvavepacket

Reputation: 1929

unable find geometries in neo4j spatial

I'm using neo4j spatial 0.15 and neo4j 2.3.3. I have imported a shapefile and saw that geometries now exists on my database.

enter image description here

enter image description here

Now, I would like to find all the geometries using bounding box.

SpatialDatabaseService spatialService = new SpatialDatabaseService(database);
Layer layer = spatialService.getLayer("layer_roads");
SpatialIndexReader spatialIndex = layer.getIndex();

LayerIndexReader rtreeIndex = layer.getIndex();
Envelope bbox = rtreeIndex.getBoundingBox();
SearchIntersect searchQuery = new SearchIntersect(layer, layer.getGeometryFactory().toGeometry(Utilities.fromNeo4jToJts(bbox)));
SearchRecords results = rtreeIndex.search(searchQuery);

When I go through the results variable, I saw that there are no geometries return. Why is it's not appearing, even though I see that geometries are existing on my database.

enter image description here

Upvotes: 4

Views: 170

Answers (1)

Craig Taverner
Craig Taverner

Reputation: 769

I looked into the test cases and found a test that used code very similar to your code, at https://github.com/neo4j-contrib/spatial/blob/master/src/test/java/org/neo4j/gis/spatial/TestSpatial.java#L269. This test runs on both SHP and OSM data models and does find results. One difference in your code is you are using the bbox from the layer index, so I changed the test to do that, and it still worked. I think we cannot help without an example of your data to see what is going wrong for you.

Upvotes: 1

Related Questions