Last active
December 9, 2018 20:54
-
-
Save michael-simons/c48f6eb0a5fcd1de5b1e9e0c331d3ec2 to your computer and use it in GitHub Desktop.
Fietsen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH 2407988 as parentRel | |
MATCH (p:Network {externalId: parentRel}) | |
WITH p | |
CALL apoc.load.xml("https://api.openstreetmap.org/api/0.6/relation/" + p.externalId + "/full") YIELD value AS v | |
WITH p, [c IN v._children WHERE c._type = 'relation' AND ANY (t IN c._children WHERE t._type = 'tag' and t.k = 'network' and t.v = 'rcn')] as relations | |
SET p.name = [r IN relations WHERE r.id = toString(p.externalId) | [t IN r._children WHERE t._type = 'tag' and t.k = 'name' | t.v][0] ][0] | |
WITH p, relations | |
UNWIND relations AS relation | |
WITH p, [t IN relation._children WHERE t._type = 'tag' and t.k ='note' and t.v =~ "\\d+-\\d+"] as connection | |
WHERE size(connection) = 1 | |
WITH p, apoc.text.regexGroups(connection[0].v, "(\\d+)-(\\d+)") as names | |
MATCH (s:Node {name: names[0][1]}) - [:BELONGS_TO] -> (p) | |
MATCH (e:Node {name: names[0][2]}) - [:BELONGS_TO] -> (p) | |
MERGE (s) -[r:NEXT {distance: distance(s.location, e.location)}] ->(e) | |
return s, r, e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH 2407988 as relationId | |
CREATE (p:Network {externalId: relationId}) | |
WITH p | |
CALL apoc.load.xml("https://api.openstreetmap.org/api/0.6/relation/" + p.externalId + "/full") YIELD value AS v | |
WITH p, v, [c IN v._children WHERE c._type = 'node' AND SINGLE (t IN c._children WHERE t._type = 'tag' and t.k = 'rcn_ref')] as nodes | |
UNWIND nodes AS node | |
WITH p, node, [t IN node._children WHERE t.k = 'rcn_ref' | t.v][0] as name | |
MERGE (n:Node {name: name}) - [b:BELONGS_TO] -> (p) | |
SET n.externalId = toString(node.id), | |
n.location = point({longitude: toFloat(node.lon), latitude: toFloat(node.lat)}) | |
RETURN n, b, p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MATCH (start:Node{name:'75'}), (end:Node{name:'83'}) | |
CALL algo.shortestPath.stream(start, end, 'distance', {nodeQuery:'Node'}) | |
YIELD nodeId, cost | |
RETURN algo.getNodeById(nodeId).name AS name, cost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment