0
votes

I have used Neo4j 3.0.4 + Spatial.

I am working with curl, and I have make this calls:

addSimplePointLayer,(create nodes),addNodeToLayer

In this point, I try:

findGeometriesWithinDistance

And work perfectly (I have need change lat,lon by lon,lat...)

But I need use in cypher, for example:

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

This never return results because "geom" is empty. I haven't any index, I try to create a new index with provider "spatial", and not work (i have read that is option was remove).

Can I put all nodes of TypeX in geom index?, or Can I use withinDistance without index? (I think in where is not posible use this)

1
I have found this: MATCH (r:Restaurant) WHERE distance(point(r),point({latitude:40.39682978190974,longitude:-3.4897354662994173})) < 2*1000 RETURN r It work withouth Spatial, Is it a good option?David González

1 Answers

0
votes

The index provider has been removed in the spatial extension for Neo4j 3.x in favor of using procedures. Instead you can call the procedures directly from Cypher. For example:

To create a SimplePointLayer:

CALL spatial.addPointLayer("geom")

Then to add Restaurant nodes to the layer:

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

Then to perform a within distance query:

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

Documentation for these procedures is still in progress, but there is some documentation on the Github project README and in this post.