spatial
spatial copied to clipboard
Updating a node creates new RTREE_REFERENCE relationship
The nodes in our geospatial index can change location (frequently). At the moment, we modify the properties in the node and add it to the index anew by posting to:
/db/data/ext/SpatialPlugin/graphdb/addNodeToLayer
with
{"layer": "geom", "node", "nodeID"}
Which updates the bounding boxes of the geospatial index, but creates a new RTREE_REFERENCE relationship. Is there a way to update the geospatial location of a node, without creating a new relationship after each update operation?
Alternatively we can create a batch job which reduces X references (X > 1) to 1; or delete the first reference in the same transaction, but preferably we would like to avoid it.
from what I get, frequently moving things are not supposed to be modeled as geospatial nodes... I mean, you wouldn't call a cow a geospatial landmark, would you? (not meant to offend anyone, just making an example, same with cars and stuff) or, hang on... are you implementing a Sims City-styled virtual building reality with Spatial? that would be an interesting use case the creators certainly haven't thought of! I'd add a "like" to this idea!
Sorry to disappoint you, we are not implementing a Sims City-styled virtual building reality. We have neo4j entities with location properties, and would like to use the Neo4j Spatial library for Geospatial operations on Neo4j entities, to perform a geospatial operation (withinDistance) on these entities.
so it's kind of how far cars are away from each other?
Correct, from a certain location. In case anyone is interested, our current approach cleans up the database at regular moments with the following commands:
Clean double relationships
match s-[r:RTREE_REFERENCE]->e
with s,e,type(r) as typ, tail(collect(r)) as coll
foreach(x in coll | delete x)
Clean empty bounding boxes:
match (x)-[r:RTREE_CHILD]->(n)
WHERE NOT (n)-[]->()
delete r,n
The latter query would be cleaner if the bounding box nodes had a label, like the RTREE metadata node.