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

Definition at line 647 of file geography_inout.c.

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

648 {
649  LWGEOM *lwgeom = NULL;
650  GSERIALIZED *ret = NULL;
651  GSERIALIZED *g_ser = PG_GETARG_GSERIALIZED_P(0);
652 
653  lwgeom = lwgeom_from_gserialized(g_ser);
654 
655  /* Recalculate the boxes after re-setting the geodetic bit */
656  lwgeom_set_geodetic(lwgeom, false);
657  lwgeom_refresh_bbox(lwgeom);
658 
659  /* We want "geometry" to think all our "geography" has an SRID, and the
660  implied SRID is the default, so we fill that in if our SRID is actually unknown. */
661  if ( (int)lwgeom->srid <= 0 )
662  lwgeom->srid = SRID_DEFAULT;
663 
664  ret = geometry_serialize(lwgeom);
665  lwgeom_free(lwgeom);
666 
667  PG_RETURN_POINTER(ret);
668 }
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
Definition: lwgeom.c:691
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
#define SRID_DEFAULT
Definition: liblwgeom.h:194
int32_t srid
Definition: liblwgeom.h:398
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
Definition: lwgeom.c:945
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

Here is the call graph for this function: