[postgis-tickets] [PostGIS] #3667: Bug in geography ST_Segmentize

PostGIS trac at osgeo.org
Tue Nov 8 23:02:56 PST 2016


#3667: Bug in geography ST_Segmentize
---------------------+---------------------------
 Reporter:  robe     |      Owner:  pramsey
     Type:  defect   |     Status:  new
 Priority:  high     |  Milestone:  PostGIS 2.3.1
Component:  postgis  |    Version:  2.3.x
 Keywords:           |
---------------------+---------------------------
 There is still something wrong with ST_Segmentize geography as someone
 noted on IRC:

 From http://irclogs.geoapt.com/postgis/%23postgis.2016-11-08.log
 {{{
 15:42:57        skyrocker:      E.g. SELECT
 ST_AsText(ST_Segmentize(ST_GeographyFromText('LINESTRING(38.769917
 10.780694, 38.769917 9.106194)'), 30000))
 15:43:01        skyrocker:      Results in LINESTRING(38.769917
 10.780694,3.97245555092463e-308 5.68175492717434e-322,38.769917 9.106194)
 15:43:12        skyrocker:      Which is obviously not correct
 15:45:18        skyrocker:      Although after changing first coordinate
 of first point in LINESTRING I get correct result (e.g. instead of
 38.769917 put 38.769918)
 15:46:50        skyrocker:      And also for some werid reason swapping
 order of points in LINESTRING also gives me correct result
 }}}


 The only thing I see special about this is that in cartesian it's
 vertical.

 Testing on


 {{{
 POSTGIS="2.3.0 r15146" GEOS="3.6.0-CAPI-1.10.0 r4265" PROJ="Rel. 4.9.1, 04
 March 2015" GDAL="GDAL 2.1.1, released 2016/07/07" LIBXML="2.7.8"
 LIBJSON="0.12" RASTER
 }}}

 The lengths are way off, so it's clearly wrong:


 {{{
 SELECT ST_Length(geog) As len_before, ST_Length(ST_Segmentize(geog,
 30000)) As len_after
 FROM (SELECT ST_GeographyFromText('LINESTRING(38.769917 10.780694,
 38.769917 9.106194)') As geog) AS f;

     len_before    |    len_after
 ------------------+------------------
  185212.200983372 | 8865756.13359671
 (1 row)


 }}}


 But as noted flipping the coordinates works

 {{{
 SELECT ST_Length(geog) As len_before, ST_Length(ST_Segmentize(geog,
 30000)) As len_after
 FROM (SELECT ST_GeographyFromText('LINESTRING(38.769917 9.106194,
 38.769917 10.780694)') As geog) AS f;

     len_before    |    len_after
 ------------------+------------------
  185212.200983372 | 185212.200983372
 (1 row)

 }}}


 This problem is new in 2.3.0 but not 2.2.2, so must be a continuation of
 issue I complained about in #3539:


 In POSTGIS="2.2.2 r14797" GEOS="3.5.0-CAPI-1.9.0 r4090" PROJ="Rel. 4.9.1,
 04 March 2015" GDAL="GDAL 2.0.2, released 2016/01/26" LIBXML="2.7.8"
 LIBJSON="0.12" RASTER the answers are right:


 {{{
 SELECT ST_Length(geog) As len_before, ST_Length(ST_Segmentize(geog,
 30000)) As len_after
 FROM (SELECT ST_GeographyFromText('LINESTRING(38.769917 10.780694,
 38.769917 9.106194)') As geog) AS f;

     len_before    |    len_after
 ------------------+------------------
  185212.200983372 | 185212.200983372
 (1 row)
 }}}

--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3667>
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