itacart.geometry.densify_segment
- itacart.geometry.densify_segment(p1, p2, max_segment_m, edge_model='WGS84_GEODESIC')[source]
Densify a single segment.
The building block of
densify_orthodromic(), exposed for callers working segment by segment such as open LINESTRING handling.The span is measured with the Vincenty inverse and the intermediate points are placed with the Vincenty direct along the forward azimuth, equally spaced in geodesic arc length. Nothing is measured on the plane, because the projection preserves area and not direction.
n_segments = floor(d / max_segment_m) + 1, so every resulting leg is strictly shorter than the threshold whenever any subdivision happens at all. That is what makes the operation idempotent: a second pass measures each leg, finds it under the threshold, and leaves it.Each interior point is put on the branch of the endpoint nearer to it in arc length, the start for the first half and the destination for the second. On an ordinary segment the two references sit less than half a turn apart and agree, so the rule changes nothing. On a segment spanning exactly half a turn of longitude they do not agree, because such a segment is meridional: its geodesic passes through a pole and its longitude jumps a hundred and eighty degrees there. Referring the far half to the start would let it land on the opposite branch from the vertex it is walking towards, which folds the ring across the globe and leaves the projection with a self-intersection the caller cannot read. The midpoint itself, which is the pole when the segment is symmetric about it, is referred to the start; its longitude is immaterial because the parallels plane collapses every meridian at the pole onto one point.
Provenance:
itacart_core/geometry_blob.py(densify_segment).- Parameters:
- Return type:
- Returns:
(lon, lat)pairs including both endpoints.- Raises:
DensificationError – If the threshold is not positive and finite, or the edge model is unknown.