Hi Bryce, Currently the OSM model in Neo4j Spatial only indexes the ways, which means that when you do spatial searches on the layers, you are always talking about the ways. Whether this suites you or not depends on your specific use case. You could search for the closest ways, and the use the SpatialTopologyUtils to snap to the point node on the way that is closest to your point of interest, which may give you the result you want.
If you are specifically interested in only searching on nodes, not ways, then there are two options, both requiring some refactoring of the OSM model (ie. you need to make changes to Neo4j Spatial). - In the OSMImporter code, simply add all nodes as Point geometries to the index. This is simple to code and will get what you want, but might not lead to the most efficient index, since both the ways and the nodes they are composed of get indexed in the same index. - Enhance the OSM model to support multiple indexes, for nodes, ways and relationships. This requires much more code, but opens the possibility to enhance the performance by allowing the index to be optimized for the geometries and densities seen in the dataset. The reasons we have not done this yet are: - Existing use cases have not required it (but we are reaching cases that do now) - It is not clear yet which of the above options is the best overall (one index or several). Originally I believed in the multiple-index approach, mostly because points can be indexed with very different indexes than geometries (eg. we can even place lucene behind the point index, which we cannot do for geometries). But at the moment I am leaning back towards the single index approach (simpler code). So, I hope the approach of searching for close ways, and then using the topology utils to snap to the closest point is the right solution for you. Otherwise considering contributing to the updates necessary to complete the point index :-) Regards, Craig On Tue, Jan 18, 2011 at 6:08 PM, bryce hendrix <[email protected]>wrote: > Peter, > > I think my problem is more of understanding how the graph is built from OSM > data. The method of find the closest edge gives me the way geometry, but > (please correct me if I am wrong) I need to find the closest OSM node (Node > with "lat" and "lon" properties) in the geometry. > > Thanks, > Bryce > > On Tue, Jan 18, 2011 at 2:05 AM, Peter Neubauer < > [email protected]> wrote: > > > Bryce, > > are you looking for some kind of "snapping" to the nearest geometry? I > > was doing something like that, Craig did a test on that, see > > > > > https://github.com/neo4j/neo4j-spatial/blob/master/src/test/java/org/neo4j/gis/spatial/TestSpatialUtils.java#L53 > > , > > there is some basic support for that in > > > > SpatialTopologyUtils.java. > > > > Does that help to get started? Feel free to add more utilities and > > maybe a routing example, when you get it working. > > > > Cheers, > > > > /peter neubauer > > > > GTalk: neubauer.peter > > Skype peter.neubauer > > Phone +46 704 106975 > > LinkedIn http://www.linkedin.com/in/neubauer > > Twitter http://twitter.com/peterneubauer > > > > http://www.neo4j.org - Your high performance graph > database. > > http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. > > > > > > > > On Tue, Jan 18, 2011 at 5:50 AM, bryce hendrix <[email protected]> > > wrote: > > > Craig, > > > > > > I've ran into a bit of a stumbling block. I am attempting to do find a > > > simple route using A* from 2 nodes on 2 different ways. What is the > best > > way > > > to find the points closest to 2 reference points which are on ways? > > Assuming > > > I've got those nodes, is there anything special I have to do, other > than > > > setting up the estimate and cost evaluators? > > > > > > If I can figure this out, I'll submit my example back to you guys. I'm > > > excited about this stuff, but I seem to be discovering the limits of > the > > > docs. > > > > > > Bryce > > > > > > On Sun, Jan 16, 2011 at 7:11 PM, Craig Taverner <[email protected]> > > wrote: > > > > > >> Great that they all work :-) > > >> > > >> Good luck with the rest of the project and keep us posted, we're > > interested > > >> in any feedback on the API. > > >> > > >> (getting lat/long mixed up is one of those things we all keep doing, > I'm > > >> pretty sure I did it once as recently as last month ... ;-) > > >> > > >> On Sun, Jan 16, 2011 at 11:52 PM, bryce hendrix < > [email protected] > > >> >wrote: > > >> > > >> > Craig, Peter, > > >> > > > >> > Its useful if I get the latitude and longitude in the correct order > > for > > >> the > > >> > Point. Ugh. I've found > > >> > that SearchPointsWithinOrthodromicDistance, SearchClosest, > > >> > and SpatialTopologyUtils.findClosestEdges all work for me. Looks > like > > my > > >> > project is well on its way now, thanks for the help. > > >> > > > >> > Bryce > > >> > > > >> > On Sun, Jan 16, 2011 at 3:16 PM, Craig Taverner <[email protected]> > > >> wrote: > > >> > > > >> > > The SearchPointsWithinOrthodromicDistance basically does a search > on > > a > > >> > > rectangular bounding box, and then inside the result set filters > by > > >> > > distance > > >> > > from the center. The filter probably works only on points as > implied > > by > > >> > the > > >> > > class name. > > >> > > > > >> > > The SpatialTopologyUtils class has a method findClosestEdge, which > > will > > >> > do > > >> > > what you are looking for. If you call it without a distance value, > > it > > >> > will > > >> > > take 1% of the total span of your layer as the search window, so > if > > >> this > > >> > > does not make sense for your data (eg. your layer covers a small > > area, > > >> as > > >> > > you hinted at), then pass in the distance in units of the > coordinate > > >> > system > > >> > > of the layer (probably WGS84, degrees, if you are using only OSM > > data). > > >> > Try > > >> > > it out and let us know. > > >> > > > > >> > > See: > > >> > > > > >> > > - > > >> > > > > >> > > > > >> > > > >> > > > https://github.com/neo4j/neo4j-spatial/blob/master/src/main/java/org/neo4j/gis/spatial/SpatialTopologyUtils.java > > >> > > - > > >> > > > > >> > > > > >> > > > >> > > > https://github.com/neo4j/neo4j-spatial/blob/master/src/test/java/org/neo4j/gis/spatial/TestSpatialUtils.java > > >> > > > > >> > > > > >> > > On Sun, Jan 16, 2011 at 11:19 AM, Peter Neubauer < > > >> > > [email protected]> wrote: > > >> > > > > >> > > > Bryce, > > >> > > > I think (Craig, correct me if I'm wrong) you need to have a > Point > > >> > > > layer to be able to do that search. The default OSM layer is > > >> > > > containing a lot of geometries, so I think you first should > define > > a > > >> > > > layer on top of the full imported one, then search. I did > > something > > >> > > > like that in another spike, see > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > > > https://github.com/popdevelop/snapplr/blob/master/server_java/src/main/java/com/geosnappr/TaginfoImporter.java#L312 > > >> > > > > > >> > > > The layer is defined with something like > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > > > https://github.com/neo4j/neo4j-spatial/blob/master/src/test/java/org/neo4j/gis/spatial/TestDynamicLayers.java#L26 > > >> > > > on top of the imported full data layer. > > >> > > > > > >> > > > Does that help? > > >> > > > > > >> > > > Cheers, > > >> > > > > > >> > > > /peter neubauer > > >> > > > > > >> > > > GTalk: neubauer.peter > > >> > > > Skype peter.neubauer > > >> > > > Phone +46 704 106975 > > >> > > > LinkedIn http://www.linkedin.com/in/neubauer > > >> > > > Twitter http://twitter.com/peterneubauer > > >> > > > > > >> > > > http://www.neo4j.org - Your high performance > graph > > >> > > database. > > >> > > > http://www.thoughtmade.com - Scandinavia's coolest > Bring-a-Thing > > >> > party. > > >> > > > > > >> > > > > > >> > > > > > >> > > > On Sat, Jan 15, 2011 at 10:58 PM, bryce hendrix < > > >> > [email protected]> > > >> > > > wrote: > > >> > > > > I'm pretty new to neo4j, so please excuse me if this is a FAQ. > > >> > > > > > > >> > > > > I exported OSM data for a city from the OSM site, then > imported > > it > > >> > > using > > >> > > > the > > >> > > > > OSMImporter. I can see the layer via the webserver, so I know > if > > >> got > > >> > > > > imported okay. Now I would like to find the way nearest to a > > >> > coordinate > > >> > > > via > > >> > > > > the Java API, but I'm not really sure how to do that. I've > tried > > >> > using > > >> > > > > SearchPointsWithinOrthodromicDistance, but the results of the > > query > > >> > are > > >> > > > > always empty. Can someone give me some tips, or provide a > simple > > >> > > example? > > >> > > > > > > >> > > > > Thanks in advance, > > >> > > > > Bryce > > >> > > > > _______________________________________________ > > >> > > > > Neo4j mailing list > > >> > > > > [email protected] > > >> > > > > https://lists.neo4j.org/mailman/listinfo/user > > >> > > > > > > >> > > > _______________________________________________ > > >> > > > Neo4j mailing list > > >> > > > [email protected] > > >> > > > https://lists.neo4j.org/mailman/listinfo/user > > >> > > > > > >> > > _______________________________________________ > > >> > > Neo4j mailing list > > >> > > [email protected] > > >> > > https://lists.neo4j.org/mailman/listinfo/user > > >> > > > > >> > _______________________________________________ > > >> > Neo4j mailing list > > >> > [email protected] > > >> > https://lists.neo4j.org/mailman/listinfo/user > > >> > > > >> _______________________________________________ > > >> Neo4j mailing list > > >> [email protected] > > >> https://lists.neo4j.org/mailman/listinfo/user > > >> > > > _______________________________________________ > > > Neo4j mailing list > > > [email protected] > > > https://lists.neo4j.org/mailman/listinfo/user > > > > > _______________________________________________ > > Neo4j mailing list > > [email protected] > > https://lists.neo4j.org/mailman/listinfo/user > > > _______________________________________________ > Neo4j mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user > _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

