Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nav2_route/graphs/scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
These scripts are used to help automate parts of route graph generation process.
19 changes: 19 additions & 0 deletions nav2_route/graphs/scripts/export_shapefiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import geopandas as gpd
import pandas as pd
import sys
from datetime import datetime

try:
file_prefix = sys.argv[1]
edges = gpd.read_file(sys.argv[2])
nodes = gpd.read_file(sys.argv[3])
except:
raise Exception("Incorrect arguements provided")

now = datetime.now()

graph = pd.concat([nodes, edges])

file_name = file_prefix + "_" + now.strftime("%m_%d_%Y_%H_%M_%S") + ".geojson"

graph.to_file(file_name, driver='GeoJSON')
22 changes: 22 additions & 0 deletions nav2_route/graphs/scripts/generate_start_and_end_id.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
WITH start_points AS
(
SELECT n.id AS node_id
,e.id AS edge_id
,e.geometry AS edge_geometry
FROM edges AS e, nodes AS n
WHERE ST_INTERSECTS(n.geometry, ST_StartPoint(e.geometry))
), end_points AS
(
SELECT n.id AS node_id
,e.id AS edge_id
,e.geometry AS edge_geometry
FROM edges AS e, nodes AS n
WHERE ST_INTERSECTS(n.geometry, ST_EndPoint(e.geometry))
)
SELECT sp.edge_id AS edge_id
,sp.node_id AS start_node
,ep.node_id AS end_node
,sp.edge_geometry AS geometry
FROM start_points AS sp
JOIN end_points AS ep
ON sp.edge_id = ep.edge_id
21 changes: 21 additions & 0 deletions nav2_route/graphs/scripts/increment_edge_id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"author": "josh",
"exported_at": "2023-03-15T19:27:03",
"expressions": [
{
"description": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n<html><head><style type=\"text/css\">\np, li { white-space: pre-wrap; }\n</style></head><body style=\" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;\">\n<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>",
"expression": "if(maximum(\"id\") is null, 10000, maximum(\"id\")+1)",
"group": "user",
"name": "increment_edge_id",
"type": "expression"
},
{
"description": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n<html><head><style type=\"text/css\">\np, li { white-space: pre-wrap; }\n</style></head><body style=\" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;\">\n<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>",
"expression": "if(maximum(\"id\") is null, 0, maximum(\"id\")+1)",
"group": "user",
"name": "increment_node_id",
"type": "expression"
}
],
"qgis_version": "3.22.4-Białowieża"
}
14 changes: 14 additions & 0 deletions nav2_route/graphs/scripts/increment_node_id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"author": "josh",
"exported_at": "2023-03-15T19:22:14",
"expressions": [
{
"description": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n<html><head><style type=\"text/css\">\np, li { white-space: pre-wrap; }\n</style></head><body style=\" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;\">\n<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>",
"expression": "if(maximum(\"id\") is null, 0, maximum(\"id\")+1)",
"group": "user",
"name": "increment_node_id",
"type": "expression"
}
],
"qgis_version": "3.22.4-Białowieża"
}