【发布时间】:2020-06-25 14:54:04
【问题描述】:
1.我已经下载了一个城市的OSM文件,并通过https://github.com/neo4j-contrib/osm将数据导入Neo4j
2.Followed README,我添加了距离、交点、ROUTE 关系、PointOfInterest。
3.但是ROUTE关系是双向的,不知道这是否是导致路由算法失败的原因。
仅供参考,我的上述步骤脚本
- 计算距离
'MATCH
(awn:OSMWayNode)-[r:NEXT]-(bwn:OSMWayNode)
WHERE NOT exists(r.distance)
RETURN awn,bwn,r',
'MATCH
(awn)-[:NODE]->(a:OSMNode),
(bwn)-[:NODE]->(b:OSMNode)
SET r.distance=round(distance(a.location,b.location))',
{batchSize:10000,parallel:false});
2.判断什么是交集
'MATCH(n:OSMNode)
WHERE size((n)<-[:NODE]-())>2
AND NOT (n:Intersection)
RETURN n',
'MATCH
(n)<-[:NODE]-(wn:OSMWayNode),(wn)<-[:NEXT*]-(wx),
(wx)<-[:FIRST_NODE]-(w:OSMWay)-[:TAGS]->(wt:OSMTags)
WHERE exists(wt.highway)
SET n:Intersection',
{batchSize:10000,parallel:false});
3.用新的距离关系连接决策点(交叉点)
'MATCH(x:Intersection)
CALL spatial.osm.routeIntersection(x,false,false,false)
YIELD fromNode,toNode,distance,fromRel,toRel
RETURN fromNode,toNode,distance,fromRel,toRel',
'MERGE (fromNode)-[r:ROUTE {fromRel:id(fromRel),toRel:id(toRel)}]->(toNode)
ON CREATE SET r.distance=round(distance)',
{batchSize:10000,parallel:false});
4.创建兴趣点,按照我为位置创建另外3个兴趣点的相同方式:{longitude:103.835553,latitude:1.3045739},{longitude:103.78152251,latitude:1.28357103},{longitude:103.8604644,latitude: 1.305788741}
MATCH(n:OSMNode)
WHERE
distance(n.location,point({longitude:103.8958005,latitude:1.330945169})
)<100 AND (n)-[:ROUTE]->() and NOT n:PointOfInterest
WITH n,n.location as poi LIMIT 1
MATCH(m:OSMNode)
WHERE distance(poi,m.location)<100
WITH n,m
MATCH(m)<-[:NODE]-(wn:OSMWayNode),
(wn)<-[:NEXT*]-(wx),
(wx)<-[:FIRST_NODE]-(w:OSMWay)
WITH n,w
WITH n,COLLECT(w) AS ways
CALL spatial.osm.routePointOfInterest(n,ways) YIELD node
SET n:PointOfInterest,n.name="AAA"
RETURN count(node)
问题:
我想使用 gds.alpha.spanningTree.minimum.write 来获得从 AAA 点到所有其他 PointOfInterest 的最小努力,即 BBB、CCC、DDD
CALL gds.alpha.spanningTree.minimum.write({
nodeProjection: 'PointOfInterest',
relationshipProjection: {
ROUTE: {
type: 'ROUTE',
properties: 'distance',
orientation: 'UNDIRECTED'
},
startNodeId: id(n),
relationshipWeightProperty: 'distance',
writeProperty: 'MINST',
weightWriteProperty: 'writeCost'
}
})
YIELD createMillis, computeMillis, writeMillis, effectiveNodeCount
RETURN createMillis, computeMillis, writeMillis, effectiveNodeCount;
但我总是出错
Failed to invoke procedure `gds.alpha.spanningTree.minimum.write`: Caused by: java.lang.IllegalArgumentException: Cannot construct a relationship filter out of a java.lang.Long
是否可以使用上述方式实现我的目的?如果可以,我的密码有什么问题吗?
【问题讨论】:
标签: neo4j openstreetmap