@@ -2703,19 +2703,19 @@ def check_geometry_overlaps(
27032703
27042704
27052705def compound_dilation (geoms : list [Geometry ], offset : float ) -> CompoundGeometry :
2706- """
2707- Returns a CompoundGeometry representing the input Geometries, dilated
2706+ """Returns a CompoundGeometry representing the input Geometries, dilated.
27082707
27092708 Args:
2710- geoms: List of Geometry
2711- offset: a positive float or int
2709+ geoms: List of Geometry objects
2710+ offset: A positive `` float`` or `` int``
27122711
27132712 Returns:
2714- The geometries dilated by ' offset'
2713+ The geometries dilated by `` offset``
27152714 """
27162715 polys = [geom .geom for geom in geoms ]
27172716 geom_network = build_geometry_network (polys )
27182717 acc = []
2718+
27192719 for poly_idx , connectivity in geom_network .items ():
27202720 poly_orig = polys [poly_idx ]
27212721 poly_orig_exterior = poly_orig .exterior
@@ -2726,11 +2726,9 @@ def compound_dilation(geoms: list[Geometry], offset: float) -> CompoundGeometry:
27262726 )
27272727 source = line_merge (poly_orig_exterior - shared_path_geometries )
27282728 buff = source .buffer (offset , cap_style = "flat" )
2729- new = Geometry (
2730- poly_orig | buff ,
2731- material = geoms [poly_idx ].material ,
2732- )
2729+ new = Geometry (poly_orig | buff , material = geoms [poly_idx ].material )
27332730 acc .append (new )
2731+
27342732 return CompoundGeometry (acc )
27352733
27362734
@@ -2781,11 +2779,11 @@ def walk_network(
27812779
27822780
27832781def build_geometry_network (lop : list [Polygon ]) -> dict [int , set [int ]]:
2784- """
2785- Returns a graph describing the connectivity of each polygon to each
2786- other polygon in 'lop'. The keys are the indexes of the polygons in
2787- ' lop' and the values are a set of indexes that the key is connected
2788- to.
2782+ """Builds a geometry connectivity graph.
2783+
2784+ Returns a graph describing the connectivity of each polygon to each other polygon in
2785+ `` lop``. The keys are the indexes of the polygons in ``lop`` and the values are a
2786+ set of indexes that the key is connected to.
27892787
27902788 Args:
27912789 lop: List of Polygon
@@ -2794,24 +2792,39 @@ def build_geometry_network(lop: list[Polygon]) -> dict[int, set[int]]:
27942792 A dictionary describing the connectivity graph of the polygons
27952793 """
27962794 network : dict [int , set [int ]] = {}
2795+
27972796 for idx_i , poly1 in enumerate (lop ):
27982797 for idx_j , poly2 in enumerate (lop ):
27992798 if idx_i != idx_j :
28002799 connectivity = network .get (idx_i , set ())
2800+
28012801 if poly1 .intersection (poly2 ):
28022802 connectivity .add (idx_j )
2803+
28032804 network [idx_i ] = connectivity
2805+
28042806 return network
28052807
28062808
28072809def extract_shared_paths (
28082810 arr_of_geom_coll : npt .ArrayLike ,
28092811) -> list [LineString ]:
2812+ """Extracts a list of LineStrings exported by the shapely ``shared_paths`` method.
2813+
2814+ Args:
2815+ arr_of_geom_coll: An array of geometry collections
2816+
2817+ Returns:
2818+ List of LineStrings.
2819+ """
28102820 acc = []
2821+
28112822 for geom_col in arr_of_geom_coll :
28122823 for mls in geom_col .geoms :
28132824 if mls .is_empty :
28142825 continue
2826+
28152827 ls = line_merge (mls )
28162828 acc .append (ls )
2829+
28172830 return acc
0 commit comments