This topic describes the ST_AsGML function. This function returns the Geography Markup Language (GML) element that represents a geometry object or a geography object.
Syntax
text ST_AsGML(geometry geom , integer maxdecimaldigits , integer options);
text ST_AsGML(geography geog , integer maxdecimaldigits , integer options);
text ST_AsGML(integer version , geometry geom , integer maxdecimaldigits , integer options , text nprefix, text id);
text ST_AsGML(integer version , geography geog , integer maxdecimaldigits , integer options , text nprefix, text id);
Parameters
Parameter | Description |
---|
Parameter | Description |
---|---|
geom | The geometry object whose GML representation you want to obtain. |
maxdecimaldigits | The maximum number of decimal places that you want to retain. Default value: 15. |
options | The type of coordinate reference system (CRS) information that you want to return
in the GML element. Valid values:
|
geog | The geography object whose GML representation you want to obtain. |
version | The GML version that you want to use. The default value 2 specifies GML version 2.1.2. You can set this parameter to 3, which specifies GML version 3.1.1. |
nprefix | The prefix of the namespace. Default value: NULL. You can specify a custom prefix. |
id | The ID of the GML element. Default value: NULL. This parameter is valid only when GML version 3 is used. |
Description
- This function supports circular strings, curves, polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.
- This function supports polyhedral surfaces and TIN surfaces only when GML version 3 or a later version is used.
Examples
Obtain a GML element that contains the CRS in a long expression, the bounding box,
and the coordinates in which the latitude precedes the longitude.
SELECT ST_AsGML(3, ST_GeomFromText('POINT(116 40)',4326), 5, 32|16|1);
st_asgml
---------------------------------------------------------------
<gml:Envelope srsName="urn:ogc:def:crs:EPSG::4326" srsDimension="2">
<gml:lowerCorner>40 116</gml:lowerCorner>
<gml:upperCorner>40 116</gml:upperCorner>
</gml:Envelope>
(1 row)