[postgis-tickets] [PostGIS] #2965: ST_Distance, use_spheroid default
PostGIS
trac at osgeo.org
Fri Oct 24 23:18:35 PDT 2014
#2965: ST_Distance, use_spheroid default
-----------------------+----------------------------------------------------
Reporter: gitai | Owner: pramsey
Type: defect | Status: closed
Priority: critical | Milestone: PostGIS 2.1.5
Component: postgis | Version: 2.1.x
Resolution: wontfix | Keywords: ST_Distance, use_spheroid
-----------------------+----------------------------------------------------
Comment(by robe):
autocast is never done per function, its done with a cast object and
automatically applies to all function. The thing that controls it is
this:
{{{
CREATE CAST (geometry AS geography)
WITH FUNCTION postgis.geography(geometry)
AS IMPLICIT;
}}}
Note the term -- IMPLICIT (that means that if there is a function for
geography and no equivalent for geometry, then geometry can auto cast
itself to geography to use it)
So if you want to experiment yourself with what pramsey is proposing do
this:
{{{
-- this line needed if you installed postgis as an extension
ALTER EXTENSION postgis DROP CAST (geometry AS geography);
DROP CAST (geometry AS geography);
CREATE CAST (geometry AS geography)
WITH FUNCTION geography(geometry)
AS ASSIGNMENT;
--this line needed if you installed postgis as an extension
ALTER EXTENSION postgis ADD CAST (geometry AS geography);
}}}
Once you do that, you'll see that this no longer works
{{{
select ST_Distance(ST_SetSRID(ST_MakePoint(-73.9662500, 40.7834300),
4326), ST_SetSRID(ST_MakePoint(-74.1960983, 40.739418), 4326), true);
}}}
and you have to explicitly cast to
{{{
select ST_Distance(ST_SetSRID(ST_MakePoint(-73.9662500, 40.7834300),
4326)::geography, ST_SetSRID(ST_MakePoint(-74.1960983, 40.739418),
4326)::geography, true);
}}}
As a general rule, all constructor functions (except for the ones that
have ST_Geog.. or that explicitly take in input as geography return
geometry (not geography).
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2965#comment:19>
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