views:

113

answers:

1

I would like to store coordinates as nodes in neo4j to do simple querys

For example a list of 10,000 nodes:

Node[1] -   lon=-74.007124, lat=40.714550
Node[2] -   lon=-94.626824, lat=39.113380
Node[3] -   lon=-105.937406, lat=35.691543
Node[4] -   lon=-122.329439, lat=47.603560
Node[5] -   lon=-122.420139, lat=37.779600
    ..
    ..

I would like to find all nodes within 10km of the following coordinate :(lon=-120.42, lat=37.76)

I have been looking at neo4j spatial but there is not much docs, is it possible to do this using a lucene query

+1  A: 

I have uploaded some example code i used with sample data containing 1000 Bus Stop/Coordinate data from Dublin in case anyone is interested here: http://github.com/paddydub/Neo4j-Spatial-Example

It finds Bus Stops within 200m from the point (53.352788,-6.264396) It should return a Sorted HashMap

Output:

stopid: 1100300027 metres: 0.0
stopid: 1000500001 metres: 13.726485289384284
stopid: 1100200027 metres: 13.726485289384284
stopid: 1100500048 metres: 13.726485289384284
stopid: 1100100001 metres: 13.726485289384284
stopid: 1100400029 metres: 92.4113082700094
stopid: 1100401034 metres: 92.4113082700094
stopid: 1000300025 metres: 171.01481687376895
stopid: 1000200001 metres: 171.01481687376895
stopid: 1000100001 metres: 171.01481687376895
stopid: 1000401001 metres: 190.21917556849772
stopid: 1000400001 metres: 190.21917556849772
paddydub