geometry
calculate_distance(x1, y1, x2, y2)
Calculate the distance between two points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x1
|
float
|
The x-coordinate of the first point. |
required |
y1
|
float
|
The y-coordinate of the first point. |
required |
x2
|
float
|
The x-coordinate of the second point. |
required |
y2
|
float
|
The y-coordinate of the second point. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The distance between the two points. |
Source code in src/layerforge/utils/geometry.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
polygon_parts(geometry)
Return every polygon with positive area inside geometry, however deeply nested.
shapely.get_parts descends only one level, so a GeometryCollection holding a
MultiPolygon -- a real output of shapely.make_valid on some self-intersecting
polygons, alongside the leftover line of the self-intersection -- would otherwise hide
that MultiPolygon's own pieces behind a type that fails an isinstance(part, Polygon)
check. This walks every level and keeps only what has area.
Source code in src/layerforge/utils/geometry.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |