[postgis-tickets] [PostGIS] #2640: ST_GeogFromText allows putting in non-long lat coordinate ref

PostGIS trac at osgeo.org
Fri Feb 7 12:39:29 PST 2014


#2640: ST_GeogFromText allows putting in non-long lat coordinate ref
---------------------+------------------------------------------------------
 Reporter:  robe     |       Owner:  pramsey      
     Type:  defect   |      Status:  new          
 Priority:  medium   |   Milestone:  PostGIS 2.1.2
Component:  postgis  |     Version:  2.1.x        
 Keywords:           |  
---------------------+------------------------------------------------------
 {{{
 SELECT ST_Distance(ST_GeogFromText('SRID=2249;POINT(1 2)'),
 ST_GeogFromText('SRID=2249;POINT(4 8)') ) ;
 }}}


 Paul I assume it was intentional that you changed geography to accept
 other spatial ref sys besides WGS 84 (4326).  Where was this announcement
 made -- I assume I just missed it.

 Trapping works fine when casting to geography, but not so nice when using
 ST_GeogFromText

 Observe:


 {{{
 -- cool catch
 SELECT 'SRID=2249;POINT(775041.040826076 2956528.39992328)'::geography

 ERROR:  Only lon/lat coordinate systems are supported in geography.
 }}}

 -- not so cool catch
 {{{
 SELECT ST_GeogFromText('SRID=2249;POINT(775041.040826076
 2956528.39992328)');

 --very not cool to find out after I've loaded my data --

 SELECT ST_Distance(ST_GeogFromText('SRID=2249;POINT(775041.040826076
 2956528.39992328)'), ST_GeogFromText('SRID=2249;POINT(772319.977336506
 2960158.82319006)') );

 NOTICE:  Coordinate values were coerced into range [-180 -90, 180 90] for
 GEOGRAPHY
 NOTICE:  Coordinate values were coerced into range [-180 -90, 180 90] for
 GEOGRAPHY


 ERROR:  spheroid_distance returned NaN: (-0.49567216854771884
 -0.67996585883191063) (-1.0266583430730258 2.0939995498030646) a =
 1.0234294757849818e-315 b = 0
 CONTEXT:  SQL function "st_distance" statement 1


 }}}

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