Opened 12 years ago

Closed 12 years ago

#559 closed defect (fixed)

EMPTY Centroid of tiny triangular polygon

Reported by: strk Owned by: geos-devel@…
Priority: major Milestone: 3.3.5
Component: Default Version: 3.3.4
Severity: Unassigned Keywords:
Cc:

Description

The centroid of this polygon:

POLYGON((
56.528666666700 25.2101666667,
56.529000000001 25.2105000000,
56.528833333300 25.2103333333,
56.528666666700 25.2101666667))

Is computed as EMPTY.

See http://trac.osgeo.org/postgis/ticket/1884 for origins of this

Change History (5)

comment:1 by strk, 12 years ago

It is a _very_ tiny polygon, area: 3.30872245021211e-24 ST_PointOnSurface works fine.

comment:2 by strk, 12 years ago

Sorry, I had the wrong WKT. The one in the orginal post works, this one is the one that fails:

POLYGON((
56.528666666700 25.2101666667,
56.529000000000 25.2105000000,
56.528833333300 25.2103333333,
56.528666666700 25.2101666667))

The difference is in the least significant digit in the X ordinate of the second point. Both are valid. Area of the working one is 8.28966197710509e-17, area of the non-working one is 3.30872245021211e-24

comment:3 by strk, 12 years ago

CentroidArea::area2 always returns 0 in the failing case, for all the involved triangles (3).

Casting one of the vertices ordinate values to a long double (any of them) "fixes" the case.

comment:4 by strk, 12 years ago

I found an unported handling for this case in JTS (degenerate area). Trying that out now. Mind you: an empty polygon seems still unhandled by JTS.

comment:5 by strk, 12 years ago

Resolution: fixed
Status: newclosed

Fixed by r3676 in 3.3 branch (to be 3.3.5) and r3677 in trunk (to be 3.4.0)

Note: See TracTickets for help on using tickets.