[postgis-tickets] [PostGIS] #4598: spurious results of ST_Centroid on invalid polygons of type geography
PostGIS
trac at osgeo.org
Mon Dec 9 08:32:51 PST 2019
#4598: spurious results of ST_Centroid on invalid polygons of type geography
---------------------+---------------------------
Reporter: fadi | Owner: pramsey
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 2.5.4
Component: postgis | Version: 3.0.x
Keywords: |
---------------------+---------------------------
The following query:
{{{
WITH geogs (geog) AS (VALUES
('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'::geography),
('POLYGON((0 0, 1 1, 1 1, 0 0))'::geography),
('POLYGON((0 0, 1 1, 1 0, 0 1, 0 0))'))
SELECT
pg_typeof(geog),
ST_IsValidReason(geog::geometry),
ST_AsText(ST_Centroid(geog)),
ST_AsText(ST_Centroid(geog::geometry)),
FROM geogs;
}}}
will output :
||pg_typeof || st_isvalidreason ||
st_astext || st_astext ||
||geography || Valid Geometry ||
POINT(0.499999916440062 0.500006427946943) ||POINT(0.5 0.5)||
||geography || Too few points in geometry component[0 0] ||POINT(-nan
nan) ||POINT(0.5 0.5)||
||geography || Self-intersection[0.5 0.5] ||POINT(0.5
0.333342264894616) ||POINT(0.5 0.5)||
(3 rows)
* The first one seems okay, assuming the numbers are due to numerical not
very
precise calculation, although I would have expected the centroid some
where
between 0 and 0.5 in terms of latitude (the polygon is thicker at the
bottom)
* Second and third do not look right.
{{{
$ select postgis_full_version();
}}}
POSTGIS="3.0.0 r17983" [EXTENSION] PGSQL="120" GEOS="3.7.1-CAPI-1.11.1
27a5e771" PROJ="Rel. 4.9.2, 08 September 2015" GDAL="GDAL
1.11.3, released 2015/09/16" LIBXML="2.9.3" LIBJSON="0.11.99"
LIBPROTOBUF="1.2.1" WAGYU="0.4.3 (Internal)" RASTER
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4598>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list