52 projPJ input_pj, output_pj;
53 int32 output_srid, input_srid;
55 output_srid = PG_GETARG_INT32(1);
62 geom = PG_GETARG_GSERIALIZED_P_COPY(0);
66 PG_FREE_IF_COPY(geom, 0);
67 elog(ERROR,
"Input geometry has unknown (%d) SRID",
SRID_UNKNOWN);
75 if ( input_srid == output_srid )
76 PG_RETURN_POINTER(PG_GETARG_DATUM(0));
78 if ( GetProjectionsUsingFCInfo(fcinfo, input_srid, output_srid, &input_pj, &output_pj) ==
LW_FAILURE )
80 PG_FREE_IF_COPY(geom, 0);
81 elog(ERROR,
"Failure reading projections from spatial_ref_sys.");
88 lwgeom->
srid = output_srid;
99 PG_FREE_IF_COPY(geom, 0);
101 PG_RETURN_POINTER(result);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
int lwgeom_transform(LWGEOM *geom, projPJ inpj, projPJ outpj)
Transform (reproject) a geometry in-place.
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
#define SRID_UNKNOWN
Unknown SRID value.
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...