PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwgeom_to_gml2()

char* 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 231 of file lwout_gml.c.

232 {
233  int type = geom->type;
234 
235  /* Return null for empty (#1377) */
236  if ( lwgeom_is_empty(geom) )
237  return NULL;
238 
239  switch (type)
240  {
241  case POINTTYPE:
242  return asgml2_point((LWPOINT*)geom, srs, precision, prefix);
243 
244  case LINETYPE:
245  return asgml2_line((LWLINE*)geom, srs, precision, prefix);
246 
247  case POLYGONTYPE:
248  return asgml2_poly((LWPOLY*)geom, srs, precision, prefix);
249 
250  case MULTIPOINTTYPE:
251  case MULTILINETYPE:
252  case MULTIPOLYGONTYPE:
253  return asgml2_multi((LWCOLLECTION*)geom, srs, precision, prefix);
254 
255  case COLLECTIONTYPE:
256  return asgml2_collection((LWCOLLECTION*)geom, srs, precision, prefix);
257 
258  case TRIANGLETYPE:
260  case TINTYPE:
261  lwerror("Cannot convert %s to GML2. Try ST_AsGML(3, <geometry>) to generate GML3.", lwtype_name(type));
262  return NULL;
263 
264  default:
265  lwerror("lwgeom_to_gml2: '%s' geometry type not supported", lwtype_name(type));
266  return NULL;
267  }
268 }
static uint8_t precision
Definition: cu_in_twkb.c:25
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define TINTYPE
Definition: liblwgeom.h:99
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwgeom.c:1393
#define TRIANGLETYPE
Definition: liblwgeom.h:98
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
static char * asgml2_collection(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:648
static char * asgml2_line(const LWLINE *line, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:350
static char * asgml2_point(const LWPOINT *point, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:303
static char * asgml2_multi(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:529
static char * asgml2_poly(const LWPOLY *poly, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:412
type
Definition: ovdump.py:41
uint8_t type
Definition: liblwgeom.h:399

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: