Neo4J Spatial within distance returns 仅完全匹配
Neo4J Spatial within distance returns only exact matches
使用以下脚本将数据添加到 neo4j。数据添加成功,但查询有问题。仅当我给出数据库中节点的确切纬度和经度时,查询才有效。任何其他坐标都会导致空集。
import csv
import requests
import json
headers = {'content-type': 'application/json'}
# Create geom index
url = "http://localhost:7474/db/data/index/node/"
payload= {
"name" : "geom",
"config" : {
"provider" : "spatial",
"geometry_type" : "point",
"lat" : "lat",
"lon" : "lon"
}
}
r = requests.post(url, data=json.dumps(payload), headers=headers, auth=('neo4j', 'thanks123'))
with open('/home/haripriya/workspace/ContentMatching/src/main/resources/coords.csv', 'rb') as f: # read data file
reader = csv.reader(f, delimiter='\t')
for row in reader:
# create airport node
url = "http://localhost:7474/db/data/node"
payload = {'name': row[0], 'street': row[1], 'city': row[2], 'state': row[3], 'pin': row[4], 'lon': float(row[5]), 'lat': float(row[6])}
r = requests.post(url, data=json.dumps(payload), headers=headers, auth=('neo4j', 'thanks123'))
node = r.json()['self']
#add node to geom index
url = "http://localhost:7474/db/data/index/node/geom"
payload = {'value': 'dummy', 'key': 'dummy', 'uri': node}
r = requests.post(url, data=json.dumps(payload), headers=headers, auth=('neo4j', 'thanks123'))
#add node to Spatial index
url = "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addNodeToLayer"
payload = {'layer': 'geom', 'node': node}
r = requests.post(url, data=json.dumps(payload), headers=headers, auth=('neo4j', 'thanks123'))
示例节点:
一个 29.6490287781 -98.4621124268
B 30.2107849121 -95.7507781982
开始 n=node:geom('withinDistance:[29.6490287781, -98.4621124268, 50.0]') RETURN n returns 节点 A 但
开始 n=node:geom('withinDistance:[29.6490287780, -98.4621124260, 50.0]') RETURN n returns 空集
在 Whosebug 上发现了一个类似的问题。答案有所帮助。请在下面找到 link:
Neo4j Spatial return only one node
谢谢!
使用以下脚本将数据添加到 neo4j。数据添加成功,但查询有问题。仅当我给出数据库中节点的确切纬度和经度时,查询才有效。任何其他坐标都会导致空集。
import csv
import requests
import json
headers = {'content-type': 'application/json'}
# Create geom index
url = "http://localhost:7474/db/data/index/node/"
payload= {
"name" : "geom",
"config" : {
"provider" : "spatial",
"geometry_type" : "point",
"lat" : "lat",
"lon" : "lon"
}
}
r = requests.post(url, data=json.dumps(payload), headers=headers, auth=('neo4j', 'thanks123'))
with open('/home/haripriya/workspace/ContentMatching/src/main/resources/coords.csv', 'rb') as f: # read data file
reader = csv.reader(f, delimiter='\t')
for row in reader:
# create airport node
url = "http://localhost:7474/db/data/node"
payload = {'name': row[0], 'street': row[1], 'city': row[2], 'state': row[3], 'pin': row[4], 'lon': float(row[5]), 'lat': float(row[6])}
r = requests.post(url, data=json.dumps(payload), headers=headers, auth=('neo4j', 'thanks123'))
node = r.json()['self']
#add node to geom index
url = "http://localhost:7474/db/data/index/node/geom"
payload = {'value': 'dummy', 'key': 'dummy', 'uri': node}
r = requests.post(url, data=json.dumps(payload), headers=headers, auth=('neo4j', 'thanks123'))
#add node to Spatial index
url = "http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addNodeToLayer"
payload = {'layer': 'geom', 'node': node}
r = requests.post(url, data=json.dumps(payload), headers=headers, auth=('neo4j', 'thanks123'))
示例节点: 一个 29.6490287781 -98.4621124268 B 30.2107849121 -95.7507781982
开始 n=node:geom('withinDistance:[29.6490287781, -98.4621124268, 50.0]') RETURN n returns 节点 A 但
开始 n=node:geom('withinDistance:[29.6490287780, -98.4621124260, 50.0]') RETURN n returns 空集
在 Whosebug 上发现了一个类似的问题。答案有所帮助。请在下面找到 link:
Neo4j Spatial return only one node
谢谢!