【问题标题】:Neo4j Spatial work for POST but not work cypherNeo4j 用于 POST 的空间工作,但不能工作密码
【发布时间】:2016-09-01 09:00:42
【问题描述】:

我使用过 Neo4j 3.0.4 + Spatial。

我正在使用 curl,我已经打了这个电话:

addSimplePointLayer,(create nodes),addNodeToLayer

在这一点上,我尝试:

findGeometriesWithinDistance

并且工作完美(我需要将 lat,lon 更改为 lon,lat...)

但我需要在密码中使用,例如:

START n=node:geom('withinDistance:[40.39742917035895,-3.495200140744832, 100.0]') 
  WITH n 
  WHERE n:TypeX
  RETURN n;

这永远不会返回结果,因为“geom”是空的。我没有任何索引,我尝试使用提供程序“空间”创建一个新索引,但不起作用(我已阅读该选项已删除)。

我可以将TypeX的所有节点都放在geom索引中吗?或者我可以在没有索引的情况下使用withinDistance吗? (我认为在哪里不能使用这个)

【问题讨论】:

  • 我发现这个: MATCH (r:Restaurant) WHERE distance(point(r),point({latitude:40.39682978190974,longitude:-3.4897354662994173}))

标签: neo4j spatial


【解决方案1】:

已在 Neo4j 3.x 的空间扩展中删除了索引提供程序,以支持使用 procedures。相反,您可以直接从 Cypher 调用这些过程。例如:

创建一个 SimplePointLayer:

CALL spatial.addPointLayer("geom")

然后将Restaurant节点添加到层:

MATCH (r:Restaurant) WITH collect(r) AS restaurants
CALL spatial.addNodes("geom", restaurants) YIELD node
RETURN count(*)

然后执行距离内查询:

CALL spatial.withinDistance("geom",{latitude: 40.39742917035895,longitude:-3.495200140744832}, 100.0) YIELD node AS restaurant
RETURN restaurant

这些程序的文档仍在进行中,但在Github project READMEthis post 中有一些文档。

【讨论】:

    猜你喜欢
    • 2018-02-06
    • 2014-06-23
    • 1970-01-01
    • 1970-01-01
    • 2021-07-04
    • 2022-01-08
    • 1970-01-01
    • 2021-07-06
    • 1970-01-01
    相关资源
    最近更新 更多