Opened 11 years ago

Last modified 5 years ago

#665 new enhancement

st_isvalid fails to detect invalid interior ring orientation

Reported by: vmo Owned by: geos-devel@…
Priority: major Milestone: GEOS Fund Me
Component: Default Version: 3.3.3
Severity: Unassigned Keywords:
Cc:

Description

The following request should return False (the interior ring as the same orientation as the exterior ring)

select st_isvalid(st_geomfromtext('polygon((0 0, 1 0, 1 1, 0 1, 0 0),(.1 .1, .9 .1, .9 .9, .1 .9, .1 .1))'));

But it returns True.

From Simple Feature Access - Part 1 (1.2.1), section 6.1.11:

The exterior boundary LinearRing defines the “top” of the surface which is the side of the surface from which the exterior boundary appears to traverse the boundary in a counter clockwise direction. The interior LinearRings will have the opposite orientation, and appear as clockwise when viewed from the “top”,

Change History (11)

comment:1 by strk, 11 years ago

GEOS/JTS has never been checking for orientation as a validity constraint, is this new in the SFS specs ?

comment:2 by vmo, 11 years ago

Since version 1.2.0 (2006-10-05) apparently.

comment:3 by aperi2007, 11 years ago

AFAIK the clockwise vs not-clockwise orientation is not a OGC-SF velidity constraint. AFAIK it is a specific constraint only for shapefile.

comment:4 by aperi2007, 11 years ago

in the 1.2.1 successively version of specs

OpenGIS® Implementation Standard for Geographic information - Simple feature access - Part 2: SQL option 2010-08-04

Seem it was corrected.

Infact at page 105 they wrote:

Polygon rotation is not defined by this standard; actual polygon rotation may be in a clockwise or counter-clockwise direction

AFAIK this is for internal or external ring.

comment:5 by vmo, 11 years ago

I agree that the orientation of the exterior ring is not specified (it's used to define the top, nothing more).

But to me the highlighted sentence clearly says that interior rings must be oriented opposite to the exterior ring.

It's somewhat clarified in the draft of the upcoming ISO 19107 (admittedly not voted yet):

"Surfaces in 2D will always have a planar interpolation because of the restriction of the dimension of the coordinate space. In 2D because of the restriction above, a surface will have a unique exterior ring, the one with the largest envelope, and some number of interior rings. Each such ring in 2D satisfies the Jordan Curve Theorem and thus divides the space into exactly two regions, one bounded and one unbounded. For rings that are counterclockwise, the bounded area is to the left of the ring as a curve. For rings that are clockwise, the bounded area is to its right. Each ring is said to define an area, the one to its left. A surface in 2D is the set intersection of the areas defined by its rings."

I say "somewhat clarified" because the highlighted sentence means that orientation defines where the area is (exterior or interior). Interior ring needs to define the unbounded region to define the polygon as intersection of all areas defined by the rings. Nevertheless, the two previous sentences seem to me to say just the opposite.

comment:6 by strk, 11 years ago

I guess we'll need a flag to check validity according to ISO 19107 then. There's one for ring-touching-shell validity already, IIRC.

comment:7 by strk, 11 years ago

Milestone: 3.4.33.5.0
Type: defectenhancement

I confirm we have a switch to check for ring-touching-shell, but for orientation there's no code currently to do it. It isn't hard, but I'd like not to get out of sync with JTS so it'd be lovely to hear Martin Davis voice on this.

comment:8 by robe, 9 years ago

Milestone: 3.5.03.6.0

comment:9 by strk, 8 years ago

Milestone: 3.6.03.7.0

Ticket retargeted after milestone closed

comment:10 by robe, 6 years ago

Milestone: 3.7.0GEOS Fund Me

comment:11 by darkblueb, 5 years ago

Testing dataset Valids-Delft for valid-invalid policy evaluation, under construction here

Currently all Valids-Delft tests use counter-clockwise winding for outer-shell, and clockwise winding for inner-shell(s). Permutations of winding are planned.

DrJTS says: JTS will continue to be insensitive to windings at this time (sep19).

Note: See TracTickets for help on using tickets.