All Products
Search
Document Center

ApsaraDB RDS:ST_AsMVT3D

Last Updated:Jun 28, 2023

This topic describes the ST_AsMVT3D function. This function returns the binary representation of mvtgeom data in the Mapbox Vector Tile (MVT) format.

Syntax

  • Syntax 1

    bytea ST_AsMVT3D(anyelement set row);
  • Syntax 2

    bytea ST_AsMVT3D(anyelement row, text name);
  • Syntax 3

    bytea ST_AsMVT3D(anyelement row, text name, integer extent);
  • Syntax 4

    bytea ST_AsMVT3D(anyelement row, text name, integer extent, text geom_name);
  • Syntax 5

    bytea ST_AsMVT3D(anyelement row, text name, integer extent, text geom_name, text feature_id_name);

Parameters

Parameter

Description

row

The row that contains at least one 3D geometry column.

name

The name of the layer. Default value: Default.

extent

The number of tiles in screen space.

Valid values: 256 to 8192. Default value: 4096.

geom_name

The name of the geometry column in the row. By default, the name of the first geometry column is used.

feature_id_name

The name of the Feature ID column in the row.

If this parameter is set to NULL or a negative value, ignore the Feature ID column.

Description

  • This function is an aggregate function returns the binary representation of MVT format.

  • The row must contain a geometry column that needs to be encoded as a spatial feature of the geometric attribute.

  • The ST_AsMVTGeom3D function can be called to represent 3D geometries in the title coordinate system and encode other rows and columns as spatial features of non-geometric attributes.

  • You can create a vector tile with multiple layers by using || or STRING_AGG. Example: SELECT ST_AsMVT3D() || ST_AsMVT3D() AS tile;.

The following list describes the encoding methods on the z-axis:

  1. CommandID encoding: MoveTo3D(5)\LineTo3D(6) XYZXYZ... to encode 3D graphics is supported.

  2. Numerical calculation on the z-axis: Numeric value = 7 × (z + 450). The valid values range from -450 to 8848.

Note

For more information, see vector-tile-spec.

The following figure shows the large-scale 3D scenarios by using the 3D MVT tile technology.

image..png

Examples

WITH mvtgeom AS
(
  SELECT ST_AsMVTGeom3D(
    ST_Transform('SRID=4326; MULTIPOLYGON(((100 50 0, -100 50 1, -100 -50 2, 100 -50 3, 100 50 0)), ((0 0 0, 1 0 1, 2 2 2, 0 0 0)))'::geometry, 3857),
    ST_TileEnvelope(1, 0, 0)) AS geom,  'test' AS name
)
SELECT ST_AsMVT3D(mvtgeom.*) FROM mvtgeom;
                                                                                                                     st_asmvt3d                                                                                                                     
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 \x1a760a0764656661756c74125812020000180322500d8044a842b83116ff23d80105802400080f0d810481041d162e000e2e590e0f0dd920dc0405168024d70106c727f3160d0f0dc827f4160e1600f31615c72700080f0d0000001600cc1808c80300000f1a046e616d6522060a04746573742880207802
(1 row)