Robin
Robin

Reputation: 3850

Neo4J Spatial: Add all Nodes to Layer

I have a Neo4J Database with Nodes that have an id, lat, and lon property.

I created a PointLayer and created a SpatialIndex.

Now I have to add all Nodes to the Index. The REST call for a single node is:

POST /db/data/ext/SpatialPlugin/graphdb/addNodeToLayer HTTP/1.1
Host: localhost:7474
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache

{ 
    "layer": "geom", 
    "node": "http://localhost:7474/db/data/node/<my_nodeid_goes_here>" 
}

But how can this be extended to match multiple or even every node?

Upvotes: 1

Views: 421

Answers (1)

Michael Hunger
Michael Hunger

Reputation: 41706

There is a function that does it for multiple nodes, you just pass a list of your nodes, see:

https://github.com/neo4j-contrib/spatial/blob/master/src/main/java/org/neo4j/gis/spatial/server/plugin/SpatialPlugin.java#L129

here is a test:

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

I would recommend to do perhaps 1000 at a time.

Upvotes: 1

Related Questions