neo4j 3.4根据经纬度计算两点之间的距离
发布于 6 年前 作者 feng1990liu 4513 次浏览 来自 分享

https://neo4j.com/docs/developer-manual/current/cypher/functions/spatial/

create(l:Location) set l.latitude=toFloat(‘55.612151’),l.longitude=toFloat(‘12.995090’) return l

with point({latitude:55.612,longitude:12.995}) as poi match (l:Location) where l.latitude=55.612151 return distance(point({latitude:l.latitude,longitude: l.longitude}),poi) as distince

5 回复

如果只为计算两个节点上 经纬度之间的距离,不用 空间索引,直接 用距离公式计算也可以

@pangguoming 有文档吗?你说的是cypher实现?还是自定义比如java python 实现

@pangguoming 类似这种https://blog.csdn.net/sanyuesan0000/article/details/51683464?

cypher 实现, 节点上存lat,lng属性,我用cypher重写了 谷歌的 地理位置距离算法,你可以在cypher的where语句里,用下面方法来找 500米以内的 节点

  round( 
  6378.137 *1000*2*
   asin(sqrt(
        sin((radians(start.lat)-radians({start_lat}))/2)^2+cos(radians(start.lat))*cos(radians({start_lat}))* 
       sin((radians(start.lng)-radians({start_lng}))/2)^2
     ))
    )<500
回到顶部