I am making a locations based application in c#, and I am using neo4j and neo4j spatial plugin to handle it. for communication with spatial plugin, I have to use its REST API as there is currently no support for it in neo4jClient. now I want to add all the nodes (with location data ie lat, lon) to spatial layer , for which I need all the neo4j node Ids, my qusestion is there any way to get the node id of previously inserted nodes through it's data(in this case, its lat/lon), or is there any better approch to add nodes to spatial layer?
EDIT: I'm also using neo4jClient for other insertion and retrievals
First of all, there isn't an other approach than adding the nodes to a spatial by their IDs.
You can write a Cypher-query that retrieves all the node Ids by using the function has(n.Property), eg:
// cypher-query to retrieve node Ids
client.Cypher
.Match("(n:SpatialIndex)")
.Where("has(n.lat)")
.AndWhere("has(n.lon)")
.Return(node => node.Id());
// add existing node to SimplePoint-Layer
public void AddNodeToLayer(long nodeId, string layer)
{
string URINode = string.Format("{0}node/{1}",_client.BaseUrl, nodeId);
string json = string.Format("{{\"layer\":\"{0}\", \"node\":\"{1}\"}}", layer, URINode);
string URIAdd = string.Format("{0}ext/SpatialPlugin/graphdb/addNodeToLayer", _client.BaseUrl);
HTTPCommand(new Uri(URIAdd), json);
}
Acutally there was an other REST-endpoint: addMultipleNodesToLayer. But seems like it wasn't pushed yet. I already asked about that and hope that it will be availible soon.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.