Hi im new to neo4j and trying to figure out how everything works atm
I importet a OSM file and now im working on a function which you can input a point in WGS84 format and a POI and then the function finds the shortest path to the POI.
So for finding the nearest Geometries to my WGS84 Point I use
Coordinate co = new Coordinate(12.9639158,56.070904);
List<SpatialDatabaseRecord> results2 = GeoPipeline
.startNearestNeighborLatLonSearch(layer, co, 1)
.toSpatialDatabaseRecordList();
but then my problems start because i don't really understand how the OSM file is built up
Is there a function so that i can get my POI Node by name? I get an index from the OSM file
SpatialDatabaseService spatialService = new SpatialDatabaseService(database);
Layer layer = spatialService.getLayer(osm);
LayerIndexReader spatialIndex = layer.getIndex();
Can I use it to search Nodes by properties?
And for finding the shortest Way between the points I found a dijkstra Algorithm
PathFinder<WeightedPath> finder = GraphAlgoFactory.dijkstra(
Traversal.expanderForTypes( ExampleTypes.MY_TYPE, Direction.BOTH ), "cost" );
WeightedPath path = finder.findSinglePath( nodeA, nodeB );
The question now is what are my RelationshipTypes??? I think it shoud be NEXT but how do I include this in the code? Do I have to create an Enum with NEXT???
Can someone give me some feedback if im on the right way and give me some help please?
Okay finally found out how to find Nodes by id :D not too difficult but i searched for a long time :D
Thank you
I can make a few comments:
Finally, two suggestions for finding POI by name. Either: - dynamic layers - or geopipes
For Dynamic layers you can use either CQL syntax or key,value pairs (for tags). For examples of each see lines 81 and 84 of https://github.com/neo4j/spatial/blob/master/src/test/java/org/neo4j/gis/spatial/TestDynamicLayers.java. This approach allows the test for name to be done during the traversal in a callback from the RTree.
For GeoPipes, you define a stream, and each object returned by the RTree will be passed to the next filter. This should have the same performance as the dynamic layers, and also be a bit more intuitive to use. See for example the 'filter_by_osm_attribute' and 'filter_by_property' tests on lines 99 and 112 of https://github.com/neo4j/spatial/blob/master/src/test/java/org/neo4j/gis/spatial/pipes/GeoPipesTest.java. These both search for streets by name.