Skip to content

Commit

Permalink
handling curved / crossing geoms
Browse files Browse the repository at this point in the history
  • Loading branch information
songololo committed Nov 12, 2024
1 parent f720677 commit 357a570
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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.16.0b8'
version = '4.16.0b9'
description = "Computational tools for network-based pedestrian-scale urban analysis"
readme = "README.md"
requires-python = ">=3.10, <3.14"
Expand Down
12 changes: 6 additions & 6 deletions pysrc/cityseer/tools/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@

import networkx as nx
import numpy as np
from shapely import BufferCapStyle, geometry, ops
from tqdm import tqdm

from cityseer import config
from cityseer.tools import util
from cityseer.tools.util import EdgeData, ListCoordsType, MultiGraph, NodeData, NodeKey
from shapely import BufferCapStyle, geometry, ops
from tqdm import tqdm

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -1247,7 +1246,7 @@ def recurse_child_keys(
shared_nodes.add(end_nd_key)
distinct_edges.append((start_nd_key, end_nd_key, edge_idx, edge_data))
# iter gapped edges
for start_nd_key, end_nd_key, edge_idx, edge_data in gapped_edges:
for start_nd_key, end_nd_key, edge_idx, edge_data in distinct_edges:
edge_geom = edge_data["geom"]
# hwy tags
if osm_hwy_target_tags:
Expand Down Expand Up @@ -1392,15 +1391,16 @@ def recurse_child_keys(
template = template.union(new_geom.buffer(10, cap_style=BufferCapStyle.flat))
# don't add new edges that would criss cross existing
bail = False
new_end_pnt = geometry.Point(origin_nd_data["x"], origin_nd_data["y"])
new_end_pnt = geometry.Point(new_nd_data["x"], new_nd_data["y"])
edge_hits = edges_tree.query(new_geom) # type: ignore
for edge_hit_idx in edge_hits:
edge_lookup = edge_lookups[edge_hit_idx]
start_nd_key = edge_lookup["start_nd_key"]
end_nd_key = edge_lookup["end_nd_key"]
edge_idx = edge_lookup["edge_idx"]
edge_geom: dict = nx_multigraph[start_nd_key][end_nd_key][edge_idx]["geom"]
if round(new_end_pnt.distance(edge_geom), 3) > 0: # type: ignore
# use distance to catch "crossing" where curved geoms lead to issues
if new_geom.crosses(edge_geom) and round(new_end_pnt.distance(edge_geom), 3) > 0: # type: ignore
bail = True
break
if bail:
Expand Down

0 comments on commit 357a570

Please sign in to comment.