-
-
Save davidstrategicaci/91082a00ef32ad8dd372331cc8ce4a0e to your computer and use it in GitHub Desktop.
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
sampleGraphQuery = """ | |
-- Forwards, from start to end | |
SELECT start_node as node1, end_node as node2, split_way_id, | |
CASE | |
WHEN json_extract(tags, '$.oneway') == '-1' THEN 10000000000.0 | |
ELSE length_m | |
END as cost | |
FROM osm_network_graph | |
WHERE start_node = 49370759 AND end_node = 49170395 | |
UNION | |
-- Backwards, from end to start | |
SELECT end_node as node1, start_node as node2, split_way_id, | |
CASE | |
WHEN json_extract(tags, '$.oneway') == 'yes' THEN 10000000000.0 | |
ELSE length_m | |
END as cost | |
FROM osm_network_graph | |
WHERE end_node = 49170395 or start_node = 49370759; | |
""" | |
cursor.execute(sampleGraphQuery) | |
costTable = tabulate(tabular_data=[list(value) for value in cursor.fetchall()],headers=['From','To','Way','Cost'],tablefmt='html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment