<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>+1 <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='margin-left:.5in'><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'> postgis-devel [mailto:postgis-devel-bounces@lists.osgeo.org] <b>On Behalf Of </b>Paul Ramsey<br><b>Sent:</b> Tuesday, February 07, 2017 9:02 PM<br><b>To:</b> PostGIS Development Discussion <postgis-devel@lists.osgeo.org><br><b>Subject:</b> Re: [postgis-devel] RFC - Orientation checking and forcing functions<o:p></o:p></span></p></div></div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p><div><p class=MsoNormal style='margin-left:.5in'>+1 from me<br><br>P.<o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:.5in'><br>On Feb 7, 2017, at 4:55 PM, Daniel Baston <<a href="mailto:dbaston@gmail.com">dbaston@gmail.com</a>> wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><div><div><p class=MsoNormal style='margin-left:.5in'>Hi All,<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>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.<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>The four proposed functions are.<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>ST_ForceCW<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>ST_ForceCCW<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>ST_IsCW<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>ST_IsCCW<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>The semantics are straightforward, in my opinion:<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>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.<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>2.  ST_ForceCCW is simply a shorthand for ST_Reverse(ST_ForceCW)<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>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)).<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>4.  ST_IsCCW returns true if a geometry would not be modified by ST_ForceCCW.<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>A few notes:<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>ST_IsCW and ST_IsCCW both return false if a polygon has invalid ring orientation (i.e., exterior and interior rings are all clockwise)<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>ST_IsCW and ST_IsCCW both return true for geometries that have no non-empty polygonal components.<o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div><div><div><p class=MsoNormal style='margin-left:.5in'>Relevant links: <o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>PR: <a href="https://github.com/postgis/postgis/pull/122">https://github.com/postgis/postgis/pull/122</a><o:p></o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>Trac: <a href="https://trac.osgeo.org/postgis/ticket/3689">https://trac.osgeo.org/postgis/ticket/3689</a>, <a href="https://trac.osgeo.org/postgis/ticket/3651">https://trac.osgeo.org/postgis/ticket/3651</a><o:p></o:p></p></div></div><div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p></div><div><p class=MsoNormal style='margin-left:.5in'>Dan<o:p></o:p></p></div></div></div></blockquote><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal style='margin-left:.5in'>_______________________________________________<br>postgis-devel mailing list<br><a href="mailto:postgis-devel@lists.osgeo.org">postgis-devel@lists.osgeo.org</a><br><a href="https://lists.osgeo.org/mailman/listinfo/postgis-devel">https://lists.osgeo.org/mailman/listinfo/postgis-devel</a><o:p></o:p></p></div></blockquote></div></body></html>