Changeset 4637

Show
Ignore:
Timestamp:
10/09/09 20:18:28 (3 years ago)
Author:
pramsey
Message:

Add geometry(geography) case per #257

Location:
trunk/postgis
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/postgis/geography_inout.c

    r4579 r4637  
    4949Datum geography_from_binary(PG_FUNCTION_ARGS); 
    5050Datum geography_from_geometry(PG_FUNCTION_ARGS); 
     51Datum geometry_from_geography(PG_FUNCTION_ARGS); 
    5152 
    5253/* Datum geography_gist_selectivity(PG_FUNCTION_ARGS); TBD */ 
     
    933934} 
    934935 
     936PG_FUNCTION_INFO_V1(geometry_from_geography); 
     937Datum geometry_from_geography(PG_FUNCTION_ARGS) 
     938{ 
     939        LWGEOM *lwgeom = NULL; 
     940        PG_LWGEOM *ret = NULL; 
     941        GSERIALIZED *g_ser = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0)); 
     942 
     943        lwgeom = lwgeom_from_gserialized(g_ser); 
     944        ret = pglwgeom_serialize(lwgeom); 
     945        lwgeom_release(lwgeom); 
     946         
     947        if ( is_worth_caching_pglwgeom_bbox(ret) ) 
     948        { 
     949                ret = (PG_LWGEOM *)DatumGetPointer(DirectFunctionCall1(LWGEOM_addBBOX, PointerGetDatum(ret))); 
     950        } 
     951 
     952        PG_RETURN_POINTER(ret);  
     953} 
     954 
  • trunk/postgis/geography.sql.in.c

    r4635 r4637  
    174174CREATE CAST (geometry AS geography) WITH FUNCTION geography(geometry) AS IMPLICIT; 
    175175 
     176-- Availability: 1.5.0 
     177CREATE OR REPLACE FUNCTION geometry(geography) 
     178        RETURNS geometry 
     179        AS 'MODULE_PATHNAME','geometry_from_geography' 
     180        LANGUAGE 'C' IMMUTABLE STRICT; 
     181 
     182-- Availability: 1.5.0 
     183CREATE CAST (geography AS geometry) WITH FUNCTION geometry(geography) AS IMPLICIT; 
     184 
    176185-- ---------- ---------- ---------- ---------- ---------- ---------- ---------- 
    177186-- GiST Support Functions