Opened 3 years ago

Closed 15 months ago

#1000 closed defect (fixed)

behavior of GEOSCoordSeq_isCCW() is unclear when input is not a simple closed curve

Reported by: sirsigurd Owned by: geos-devel@…
Priority: major Milestone: 3.10.0
Component: Default Version: 3.7.0
Severity: Unassigned Keywords:
Cc:

Description

Here's GEOSCoordSeq_isCCW() doc from C API header:

/*
 * Check orientation of a CoordinateSequence and set 'is_ccw' to 1
 * if it has counter-clockwise orientation, 0 otherwise.
 * Return 0 on exception, 1 on success.
 */
extern int GEOS_DLL GEOSCoordSeq_isCCW_r(GEOSContextHandle_t handle,
                                         const GEOSCoordSequence* s,
                                         char* is_ccw);

As I understand from Wikipedia, 'orientation' is defined only for simple closed curves (hereafter referred to as SCC).

So from my perspective GEOSCoordSeq_isCCW() could follow one these approaches for input which is not SCC:

  1. Orientation is defined only for SCC, so if input is not SCC, it can't be CCW-oriented curve (is_ccw = 0).
  1. Orientation is defined only for SCC, so if input is not SCC, it's invalid (error code is returned)

Currently GEOSCoordSeq_isCCW() doesn't follow any of these approaches consistently. If coordinate sequence has less than 4 points error code is returned. At later stage if it turns out that there are less than 3 distinctive points is_ccw is set to 0.

Change History (3)

comment:1 by pramsey, 22 months ago

Milestone: 3.10.0

comment:2 by pramsey, 15 months ago

No, checking this back against JTS, apparently JTS always returns false on invalid input. So we could ape that, which would be a slight change.

comment:3 by Paul Ramsey <pramsey@…>, 15 months ago

Resolution: fixed
Status: newclosed

In f4d05b2/git:

Document fun behaviour of GEOSCoordSeq_isCCW, closes #1000

Note: See TracTickets for help on using tickets.