[postgis-tickets] [PostGIS] #4598: spurious results of ST_Centroid on invalid polygons of type geography

PostGIS trac at osgeo.org
Mon Dec 9 10:22: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
Resolution:           |   Keywords:
----------------------+---------------------------

Comment (by grasslandtom):

 Replying to [ticket:4598 fadi]:
 > * 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.

 Taking into account the comment regarding the first one (i.e. "thicker at
 the bottom") the third one might well be ok (did not verify that in any
 way).

 For the "Too few points in geometry" case, it seems inconsistent that
 ST_Centroid(geography) returns POINT(-nan nan) while ST_Centroid(geometry)
 nevertheless computes a "correct" result. It could be expected that in
 both cases the output is the same as for the linestring that would be the
 correct representation of the given "polygon" (which is already the case
 for ST_Centroid(geometry)):

 {{{
 select st_astext(st_centroid('linestring(0 0, 1 1)')),
 st_astext(st_centroid('linestring(0 0, 1 1)'::geography));
 -[ RECORD 1 ]-----------------------------------------
 st_astext | POINT(0.5 0.5)
 st_astext | POINT(0.499961919922622 0.500019038226107)
 }}}

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4598#comment:1>
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