Re: r15336 - #3589, Orientation checking and forcing fuctions

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: r15336 - #3589, Orientation checking and forcing fuctions

Sandro Santilli-3
On Thu, Mar 16, 2017 at 05:28:07PM -0700, Daniel Baston wrote:
> Author: dbaston
> Date: 2017-03-16 17:28:07 -0700 (Thu, 16 Mar 2017)
> New Revision: 15336

> + <function>ST_IsPolygonCCW</function>
...
> + Returns true for all non-polygonal geometries.

I don't like this approach. Why true ? I'd rather see a NULL return
there, if you don't want to be hit by an exception.

What do others think about this ?

--strk;
_______________________________________________
postgis-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-devel
Reply | Threaded
Open this post in threaded view
|

Re: r15336 - #3589, Orientation checking and forcing fuctions

Daniel Baston
It returns true so that the functions are internally consistent, i.e. whenever ST_OrderingEquals(geom, ST_ForcePolygonCCW(geom)) is true then ST_IsPolygonCCW(geom) must also be true.  One way to think of it is that the function is telling you whether all of the polygons in the input are oriented CCW.  If you have zero polygons, then all of the polygons are oriented CCW.  In addition to internal consistency, this allows the functions to work on geometry collections that contain mixed geometry types (say, a polygon and a point).

One application of the function is to test whether an arbitrary geometry will behave correctly in software that requires a particular orientation, without having to separately test the type of the geometry.

Do you want to explain a bit about why you don't like it?  Is there a use case that benefits from the NULL return?

Dan

On Fri, Mar 17, 2017 at 3:19 AM, Sandro Santilli <[hidden email]> wrote:
On Thu, Mar 16, 2017 at 05:28:07PM -0700, Daniel Baston wrote:
> Author: dbaston
> Date: 2017-03-16 17:28:07 -0700 (Thu, 16 Mar 2017)
> New Revision: 15336

> +                                             <function>ST_IsPolygonCCW</function>
...
> +                             Returns true for all non-polygonal geometries.

I don't like this approach. Why true ? I'd rather see a NULL return
there, if you don't want to be hit by an exception.

What do others think about this ?

--strk;
_______________________________________________
postgis-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-devel


_______________________________________________
postgis-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-devel
Reply | Threaded
Open this post in threaded view
|

Re: r15336 - #3589, Orientation checking and forcing fuctions

Sandro Santilli-3
On Fri, Mar 17, 2017 at 09:31:33AM -0400, Daniel Baston wrote:

> One way to think of it is that
> the function is telling you whether all of the polygons in the input are
> oriented CCW.  If you have zero polygons, then all of the polygons are
> oriented CCW.

Ok, this is convincing.

> Do you want to explain a bit about why you don't like it?

I didn't like the wording, if you can express it as you did above,
it'll be fine for me. So basically:

- Returns true for all non-polygonal
+ Returns true if all polygonal components are oriented CCW

Something along those lines...

--strk;
_______________________________________________
postgis-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-devel
Reply | Threaded
Open this post in threaded view
|

Re: r15336 - #3589, Orientation checking and forcing fuctions

Sandro Santilli-3
On Fri, Mar 17, 2017 at 02:41:20PM +0100, Sandro Santilli wrote:

> On Fri, Mar 17, 2017 at 09:31:33AM -0400, Daniel Baston wrote:
>
> > One way to think of it is that
> > the function is telling you whether all of the polygons in the input are
> > oriented CCW.  If you have zero polygons, then all of the polygons are
> > oriented CCW.
>
> Ok, this is convincing.
>
> > Do you want to explain a bit about why you don't like it?
>
> I didn't like the wording, if you can express it as you did above,
> it'll be fine for me. So basically:
>
> - Returns true for all non-polygonal
> + Returns true if all polygonal components are oriented CCW
>
> Something along those lines...

Oh, and please add a WARNING/NOTE section specifying that a CW
closed linestring would still return true from IsPolygonCCW
function, as that'd be also a puzzling behavior (although explained
by your definition above)

--strk;
_______________________________________________
postgis-devel mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/postgis-devel