PostGIS  2.1.10dev-r@@SVN_REVISION@@
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 211 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, and LWGEOM::type.

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

212 {
213  int type = geom->type;
214 
215  /* Return null for empty (#1377) */
216  if ( lwgeom_is_empty(geom) )
217  return NULL;
218 
219  switch (type)
220  {
221  case POINTTYPE:
222  return asgml2_point((LWPOINT*)geom, srs, precision, prefix);
223 
224  case LINETYPE:
225  return asgml2_line((LWLINE*)geom, srs, precision, prefix);
226 
227  case POLYGONTYPE:
228  return asgml2_poly((LWPOLY*)geom, srs, precision, prefix);
229 
230  case MULTIPOINTTYPE:
231  case MULTILINETYPE:
232  case MULTIPOLYGONTYPE:
233  return asgml2_multi((LWCOLLECTION*)geom, srs, precision, prefix);
234 
235  case COLLECTIONTYPE:
236  return asgml2_collection((LWCOLLECTION*)geom, srs, precision, prefix);
237 
238  case TRIANGLETYPE:
240  case TINTYPE:
241  lwerror("Cannot convert %s to GML2. Try ST_AsGML(3, <geometry>) to generate GML3.", lwtype_name(type));
242  return NULL;
243 
244  default:
245  lwerror("lwgeom_to_gml2: '%s' geometry type not supported", lwtype_name(type));
246  return NULL;
247  }
248 }
#define LINETYPE
Definition: liblwgeom.h:61
static char * asgml2_line(const LWLINE *line, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:328
#define POLYGONTYPE
Definition: liblwgeom.h:62
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
#define TRIANGLETYPE
Definition: liblwgeom.h:73
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:72
static char * asgml2_collection(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:623
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:164
#define TINTYPE
Definition: liblwgeom.h:74
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:65
static char * asgml2_point(const LWPOINT *point, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:282
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
uint8_t type
Definition: liblwgeom.h:352
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:1229
static char * asgml2_multi(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:505
#define MULTILINETYPE
Definition: liblwgeom.h:64
static char * asgml2_poly(const LWPOLY *poly, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:389
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function:

Here is the caller graph for this function: