Skip to content

Commit

Permalink
updates auto clean defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
songololo committed Nov 30, 2024
1 parent 787600a commit cc54180
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Binary file modified docs/public/images/graph_clean.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cityseer"
version = '4.17.0'
version = '4.17.1'
description = "Computational tools for network-based pedestrian-scale urban analysis"
readme = "README.md"
requires-python = ">=3.10, <3.14"
Expand Down
10 changes: 5 additions & 5 deletions pysrc/cityseer/tools/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def nx_iron_edges(
nx_multigraph: MultiGraph,
simplify_by_max_angle: int = 120,
min_self_loop_length: int = 100,
max_foot_tunnel_length: int = 50,
max_foot_tunnel_length: int = 100,
) -> MultiGraph:
"""
Simplifies edges.
Expand All @@ -577,7 +577,7 @@ def nx_iron_edges(
min_self_loop_length: int
Maximum self loop length to permit for a given edge.
max_foot_tunnel_length: int
Maximum tunnel length to permit for non motorised edges.
Maximum tunnel length to permit for non motorised edges. Default of 100m.
Returns
-------
Expand Down Expand Up @@ -646,15 +646,15 @@ def nx_iron_edges(
"tertiary",
"tertiary_link",
"residential",
"living_street",
# "living_street", # intentional - e.g. barcelona
# "service", # intentional
]
)


def nx_deduplicate_edges(
nx_multigraph: MultiGraph,
dissolve_distance: int = 12,
dissolve_distance: int = 20,
max_ang_diff: int = 20,
) -> MultiGraph:
"""
Expand All @@ -670,7 +670,7 @@ def nx_deduplicate_edges(
A `networkX` `MultiGraph` in a projected coordinate system, containing `x` and `y` node attributes, and `geom`
edge attributes containing `LineString` geoms.
dissolve_distance: int
A distance to use when searching for adjacent edges. 12m by default.
A distance to use when searching for adjacent edges. 20m by default.
max_ang_diff: int
Only count a nearby adjacent edge as duplicitous if the angular difference between edges is less than
`max_ang_diff`. 20 degrees by default.
Expand Down
7 changes: 5 additions & 2 deletions pysrc/cityseer/tools/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def _auto_clean_network(
green_service_roads: bool = False,
) -> nx.MultiGraph:
# deduplicate by hierarchy
G = graphs.nx_deduplicate_edges(G)
G = graphs.nx_deduplicate_edges(G, dissolve_distance=20, max_ang_diff=20)
# parks
parks_gdf = ox.features_from_polygon(
geom_wgs,
Expand Down Expand Up @@ -295,6 +295,7 @@ def _auto_clean_network(
for start_node_key, end_node_key, edge_key, edge_data in tqdm( # type: ignore
G.edges(keys=True, data=True), # type: ignore
total=G.number_of_edges(),
disable=config.QUIET_MODE,
):
edge_geom = edge_data["geom"]
if "footway" in edge_data["highways"]:
Expand Down Expand Up @@ -475,7 +476,7 @@ def _auto_clean_network(
)
G = graphs.nx_remove_filler_nodes(G)
G = graphs.nx_merge_parallel_edges(G, merge_edges_by_midline=True, contains_buffer_dist=50)
G = graphs.nx_iron_edges(G, min_self_loop_length=100, max_foot_tunnel_length=50)
G = graphs.nx_iron_edges(G, min_self_loop_length=100, max_foot_tunnel_length=100)
# do this last to clean up any orphaned sub components
G = graphs.nx_remove_dangling_nodes(G, despine=25)

Expand Down Expand Up @@ -708,6 +709,8 @@ def get_merged_nd_keys(_idx: int) -> tuple[str, str]:
levels = tags["level"].split(":")
elif ";" in tags["level"]:
levels = tags["level"].split(";")
elif "," in tags["level"]:
levels = tags["level"].split(",")
else:
levels = [tags["level"]]
levels = [int(round(float(level))) for level in levels]
Expand Down

0 comments on commit cc54180

Please sign in to comment.