Skip to content

Commit

Permalink
Replace --keep-geometry flag with a more general --save-all flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Grufoony committed Feb 12, 2025
1 parent 7d64c79 commit 13d1a68
Showing 1 changed file with 12 additions and 28 deletions.
40 changes: 12 additions & 28 deletions utils/get_osm_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"""

from argparse import ArgumentParser
from pathlib import Path
import ast
import logging
from pathlib import Path
import osmnx as ox

__version__ = "2025.2.11"
__version__ = "2025.2.12"

RGBA_RED = (1, 0, 0, 1)
RGBA_WHITE = (1, 1, 1, 1)
Expand Down Expand Up @@ -73,10 +73,14 @@
"--tolerance",
type=int,
default=20,
help="Radius in meters to merge intersections. For more info, see osmnx documentation.",
help="Radius in meters given to consolidate intersections function."
" For more info, see osmnx documentation.",
)
parser.add_argument(
"--use-original-ids", action="store_true", help="Use the original ids from OSM."
"--use-original-ids",
action="store_true",
help="Use the original ids from OSM. If the original ids are lists,"
" keep the first element. Default is False.",
)
parser.add_argument(
"-of",
Expand All @@ -92,9 +96,9 @@
help="Consolidate intersections. Default is False",
)
parser.add_argument(
"--keep-geometry",
"--save-all",
action="store_true",
help="Keep the GEOMETRY column in aoutput csv.",
help="Save all the column for both nodes' and edges' csv.",
)
parser = parser.parse_args()
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
Expand Down Expand Up @@ -183,7 +187,7 @@
)
# update the node with new_id
gdf_nodes.loc[index, "osmid_original"] = new_id
if not parser.keep_geometry:
if not parser.save_all:
gdf_nodes = gdf_nodes[["osmid_original", "x", "y", "highway"]]
gdf_edges = gdf_edges[
[
Expand All @@ -196,35 +200,15 @@
"name",
]
]
else:
gdf_nodes = gdf_nodes[["osmid_original", "x", "y", "highway", "geometry"]]
gdf_edges = gdf_edges[
[
"u_original",
"v_original",
"length",
"lanes",
"highway",
"maxspeed",
"name",
"geometry",
]
]

else:
if not "lanes" in gdf_edges.columns:
gdf_edges["lanes"] = 1
if not parser.keep_geometry:
if not parser.save_all:
gdf_nodes = gdf_nodes[["osmid", "x", "y", "highway"]]
gdf_edges = gdf_edges[
["u", "v", "length", "lanes", "highway", "maxspeed", "name"]
]
else:
gdf_nodes = gdf_nodes[["osmid", "x", "y", "highway", "geometry"]]
gdf_edges = gdf_edges[
["u", "v", "length", "lanes", "highway", "maxspeed", "name", "geometry"]
]

if parser.allow_duplicates:
N_DUPLICATES = 0
else:
Expand Down

0 comments on commit 13d1a68

Please sign in to comment.