PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum LWGEOM_force_sfs ( PG_FUNCTION_ARGS  )

Definition at line 524 of file lwgeom_functions_basic.c.

References geometry_serialize(), lwgeom_force_sfs(), lwgeom_from_gserialized(), and result.

525 {
526  GSERIALIZED *geom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
528  LWGEOM *lwgeom;
529  LWGEOM *ogeom;
530  text * ver;
531  int version = 110; /* default version is SFS 1.1 */
532 
533  POSTGIS_DEBUG(2, "LWGEOM_force_sfs called");
534 
535  /* If user specified version, respect it */
536  if ( (PG_NARGS()>1) && (!PG_ARGISNULL(1)) )
537  {
538  ver = PG_GETARG_TEXT_P(1);
539 
540  if ( ! strncmp(VARDATA(ver), "1.2", 3))
541  {
542  version = 120;
543  }
544  }
545 
546  lwgeom = lwgeom_from_gserialized(geom);
547  ogeom = lwgeom_force_sfs(lwgeom, version);
548 
549  result = geometry_serialize(ogeom);
550 
551  PG_FREE_IF_COPY(geom, 0);
552 
553  PG_RETURN_POINTER(result);
554 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWGEOM * lwgeom_force_sfs(LWGEOM *geom, int version)
Definition: lwgeom.c:700
char ** result
Definition: liblwgeom.h:218
LWGEOM * geom
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

Here is the call graph for this function: