I'm using this code to find nearest nabours to an given point in the wgs84 format(the variable co)
for(Node n : geomPoints){
ExecutionResult result = engine.execute("START a=node(" + n.getId() + ") "+
"MATCH a-[:FIRST_NODE]->()-[:NEXT*0..]->()-[:NODE]->b "+
"RETURN b");
Iterator<Node> nodes = result.columnAs("b");
while(nodes.hasNext()){
Node nodesInGeom = nodes.next();
Float lon = Float.parseFloat(nodesInGeom.getProperty("lon").toString());
Float lat = Float.parseFloat(nodesInGeom.getProperty("lat").toString());
Coordinate coo = new Coordinate(lon,lat);
if(co.distance(coo)<distance) {
distance = co.distance(coo);
nearestNabour = nodesInGeom;
}
}
So the important part of this code is this part
co.distance(coo)
because I was told that this function uses the euclidian distance and not the distance, that I need fpr the wgs84 format
So my question is: Is there a function in neo4j satial, that returns the right distance??
Thanks alot