Skip to content

Commit 2cf64fb

Browse files
authored
docstring & typehints in simplify.simplify_loop(), etc. (#112)
* update pre-commit * doctring for simply.simplfy_loop()
1 parent 63bb65d commit 2cf64fb

File tree

2 files changed

+53
-21
lines changed

2 files changed

+53
-21
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
files: "sgeop\/"
22
repos:
33
- repo: https://github.com/astral-sh/ruff-pre-commit
4-
rev: "v0.6.9"
4+
rev: "v0.8.0"
55
hooks:
66
- id: ruff
77
- id: ruff-format

sgeop/simplify.py

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,15 @@ def simplify_network(
489489
) -> gpd.GeoDataFrame:
490490
"""Top-level workflow for simplifying networks. The input raw road network data is
491491
first preprocessed (topological corrections & node consolidation) before two
492-
iterations of artifact detection and simplification. For further information on
493-
face artifact detection and extraction see :cite:`fleischmann2023`.
492+
iterations of artifact detection and simplification.
493+
494+
Each iteration of the simplification procedure which includes (1.) the removal
495+
of false nodes; (2.) face artifact classification; and (3.) the line-based
496+
simplification of face artifacts in the order of single artifacts, pairs of
497+
artifacts, clusters of artifacts.
498+
499+
For further information on face artifact detection and extraction
500+
see :cite:`fleischmann2023`.
494501
495502
Parameters
496503
----------
@@ -616,30 +623,55 @@ def simplify_network(
616623

617624

618625
def simplify_loop(
619-
roads,
620-
artifacts,
621-
max_segment_length=1,
622-
min_dangle_length=20,
623-
clip_limit: int = 2,
624-
simplification_factor=2,
625-
consolidation_tolerance=10,
626-
eps=1e-4,
627-
):
628-
"""
626+
roads: gpd.GeoDataFrame,
627+
artifacts: gpd.GeoDataFrame,
628+
max_segment_length: float | int = 1,
629+
min_dangle_length: float | int = 20,
630+
clip_limit: float | int = 2,
631+
simplification_factor: float | int = 2,
632+
consolidation_tolerance: float | int = 10,
633+
eps: float = 1e-4,
634+
) -> gpd.GeoDataFrame:
635+
"""Perform an iteration of the simplification procedure which includes:
636+
1. Removal of false nodes
637+
2. Artifact classification
638+
3. Simplifying artifacts:
639+
- Single artifacts
640+
- Pairs of artifacts
641+
- Clusters of artifacts
629642
630643
Parameters
631644
----------
632-
633-
clip_limit : int = 2
634-
Following generation of the Voronoi linework in ``geometry.voronoi_skeleton()``,
635-
we clip to fit inside the polygon. To ensure we get a space to make proper
636-
topological connections from the linework to the actual points on the edge of
637-
the polygon, we clip using a polygon with a negative buffer of ``clip_limit``
638-
or the radius of maximum inscribed circle, whichever is smaller.
645+
roads : geopandas.GeoDataFrame
646+
Raw road network data.
647+
artifacts : geopandas.GeoDataFrame
648+
Face artifact polygons.
649+
max_segment_length : float | int = 1
650+
Additional vertices will be added so that all line segments
651+
are no longer than this value. Must be greater than 0.
652+
Used in multiple internal geometric operations.
653+
min_dangle_length : float | int
654+
The threshold for determining if linestrings are dangling slivers to be
655+
removed or not.
656+
clip_limit : float | int = 2
657+
Following generation of the Voronoi linework, we clip to fit inside the
658+
polygon. To ensure we get a space to make proper topological connections
659+
from the linework to the actual points on the edge of the polygon, we clip
660+
using a polygon with a negative buffer of ``clip_limit`` or the radius of
661+
maximum inscribed circle, whichever is smaller.
662+
simplification_factor : float | int = 2
663+
The factor by which singles, pairs, and clusters are simplified. The
664+
``max_segment_length`` is multiplied by this factor to get the
665+
simplification epsilon.
666+
consolidation_tolerance : float | int = 10
667+
Tolerance passed to node consolidation when generating Voronoi skeletons.
668+
eps : float = 1e-4
669+
Tolerance epsilon used in multiple internal geometric operations.
639670
640671
Returns
641672
-------
642-
673+
geopandas.GeoDataFrame
674+
The road network line data following 1 iteration of simplification.
643675
"""
644676

645677
# Remove edges fully within the artifact (dangles).

0 commit comments

Comments
 (0)