53 projPJ input_pj, output_pj;
54 int32 output_srid, input_srid;
56 output_srid = PG_GETARG_INT32(1);
59 elog(ERROR,
"%d is an invalid target SRID",
SRID_UNKNOWN);
63 geom = PG_GETARG_GSERIALIZED_P_COPY(0);
68 PG_FREE_IF_COPY(geom, 0);
69 elog(ERROR,
"Input geometry has unknown (%d) SRID",
SRID_UNKNOWN);
74 if ( input_srid == output_srid )
75 PG_RETURN_POINTER(geom);
77 if ( GetProjectionsUsingFCInfo(fcinfo, input_srid, output_srid, &input_pj, &output_pj) ==
LW_FAILURE )
79 PG_FREE_IF_COPY(geom, 0);
80 elog(ERROR,
"Failure reading projections from spatial_ref_sys.");
87 lwgeom->
srid = output_srid;
97 PG_FREE_IF_COPY(geom, 0);
99 PG_RETURN_POINTER(result);
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)...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
void lwgeom_free(LWGEOM *geom)
int lwgeom_transform(LWGEOM *geom, projPJ inpj, projPJ outpj)
Transform (reproject) a geometry in-place.
#define SRID_UNKNOWN
Unknown SRID value.
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)