PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ lwgeom_to_gml2()

lwvarlena_t* lwgeom_to_gml2 ( const LWGEOM geom,
const char *  srs,
int  precision,
const char *  prefix 
)

VERSION GML 2 takes a GEOMETRY and returns a GML2 representation.

Definition at line 259 of file lwout_gml.c.

260 {
261  int type = geom->type;
262 
263  /* Return null for empty (#1377) */
264  if ( lwgeom_is_empty(geom) )
265  return NULL;
266 
267  switch (type)
268  {
269  case POINTTYPE:
270  return asgml2_point((LWPOINT*)geom, srs, precision, prefix);
271 
272  case LINETYPE:
273  return asgml2_line((LWLINE*)geom, srs, precision, prefix);
274 
275  case POLYGONTYPE:
276  return asgml2_poly((LWPOLY*)geom, srs, precision, prefix);
277 
278  case MULTIPOINTTYPE:
279  case MULTILINETYPE:
280  case MULTIPOLYGONTYPE:
281  return asgml2_multi((LWCOLLECTION*)geom, srs, precision, prefix);
282 
283  case COLLECTIONTYPE:
284  return asgml2_collection((LWCOLLECTION*)geom, srs, precision, prefix);
285 
286  case TRIANGLETYPE:
288  case TINTYPE:
289  lwerror("Cannot convert %s to GML2. Try ST_AsGML(3, <geometry>) to generate GML3.", lwtype_name(type));
290  return NULL;
291 
292  default:
293  lwerror("lwgeom_to_gml2: '%s' geometry type not supported", lwtype_name(type));
294  return NULL;
295  }
296 }
static uint8_t precision
Definition: cu_in_twkb.c:25
#define COLLECTIONTYPE
Definition: liblwgeom.h:123
#define MULTILINETYPE
Definition: liblwgeom.h:121
#define LINETYPE
Definition: liblwgeom.h:118
#define MULTIPOINTTYPE
Definition: liblwgeom.h:120
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:117
#define TINTYPE
Definition: liblwgeom.h:131
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:122
#define POLYGONTYPE
Definition: liblwgeom.h:119
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:129
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
#define TRIANGLETYPE
Definition: liblwgeom.h:130
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwinline.h:203
static lwvarlena_t * asgml2_point(const LWPOINT *point, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:331
static lwvarlena_t * asgml2_collection(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:667
static lwvarlena_t * asgml2_line(const LWLINE *line, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:376
static lwvarlena_t * asgml2_multi(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:551
static lwvarlena_t * asgml2_poly(const LWPOLY *poly, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:436
type
Definition: ovdump.py:42
uint8_t type
Definition: liblwgeom.h:477

References asgml2_collection(), asgml2_line(), asgml2_multi(), asgml2_point(), asgml2_poly(), COLLECTIONTYPE, LINETYPE, lwerror(), lwgeom_is_empty(), lwtype_name(), MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, precision, TINTYPE, TRIANGLETYPE, LWGEOM::type, and ovdump::type.

Referenced by do_gml2_test(), do_gml2_test_prefix(), do_gml2_unsupported(), geography_as_gml(), and LWGEOM_asGML().

Here is the call graph for this function:
Here is the caller graph for this function: