Opened 3 years ago

Closed 2 years ago

#5107 closed defect (wontfix)

"flat" polygon has non-zero area according to ST_Area

Reported by: strk Owned by: pramsey
Priority: medium Milestone: PostGIS 3.4.0
Component: postgis Version: 3.2.x
Keywords: Cc:

Description

Spin-off of #5105, ST_Area can report non-zero area for completely flat polygons. Example:

POLYGON((
  29.262792863298348 71.22115103790775,
  29.26598031986849  71.22202978558047,
  29.275379947735576 71.22044935739267,

  29.29461024331857  71.22741507590429,

  29.275379947735576 71.22044935739267,
  29.26598031986849  71.22202978558047,
  29.262792863298348 71.22115103790775
))

Note how the polygon ring is going forward and backward onto the exact same vertices.

Change History (5)

comment:2 by strk, 3 years ago

The code is ptarray_signed_area and references https://en.wikipedia.org/wiki/Shoelace_formula with a comment saying it should return 0 for "flat" polygons, which is not happening.

comment:3 by strk, 3 years ago

GEOS suffers from the same bug, although PostGIS does NOT use GEOS for this: https://github.com/libgeos/geos/issues/581

comment:4 by robe, 2 years ago

Milestone: PostGIS 3.3.0PostGIS 3.4.0

comment:5 by pramsey, 2 years ago

Resolution: wontfix
Status: newclosed

Per https://github.com/libgeos/geos/issues/581 I'm closing this. Do enough arithmetic on FP and you get some drift. Maybe figure out your tolerance and round?

Note: See TracTickets for help on using tickets.