PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ geometry_from_geography()

Datum geometry_from_geography ( PG_FUNCTION_ARGS  )

Definition at line 631 of file geography_inout.c.

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

Referenced by geography_from_geometry().

632 {
633  LWGEOM *lwgeom = NULL;
634  GSERIALIZED *ret = NULL;
635  GSERIALIZED *g_ser = PG_GETARG_GSERIALIZED_P(0);
636 
637  lwgeom = lwgeom_from_gserialized(g_ser);
638 
639  /* Recalculate the boxes after re-setting the geodetic bit */
640  lwgeom_set_geodetic(lwgeom, false);
641  lwgeom_drop_bbox(lwgeom);
642  lwgeom_add_bbox(lwgeom);
643 
644  /* We want "geometry" to think all our "geography" has an SRID, and the
645  implied SRID is the default, so we fill that in if our SRID is actually unknown. */
646  if ( (int)lwgeom->srid <= 0 )
647  lwgeom->srid = SRID_DEFAULT;
648 
649  ret = geometry_serialize(lwgeom);
650  lwgeom_free(lwgeom);
651 
652  PG_RETURN_POINTER(ret);
653 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
#define SRID_DEFAULT
Definition: liblwgeom.h:195
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
Definition: lwgeom.c:635
int32_t srid
Definition: liblwgeom.h:399
void lwgeom_set_geodetic(LWGEOM *geom, int value)
Set the FLAGS geodetic bit on geometry an all sub-geometries and pointlists.
Definition: lwgeom.c:907
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:648
Here is the call graph for this function:
Here is the caller graph for this function: