Friday, 15 March 2013

Neo4j return calculated field in query for geographical distance -



Neo4j return calculated field in query for geographical distance -

i started working few weeks ago neo4j , want homecoming nodes in database (which contain property location in longitude/latitude format) ordered distance geographical point, current location.

this calculation needed:

dlon = lon2 - lon1 dlat = lat2 - lat1 = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2 c = 2 * atan2( sqrt(a), sqrt(1-a) ) d = r * c (where r radius of earth)

i've read documentation , can't find how store procedures execute i'd in other rdbms, , i'm pretty sure cannot perform sin or cos operation within query.

is there way execute query against database , ordered info rather getting results , create math 1 1 , homecoming them manually ordered?

cypher has haversin function calculate distances on surface of shere, see http://docs.neo4j.org/chunked/stable/query-functions-mathematical.html#functions-haversin

neo4j

No comments:

Post a Comment