PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum geometry_from_geography ( PG_FUNCTION_ARGS  )

Definition at line 619 of file geography_inout.c.

References geometry_serialize(), lwgeom_add_bbox(), lwgeom_drop_bbox(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_set_geodetic(), LWGEOM::srid, and SRID_DEFAULT.

620 {
621  LWGEOM *lwgeom = NULL;
622  GSERIALIZED *ret = NULL;
623  GSERIALIZED *g_ser = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
624 
625  lwgeom = lwgeom_from_gserialized(g_ser);
626 
627  /* Recalculate the boxes after re-setting the geodetic bit */
628  lwgeom_set_geodetic(lwgeom, false);
629  lwgeom_drop_bbox(lwgeom);
630  lwgeom_add_bbox(lwgeom);
631 
632  /* We want "geometry" to think all our "geography" has an SRID, and the
633  implied SRID is the default, so we fill that in if our SRID is actually unknown. */
634  if ( (int)lwgeom->srid <= 0 )
635  lwgeom->srid = SRID_DEFAULT;
636 
637  ret = geometry_serialize(lwgeom);
638  lwgeom_free(lwgeom);
639 
640  PG_RETURN_POINTER(ret);
641 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
#define SRID_DEFAULT
Definition: liblwgeom.h:161
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
Definition: lwgeom.c:542
int32_t srid
Definition: liblwgeom.h:355
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
Definition: lwgeom.c:814
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:555

Here is the call graph for this function: