[postgis-tickets] [PostGIS] #2951: ST_Centroid for geography

PostGIS trac at osgeo.org
Mon Jul 31 11:40:55 PDT 2017


#2951: ST_Centroid for geography
--------------------------+---------------------------
  Reporter:  Mike Toews   |      Owner:  robe
      Type:  enhancement  |     Status:  new
  Priority:  medium       |  Milestone:  PostGIS 2.4.0
 Component:  liblwgeom    |    Version:
Resolution:               |   Keywords:
--------------------------+---------------------------

Comment (by robe):

 okay get a crash with this:


 {{{
 CREATE TABLE crash_geog AS SELECT 'MULTIPOLYGON(((-71.137596
 42.3487872,-71.1383097 42.3490151,-71.1382789 42.3490681,-71.1382501
 42.3490589,-71.1382019 42.3491419,-71.1383391 42.3491856,-71.1383875
 42.3491023,-71.1383548 42.3490918,-71.138382 42.3490449,-71.1386865
 42.3491331,-71.1390201 42.3491748,-71.13933 42.3491671,-71.1396678
 42.3491065,-71.1397578 42.3493047,-71.1396044 42.3493469,-71.1395729
 42.3492775,-71.1396152 42.3492669,-71.1395796 42.3491887,-71.1394566
 42.3492194,-71.1394924 42.3492982,-71.1395196 42.3492914,-71.1395503
 42.3493589,-71.1393759 42.3493876,-71.1393659 42.3493398,-71.1393906
 42.349337,-71.1393673 42.3492253,-71.1392714 42.3492362,-71.1392912
 42.349332,-71.139319 42.3493289,-71.1393323 42.3493926,-71.1391527
 42.3494039,-71.139152 42.3493581,-71.139185 42.3493579,-71.1391833
 42.3492461,-71.1390796 42.349247,-71.1390812 42.3493579,-71.1391122
 42.3493576,-71.1391129 42.3494045,-71.1389428 42.3493988,-71.1389508
 42.3493271,-71.1389808 42.3493289,-71.13899 42.3492461,-71.1388876
 42.3492397,-71.1388784 42.3493222,-71.1389117 42.3493242,-71.1389038
 42.3493957,-71.1387259 42.3493725,-71.138733 42.3493419,-71.1387611
 42.3493454,-71.1387873 42.3492323,-71.1386944 42.3492206,-71.1386685
 42.3493329,-71.138693 42.349336,-71.1386861 42.3493653,-71.1384964
 42.3493204,-71.1385299 42.349248,-71.138582 42.3492613,-71.138611
 42.3491982,-71.1385178 42.3491684,-71.1384841 42.3492263,-71.1385087
 42.3492341,-71.1384722 42.349297,-71.1380043 42.3491477,-71.1380401
 42.349086,-71.1380635 42.3490934,-71.1381007 42.3490295,-71.1380334
 42.349008,-71.1379706 42.3491162,-71.1380034 42.3491267,-71.1379583
 42.3492045,-71.1374483 42.3490416,-71.137596 42.3487872),(-71.1378595
 42.3489515,-71.1377924 42.3490673,-71.1378626 42.3490897,-71.1379298
 42.3489739,-71.1378595 42.3489515),(-71.1376915 42.3488978,-71.1376243
 42.3490136,-71.1376946 42.349036,-71.1377618 42.3489203,-71.1376915
 42.3488978),(-71.1384173 42.3491847,-71.1383997 42.3492152,-71.1384353
 42.3492266,-71.138453 42.349196,-71.1384173 42.3491847),(-71.1381277
 42.3490922,-71.13811 42.3491228,-71.1381455 42.3491341,-71.1381633
 42.3491036,-71.1381277 42.3490922)))'::geography AS geog;


 SELECT ST_Centroid(geog)
 FROM crash_geog;
 }}}

 backtrace shows:


 {{{
 Program received signal SIGSEGV, Segmentation fault.
 [Switching to Thread 8460.0x1d80]
 lwpoint_get_y (point=0xc051c8d73f5ce5f6) at lwpoint.c:76
 76              if ( lwpoint_is_empty(point) )

 }}}


 regarding the docs,

 you need to get rid of the function proto that has no use_spheroid  and
 change the one with use_spheroid this:


 {{{
         <funcprototype>
           <funcdef>geography <function>ST_Centroid</function></funcdef>

           <paramdef><type>geography </type>
                   <parameter>g1</parameter></paramdef>
           <paramdef choice="opt"><type>boolean </type>
                   <parameter>use_spheroid=true</parameter></paramdef>
         </funcprototype>
 }}}

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