2

是否可以在此查询中获取起始坐标和匹配节点之间的距离:

START n=node:stadiumsLocation('withinDistance:[53.489271,-2.246704, 5.0]') RETURN n

对于每个返回的 n,我还想知道从 n 到 [53.489271,-2.246704] 的距离

我知道结果是按距离排序的,但我能得到实际值吗?

4

2 回答 2

0

https://github.com/neo4j-contrib/spatial/blob/master/src/test/java/org/neo4j/gis/spatial/IndexProviderTest.java#L281

@Test
public void testDistance() throws ParseException {
WKTReader wktRdr = new WKTReader();
Geometry A = wktRdr.read("POINT(40.00 30.00 )");
Geometry B = wktRdr.read("POINT(40.00 40.00 )");
DistanceOp distOp = new DistanceOp(A, B);
assertEquals(10.0, distOp.distance(), 0);
}
于 2014-07-02T06:21:47.780 回答
0

您可以使用 HAVERSINE 函数来计算与匹配节点的距离,如下所示:

START n=node:stadiumsLocation('withinDistance:[53.489271,-2.246704, 5.0]') 
RETURN 2 * 6371 * asin(
  sqrt(
    haversin(radians(n.lat - 53.489271)) +
    cos(radians(n.lat)) *
    cos(radians(53.489271)) *
    haversin(radians(n.lon - (-2.246704)))
  )
) AS dist

空间插件似乎没有此功能的任何方法。

于 2016-04-05T09:49:42.363 回答