Skip to content

Commit

Permalink
bumps osmnx to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
songololo committed Nov 25, 2024
1 parent 1dd6c34 commit b932c3c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cityseer"
version = '4.16.1'
version = '4.16.2'
description = "Computational tools for network-based pedestrian-scale urban analysis"
readme = "README.md"
requires-python = ">=3.10, <3.14"
Expand Down Expand Up @@ -49,7 +49,7 @@ dependencies = [
"rasterio>=1.3.9",
"pyarrow>=16.0.0",
"fiona>=1.9.6",
"osmnx>=1.9.3",
"osmnx>=2.0.0",
]

[project.urls]
Expand Down
6 changes: 4 additions & 2 deletions pysrc/cityseer/tools/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ def nx_iron_edges(
edges_tree, edge_lookups = util.create_edges_strtree(g_multi_copy)
start_nd_key: NodeKey
end_nd_key: NodeKey
remove_edges = []
for start_nd_key, end_nd_key, edge_idx, edge_data in tqdm(
g_multi_copy.edges(keys=True, data=True), disable=config.QUIET_MODE
):
Expand All @@ -546,11 +547,12 @@ def nx_iron_edges(
continue
edge_geom: geometry.LineString = edge_data["geom"]
hits = edges_tree.query(edge_geom, predicate="crosses")
if hits.size > 0:
g_multi_copy.remove_edge(start_nd_key, end_nd_key, edge_idx)
if len(hits):
remove_edges.append((start_nd_key, end_nd_key, edge_idx))
continue
line_coords = simplify_line_by_angle(edge_geom.coords, 100)
g_multi_copy[start_nd_key][end_nd_key][edge_idx]["geom"] = geometry.LineString(line_coords)
g_multi_copy.remove_edges_from(remove_edges)
# straightening parallel edges can create duplicates
g_multi_copy = nx_merge_parallel_edges(g_multi_copy, False, 1)

Expand Down
8 changes: 4 additions & 4 deletions pysrc/cityseer/tools/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ def _extract_gdf(gdf):
# extract ways and convert to polys
# not interested in segments - which are captured separately from network query
# but do want squares etc. described as ways - hence buffer and reverse buffer
if "element_type" in gdf.index.names and "way" in gdf.index.get_level_values("element_type"):
ways_gdf = gdf.xs("way", level="element_type", drop_level=True)
if "element" in gdf.index.names and "way" in gdf.index.get_level_values("element"):
ways_gdf = gdf.xs("way", level="element", drop_level=True)
ways_gdf = ways_gdf.explode(index_parts=False).reset_index(drop=True)
ways_gdf = ways_gdf[ways_gdf.geometry.type == "Polygon"]
else:
ways_gdf = gpd.GeoDataFrame(columns=gdf.columns, crs=gdf.crs) # type: ignore
# extract relations
if "element_type" in gdf.index.names and "relation" in gdf.index.get_level_values("element_type"):
relations_gdf = gdf.xs("relation", level="element_type", drop_level=True)
if "f" in gdf.index.names and "relation" in gdf.index.get_level_values("element"):
relations_gdf = gdf.xs("relation", level="element", drop_level=True)
relations_gdf = relations_gdf.explode(index_parts=False).reset_index(drop=True)
relations_gdf = relations_gdf[relations_gdf.geometry.type == "Polygon"]
else:
Expand Down

0 comments on commit b932c3c

Please sign in to comment.