Returns the Extensible 3D (X3D) XML representation of a geometry object as a text string.
Syntax
text ST_AsX3D(geometry g1, integer maxdecimaldigits, integer options)Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
g1 | geometry | The geometry object to convert. | — |
maxdecimaldigits | integer | The maximum number of decimal places in the output coordinates. | 15 |
options | integer | Specifies whether to represent coordinates with the X3D GeoCoordinates Geospatial node and whether to flip the x and y coordinates. See Options for details. | 0 |
Options
| Value | Behavior |
|---|---|
0 | Returns coordinates in database order (x, y). Default. |
1 | Flips x and y coordinates. When combined with the GeoCoordinates flag (2), applies latitude_first ordering. |
2 | Wraps coordinates in a GeoSpatial GeoCoordinates node. The geometry must use WGS 84 (SRID 4326); other SRIDs cause an error. This is the only GeoCoordinate type that is supported. Specify a spatial reference system based on the X3D specification. Output: GeoCoordinate geoSystem='"GD" "WE" "longitude_first"'. |
3 | Outputs GeoCoordinate geoSystem='"GD" "WE" "latitude_first"'. |
Supported geometry types
ST_AsX3D supports circular strings, curves, polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.
Examples
Convert a polygon to X3D
SELECT ST_AsX3D(ST_GeomFromEWKT('POLYGON((1 1 0,1 2 0,2 2 0,2 1 0,1 1 0))'));Output:
st_asx3d
---------------------------------------------------------------
<IndexedFaceSet convex='false' coordIndex='0 1 2 3'>
<Coordinate point='1 1 0 1 2 0 2 2 0 2 1 0 ' />
</IndexedFaceSet>
(1 row)该文章对您有帮助吗?