PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ transform_pipeline_geom()

Datum transform_pipeline_geom ( PG_FUNCTION_ARGS  )

Definition at line 165 of file postgis/lwgeom_transform.c.

166{
167 GSERIALIZED *gser, *gser_result=NULL;
168 LWGEOM *geom;
169 char *input_pipeline;
170 bool is_forward;
171 int32 result_srid;
172 int rv;
173
174 /* Take a copy, since we will be altering the coordinates */
175 gser = PG_GETARG_GSERIALIZED_P_COPY(0);
176
177 /* Convert from text to cstring for libproj */
178 input_pipeline = text_to_cstring(PG_GETARG_TEXT_P(1));
179 is_forward = PG_GETARG_BOOL(2);
180 result_srid = PG_GETARG_INT32(3);
181
182 geom = lwgeom_from_gserialized(gser);
183 rv = lwgeom_transform_pipeline(geom, input_pipeline, is_forward);
184 pfree(input_pipeline);
185
186 if (rv == LW_FAILURE)
187 {
188 elog(ERROR, "coordinate transformation failed");
189 PG_RETURN_NULL();
190 }
191
192 /* Re-compute bbox if input had one (COMPUTE_BBOX TAINTING) */
193 geom->srid = result_srid;
194 if (geom->bbox)
196
197 gser_result = geometry_serialize(geom);
198 lwgeom_free(geom);
199 PG_FREE_IF_COPY(gser, 0);
200
201 PG_RETURN_POINTER(gser_result); /* new geometry */
202}
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.
Definition lwgeom.c:735
#define LW_FAILURE
Definition liblwgeom.h:96
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
int lwgeom_transform_pipeline(LWGEOM *geom, const char *pipeline, bool is_forward)
Transform (reproject) a geometry in-place using a PROJ pipeline.
unsigned int int32
Definition shpopen.c:54
GBOX * bbox
Definition liblwgeom.h:458
int32_t srid
Definition liblwgeom.h:460

References LWGEOM::bbox, LW_FAILURE, lwgeom_free(), lwgeom_from_gserialized(), lwgeom_refresh_bbox(), lwgeom_transform_pipeline(), and LWGEOM::srid.

Here is the call graph for this function: