PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ transform_pipeline_geom()

Datum transform_pipeline_geom ( PG_FUNCTION_ARGS  )

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

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