This topic describes the ST_AsX3D function. This function returns the Extensible 3D (X3D) string that represents a geometry object.

Syntax

text  ST_AsX3D(geometry  g1 , integer  maxdecimaldigits , integer  options);

Parameters

ParameterDescription
Parameter Description
g1 The geometry object whose X3D representation you want to obtain.
maxdecimaldigits The maximum number of decimal places that you want to retain. Default value: 15.
options Specifies whether to represent coordinates with the X3D GeoCoordinates Geospatial node and whether to flip the x and y coordinates. Default value: 0
  • 0: specifies to return the x and y coordinates in the order that is used in the database.
  • 1: specifies to flip the x and y coordinates. By default, if you use this option in conjunction with the GeoCoordinate option, the default setting "latitude_first" is used and the x and y coordinates are flipped.
  • 2: specifies to return the x and y coordinates in the order that is used in GeoSpatial GeoCoordinates. If the geometry object is not in the WGS 84 coordinate system that contains a spatial reference identifier (SRID) of 4326, this option causes errors. This is the only GeoCoordinate type that is supported. Specify a spatial reference system based on the X3D specification. The default output that is returned is GeoCoordinate geoSystem='"GD" "WE" "longitude_first"'.
  • 3: specifies to return the X3D string based on the following default settings: GeoCoordinate geoSystem='"GD" "WE" "latitude_first"'.

Description

This function supports circular strings, curves, polyhedral surfaces, triangles, triangulated irregular network (TIN) surfaces, and 3D objects.

Examples

select ST_AsX3D( ST_GeomFromEWKT('POLYGON((1 1 0,1 2 0,2 2 0,2 1 0,1 1 0))'));
                           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)