On Fri, Jun 4, 2010 at 04:41, Paddy <paddyf...@gmail.com> wrote: > I have been looking at the neo4j spatial project but there is not much docs, > is it possible to do this using neo4j spatial or lucene query?
It's possible with both. If you use Latitude / Longitude coordinates you have to keep in mind that to calculate the distance between two points you can't use the Euclidean distance but some more complicated formula: http://en.wikipedia.org/wiki/Geographical_distance#Spherical-surface_formulae http://www.movable-type.co.uk/scripts/latlong-db.html I've just committed a Search class on github that should implement what you're looking for. I've made a little test, loading MaxMind Cities database, and searching within n km of my hometown and it seems to work. :) I'll send you an example in private, but basically here's what you can do: Layer layer = spatialService.getLayer("test_cities"); GeometryFactory gf = layer.getGeometryFactory(); // add points: layer.add(gf.createPoint(new Coordinate(longitude, latitude)), new String[] { "City" }, new Object[] { cityName }); ... // search: SpatialIndexReader reader = layer.getIndex(); Point startingPoint = gf.createPoint(new Coordinate(10.75, 45.0)); double maxDistanceInKm = 10; Search search = new SearchPointsWithinOrthodromicDistance(startingPoint, maxDistanceInKm); List<SpatialDatabaseRecord> results = reader.executeSearch(search); Regards, -- Davide Savazzi _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user