PostGIS  2.4.9dev-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.

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, TINTYPE, TRIANGLETYPE, ovdump::type, and LWGEOM::type.

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

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 }
#define LINETYPE
Definition: liblwgeom.h:86
static char * asgml2_line(const LWLINE *line, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:350
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define TRIANGLETYPE
Definition: liblwgeom.h:98
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
static char * asgml2_collection(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:648
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define TINTYPE
Definition: liblwgeom.h:99
uint8_t precision
Definition: cu_in_twkb.c:25
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
static char * asgml2_point(const LWPOINT *point, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:303
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:396
type
Definition: ovdump.py:41
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:1346
static char * asgml2_multi(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:529
#define MULTILINETYPE
Definition: liblwgeom.h:89
static char * asgml2_poly(const LWPOLY *poly, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:412
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: