简体   繁体   English

使用REST / neo4jclient将节点添加到C#中的空间层

[英]adding nodes to spatial layer in c# using REST /neo4jclient

I am making a locations based application in c#, and I am using neo4j and neo4j spatial plugin to handle it. 我正在用C#创建一个基于位置的应用程序,并且正在使用neo4j和neo4j空间插件来处理它。 for communication with spatial plugin, I have to use its REST API as there is currently no support for it in neo4jClient. 为了与空间插件进行通信,我必须使用其REST API,因为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? 现在我想将所有节点(带有位置数据,即lat,lon)添加到空间层 ,为此我需要所有neo4j节点ID,我的问题是有没有办法通过其数据获取先前插入的节点的节点ID(在这种情况下,是经纬度),还是有更好的方法将节点添加到空间层?

EDIT: I'm also using neo4jClient for other insertion and retrievals 编辑:我还使用neo4jClient进行其他插入和检索

First of all, there isn't an other approach than adding the nodes to a spatial by their IDs. 首先,除了通过节点的ID将节点添加到空间外,没有其他方法。

You can write a Cypher-query that retrieves all the node Ids by using the function has(n.Property), eg: 您可以编写一个Cypher查询,通过使用has(n.Property)函数来检索所有节点ID,例如:

// 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. 因此,还有一个其他的REST端点:addMultipleNodesToLayer。 But seems like it wasn't pushed yet. 但是似乎还没有推送。 I already asked about that and hope that it will be availible soon. 我已经问过这个问题,并希望不久后可以使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM