On Fri, 13 Oct 2017 13:01:19 +0300, Jukka Rahkonen wrote:
> Hi,
>
> I wonder if it would be better to rename ST_ForceLHR into
> ST_ForcePolygonCW or something because the right-hand and left-hand
> rules are ambiguous.
>
> In
https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html is is
> defined as
> "Any Polygon Ring will be oriented accordingly to Left Hand Rule
> (Exterior Ring will be clockwise oriented, and Interior Rings will be
> counter-clockwise oriented)."
>
> In PostGIS the same thing is called as Right Hand Rule
>
http://postgis.net/docs/ST_ForceRHR.html
> "Forces the orientation of the vertices in a polygon to follow a
> Right-Hand-Rule, in which the area that is bounded by the polygon is
> to the right of the boundary. In particular, the exterior ring is
> orientated in a clockwise direction and the interior rings in a
> counter-clockwise direction. This function is a synonym for
> ST_ForcePolygonCW"
>
Hi Jukka,
just to add more confusion PostGIS itself supports ST_ForceLHR(),
but only when using the SFCGAL backend:
https://postgis.net/docs/ST_ForceLHR.html
(I was unable to understand what this exactly means because the
HTML page is really vague and elusive).
as you stated, the conventional interpretation of left- and
right-hand rules are highly ambiguous, inconsistent and
contradictory between different implementations.
suppressing a well established function name never is a good
policy, because this way many existing SQL scripts could suddenly
stop working.
SQL scripts are usually deployed by big organizations on remote
servers, and are usually executed at fixed time intervals under
"cron" planning in a completely automatic and unattended mode:
so any traumatic breakage should be always carefully avoided.
I suppose that we could reasonably adopt the following corrections:
1. leave ST_ForceLHR() untouched, so not to break backward
compatibility.
2. add a new ST_ForceRHR() working the opposite way.
3. add ST_ForcePolygonCW() as an alias name to ST_ForceLHR()
4. add ST_ForcePolygonCCW() as an alias name to ST_ForceRHR()
5. clearly stating in the accompanying documentation that
ST_ForceLHR() and ST_ForceRHR() in SpatiaLite have the
opposite interpretation than in PostGIS, whilst
ST_ForcePolygonCW() and ST_ForcePolygonCCW() have
exactly the same interpretation in both DBMS.
bye Sandro