PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ geometry_from_geography()

Datum geometry_from_geography ( PG_FUNCTION_ARGS  )

Definition at line 624 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().

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