PostGIS  2.2.8dev-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 218 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().

219 {
220  int type = geom->type;
221 
222  /* Return null for empty (#1377) */
223  if ( lwgeom_is_empty(geom) )
224  return NULL;
225 
226  switch (type)
227  {
228  case POINTTYPE:
229  return asgml2_point((LWPOINT*)geom, srs, precision, prefix);
230 
231  case LINETYPE:
232  return asgml2_line((LWLINE*)geom, srs, precision, prefix);
233 
234  case POLYGONTYPE:
235  return asgml2_poly((LWPOLY*)geom, srs, precision, prefix);
236 
237  case MULTIPOINTTYPE:
238  case MULTILINETYPE:
239  case MULTIPOLYGONTYPE:
240  return asgml2_multi((LWCOLLECTION*)geom, srs, precision, prefix);
241 
242  case COLLECTIONTYPE:
243  return asgml2_collection((LWCOLLECTION*)geom, srs, precision, prefix);
244 
245  case TRIANGLETYPE:
247  case TINTYPE:
248  lwerror("Cannot convert %s to GML2. Try ST_AsGML(3, <geometry>) to generate GML3.", lwtype_name(type));
249  return NULL;
250 
251  default:
252  lwerror("lwgeom_to_gml2: '%s' geometry type not supported", lwtype_name(type));
253  return NULL;
254  }
255 }
#define LINETYPE
Definition: liblwgeom.h:71
static char * asgml2_line(const LWLINE *line, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:337
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
#define TRIANGLETYPE
Definition: liblwgeom.h:83
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:82
static char * asgml2_collection(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:635
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
#define TINTYPE
Definition: liblwgeom.h:84
uint8_t precision
Definition: cu_in_twkb.c:25
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
static char * asgml2_point(const LWPOINT *point, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:290
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
uint8_t type
Definition: liblwgeom.h:380
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:1297
static char * asgml2_multi(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:516
#define MULTILINETYPE
Definition: liblwgeom.h:74
static char * asgml2_poly(const LWPOLY *poly, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:399
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
#define COLLECTIONTYPE
Definition: liblwgeom.h:76
Here is the call graph for this function:
Here is the caller graph for this function: