[postgis-devel] RFC - Orientation checking and forcing functions
Daniel Baston
dbaston at gmail.com
Tue Feb 7 16:55:27 PST 2017
Hi All,
I put together a pull request a couple of weeks ago that introduces four
functions for checking and forcing geometry orientation. The intent is to
provide a less-ambiguous alternative to ST_ForceRHR, and an alternative to
ST_Orientation that does not depend on SFCGAL. Strk asked that I bring
this up on the devel list for a review of the semantics.
The four proposed functions are.
ST_ForceCW
ST_ForceCCW
ST_IsCW
ST_IsCCW
The semantics are straightforward, in my opinion:
1. ST_ForceCW is a synonym for ST_ForceRHR, which gives all exterior rings
a clockwise orientation and all interior rings a counterclockwise
orientation. Non-polygonal geometries, including closed LineStrings, are
simply passed through.
2. ST_ForceCCW is simply a shorthand for ST_Reverse(ST_ForceCW)
3. ST_IsCW returns true if a geometry would not be modified by
ST_ForceCW. It is essentially a synonym for ST_OrderingEquals(geom,
ST_ForceCW(geom)).
4. ST_IsCCW returns true if a geometry would not be modified by
ST_ForceCCW.
A few notes:
ST_IsCW and ST_IsCCW both return false if a polygon has invalid ring
orientation (i.e., exterior and interior rings are all clockwise)
ST_IsCW and ST_IsCCW both return true for geometries that have no non-empty
polygonal components.
Relevant links:
PR: https://github.com/postgis/postgis/pull/122
Trac: https://trac.osgeo.org/postgis/ticket/3689,
https://trac.osgeo.org/postgis/ticket/3651
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20170207/752adcab/attachment.html>
More information about the postgis-devel
mailing list