Skip to content

Commit

Permalink
docs: explain why having to orient()
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfouquet committed Feb 23, 2025
1 parent 06e6226 commit 801e488
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scripts/stac/imagery/capture_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ def merge_polygons(polygons: Sequence[BaseGeometry], buffer_distance: float) ->
union_unbuffered = union_buffered.buffer(-buffer_distance, cap_style=BufferCapStyle.flat, join_style=BufferJoinStyle.mitre)
union_simplified = union_unbuffered.simplify(buffer_distance)
union_rounded = wkt.loads(wkt.dumps(union_simplified, rounding_precision=8))
# Normalize the geometry in order to have consistent geometry
# when existing geometry is being modified but not "changed".
# Apply right-hand rule winding order (exterior rings should be counter-clockwise) to the geometry
# Normalize the geometry in order to store consistent geometry.
# Shapely.normalize() reorders the exterior ring based on the lexicographically smallest point (lowest (x, y)),
# but this reordering may still keep it CW in some cases.
# Because of the above, we need to apply right-hand rule winding order
# (exterior rings should be counter-clockwise) to the geometry
# Ref: https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6
oriented_union_simplified = orient(union_rounded.normalize(), sign=1.0)

Expand Down

0 comments on commit 801e488

Please sign in to comment.