Coverage for pyguymer3/geo/fillinSrc/fillin_MultiLineString.py: 6%
18 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-08 18:47 +0000
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-08 18:47 +0000
1#!/usr/bin/env python3
3# Define function ...
4def fillin_MultiLineString(
5 multiline,
6 fill,
7 /,
8 *,
9 debug = __debug__,
10 eps = 1.0e-12,
11 fillSpace = "EuclideanSpace",
12 nIter = 100,
13 prefix = ".",
14 ramLimit = 1073741824,
15):
16 """Fill in a MultiLineString
18 This function reads in a MultiLineString that exists on the surface of the
19 Earth and returns a MultiLineString of the same MultiLineString filled in by
20 a constant distance: either in degrees in Euclidean space; or in metres in
21 Geodesic space.
23 Parameters
24 ----------
25 line : shapely.geometry.multilinestring.MultiLineString
26 the MultiLineString
27 fill : float
28 the Euclidean or Geodesic distance to fill in between each point within
29 the shape by (in degrees or metres)
30 debug : bool, optional
31 print debug messages
32 eps : float, optional
33 the tolerance of the Vincenty formula iterations
34 fillSpace : str, optional
35 the geometric space to perform the filling in (either "EuclideanSpace"
36 or "GeodesicSpace")
37 nIter : int, optional
38 the maximum number of iterations (particularly the Vincenty formula)
39 prefix : str, optional
40 change the name of the output debugging CSVs
41 ramLimit : int, optional
42 the maximum RAM usage of each "large" array (in bytes)
44 Returns
45 -------
46 fills : shapely.geometry.multilinestring.MultiLineString
47 the filled in MultiLineString
49 Notes
50 -----
51 Copyright 2017 Thomas Guymer [1]_
53 References
54 ----------
55 .. [1] PyGuymer3, https://github.com/Guymer/PyGuymer3
56 """
58 # Import special modules ...
59 try:
60 import shapely
61 import shapely.geometry
62 except:
63 raise Exception("\"shapely\" is not installed; run \"pip install --user Shapely\"") from None
65 # Import sub-functions ...
66 from ..check import check
67 from .fillin_LineString import fillin_LineString
69 # **************************************************************************
71 # Check argument ...
72 assert isinstance(multiline, shapely.geometry.multilinestring.MultiLineString), "\"multiline\" is not a MultiLineString"
73 if debug:
74 check(multiline, prefix = prefix)
76 # Initialize list ...
77 lines = []
79 # Loop over LineStrings ...
80 for line in multiline.geoms:
81 # Append filled in LineString to list ...
82 lines.append(
83 fillin_LineString(
84 line,
85 fill,
86 debug = debug,
87 eps = eps,
88 fillSpace = fillSpace,
89 nIter = nIter,
90 prefix = prefix,
91 ramLimit = ramLimit,
92 )
93 )
95 # Convert list of LineStrings to a MultiLineString ...
96 fills = shapely.geometry.multilinestring.MultiLineString(lines)
97 if debug:
98 check(fills, prefix = prefix)
100 # Return answer ...
101 return fills