Point order in polygons - ObjectVision/GeoDMS GitHub Wiki
For some functions (like union_polygon) the sequence order of points in a polygon matters.
rules
The following rules apply to the sequence of points in a polygon:
- outer rings need to be configured clock wise
- inner rings (lakes) are configured counter clock wise
- the first and the last point need to have the same coordinate
If the sequence of points is configured manually and used in the sequence2points, always configure the correct sequence, although for the map and functions like point_in_polygon an incorrect sequence might not matter.
multi-polygons
A multi-polygon lives in the same single point sequence. Each ring is written closed, one after the other, and the reader recognises a new ring when a point repeats the ring's own first point. After the rings of a polygon, the sequence walks back to where it came from with backtrack points, so that the whole sequence starts and ends at the very first point:
outer(closed) hole0(closed) hole1(closed) hole0[0] outer[0] // one polygon with two holes
A(closed) B(closed) C(closed) B[0] A[0] // three separate polygons
Which polygon a hole belongs to follows from this order: an inner ring belongs to the outer ring that precedes it, not to the multi-polygon as a whole. That distinction matters whenever a polygon is nested inside another polygon's hole — a shed on a courtyard enclosed by a building block, for instance.
validation
A way to test if the correct sequence is configured is by requesting the area of the polygon with the area function. A positive value indicates a correct sequence, a negative value indicates the points are configured in the incorrect sequence.