PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ transform_pipeline_geom()

Datum transform_pipeline_geom ( PG_FUNCTION_ARGS  )

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

162 {
163  GSERIALIZED *gser, *gser_result=NULL;
164  LWGEOM *geom;
165  char *input_pipeline;
166  bool is_forward;
167  int32 result_srid;
168  int rv;
169 
170  /* Take a copy, since we will be altering the coordinates */
171  gser = PG_GETARG_GSERIALIZED_P_COPY(0);
172 
173  /* Convert from text to cstring for libproj */
174  input_pipeline = text_to_cstring(PG_GETARG_TEXT_P(1));
175  is_forward = PG_GETARG_BOOL(2);
176  result_srid = PG_GETARG_INT32(3);
177 
178  geom = lwgeom_from_gserialized(gser);
179  rv = lwgeom_transform_pipeline(geom, input_pipeline, is_forward);
180  pfree(input_pipeline);
181 
182  if (rv == LW_FAILURE)
183  {
184  elog(ERROR, "coordinate transformation failed");
185  PG_RETURN_NULL();
186  }
187 
188  /* Re-compute bbox if input had one (COMPUTE_BBOX TAINTING) */
189  geom->srid = result_srid;
190  if (geom->bbox)
191  lwgeom_refresh_bbox(geom);
192 
193  gser_result = geometry_serialize(geom);
194  lwgeom_free(geom);
195  PG_FREE_IF_COPY(gser, 0);
196 
197  PG_RETURN_POINTER(gser_result); /* new geometry */
198 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
Definition: lwgeom.c:707
#define LW_FAILURE
Definition: liblwgeom.h:96
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155
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: