|
12 | 12 | | [`ST_Area_Spheroid`](#st_area_spheroid) | Returns the area of a geometry in meters, using an ellipsoidal model of the earth | |
13 | 13 | | [`ST_AsGeoJSON`](#st_asgeojson) | Returns the geometry as a GeoJSON fragment | |
14 | 14 | | [`ST_AsHEXWKB`](#st_ashexwkb) | Returns the geometry as a HEXWKB string | |
| 15 | +| [`ST_AsMVTGeom`](#st_asmvtgeom) | Transform and clip geometry to a tile boundary | |
15 | 16 | | [`ST_AsSVG`](#st_assvg) | Convert the geometry into a SVG fragment or path | |
16 | 17 | | [`ST_AsText`](#st_astext) | Returns the geometry as a WKT string | |
17 | 18 | | [`ST_AsWKB`](#st_aswkb) | Returns the geometry as a WKB (Well-Known-Binary) blob | |
|
88 | 89 | | [`ST_MakeBox2D`](#st_makebox2d) | Create a BOX2D from two POINT geometries | |
89 | 90 | | [`ST_MakeEnvelope`](#st_makeenvelope) | Create a rectangular polygon from min/max coordinates | |
90 | 91 | | [`ST_MakeLine`](#st_makeline) | Create a LINESTRING from a list of POINT geometries | |
| 92 | +| [`ST_MakePoint`](#st_makepoint) | Creates a GEOMETRY point from an pair of floating point numbers. | |
91 | 93 | | [`ST_MakePolygon`](#st_makepolygon) | Create a POLYGON from a LINESTRING shell | |
92 | 94 | | [`ST_MakeValid`](#st_makevalid) | Returns a valid representation of the geometry | |
93 | 95 | | [`ST_MaximumInscribedCircle`](#st_maximuminscribedcircle) | Returns the maximum inscribed circle of the input geometry, optionally with a tolerance. | |
|
144 | 146 |
|
145 | 147 | | Function | Summary | |
146 | 148 | | --- | --- | |
| 149 | +| [`ST_AsMVT`](#st_asmvt) | Make a Mapbox Vector Tile from a set of geometries and properties | |
147 | 150 | | [`ST_CoverageInvalidEdges_Agg`](#st_coverageinvalidedges_agg) | Returns the invalid edges of a coverage geometry | |
148 | 151 | | [`ST_CoverageSimplify_Agg`](#st_coveragesimplify_agg) | Simplifies a set of geometries while maintaining coverage | |
149 | 152 | | [`ST_CoverageUnion_Agg`](#st_coverageunion_agg) | Unions a set of geometries while maintaining coverage | |
@@ -402,6 +405,26 @@ SELECT ST_AsHexWKB('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'::geometry); |
402 | 405 |
|
403 | 406 | ---- |
404 | 407 |
|
| 408 | +### ST_AsMVTGeom |
| 409 | + |
| 410 | + |
| 411 | +#### Signatures |
| 412 | + |
| 413 | +```sql |
| 414 | +GEOMETRY ST_AsMVTGeom (geom GEOMETRY, bounds BOX_2D, extent BIGINT, buffer BIGINT, clip_geom BOOLEAN) |
| 415 | +GEOMETRY ST_AsMVTGeom (geom GEOMETRY, bounds BOX_2D, extent BIGINT, buffer BIGINT) |
| 416 | +GEOMETRY ST_AsMVTGeom (geom GEOMETRY, bounds BOX_2D, extent BIGINT) |
| 417 | +GEOMETRY ST_AsMVTGeom (geom GEOMETRY, bounds BOX_2D) |
| 418 | +``` |
| 419 | + |
| 420 | +#### Description |
| 421 | + |
| 422 | +Transform and clip geometry to a tile boundary |
| 423 | + |
| 424 | +See "ST_AsMVT" for more details |
| 425 | + |
| 426 | +---- |
| 427 | + |
405 | 428 | ### ST_AsSVG |
406 | 429 |
|
407 | 430 |
|
@@ -1937,6 +1960,35 @@ LINESTRING(0 0, 1 1) |
1937 | 1960 |
|
1938 | 1961 | ---- |
1939 | 1962 |
|
| 1963 | +### ST_MakePoint |
| 1964 | + |
| 1965 | + |
| 1966 | +#### Signatures |
| 1967 | + |
| 1968 | +```sql |
| 1969 | +POINT_2D ST_MakePoint (x DOUBLE, y DOUBLE) |
| 1970 | +POINT_3D ST_MakePoint (x DOUBLE, y DOUBLE, z DOUBLE) |
| 1971 | +POINT_4D ST_MakePoint (x DOUBLE, y DOUBLE, z DOUBLE, m DOUBLE) |
| 1972 | +``` |
| 1973 | + |
| 1974 | +#### Description |
| 1975 | + |
| 1976 | +Creates a GEOMETRY point from an pair of floating point numbers. |
| 1977 | + |
| 1978 | +For geodetic coordinate systems, x is typically the longitude value and y is the latitude value. |
| 1979 | + |
| 1980 | +Note that ST_Point is equivalent. ST_MakePoint is provided for PostGIS compatibility. |
| 1981 | + |
| 1982 | +#### Example |
| 1983 | + |
| 1984 | +```sql |
| 1985 | +SELECT ST_AsText(ST_MakePoint(143.3, -24.2)); |
| 1986 | +---- |
| 1987 | +POINT (143.3 -24.2) |
| 1988 | +``` |
| 1989 | + |
| 1990 | +---- |
| 1991 | + |
1940 | 1992 | ### ST_MakePolygon |
1941 | 1993 |
|
1942 | 1994 |
|
@@ -3015,6 +3067,66 @@ SELECT ST_ZMin(ST_Point(1, 2, 3)) |
3015 | 3067 |
|
3016 | 3068 | ## Aggregate Functions |
3017 | 3069 |
|
| 3070 | +### ST_AsMVT |
| 3071 | + |
| 3072 | + |
| 3073 | +#### Signatures |
| 3074 | + |
| 3075 | +```sql |
| 3076 | +BLOB ST_AsMVT (col0 ANY) |
| 3077 | +BLOB ST_AsMVT (col0 ANY, col1 VARCHAR) |
| 3078 | +BLOB ST_AsMVT (col0 ANY, col1 VARCHAR, col2 INTEGER) |
| 3079 | +BLOB ST_AsMVT (col0 ANY, col1 VARCHAR, col2 INTEGER, col3 VARCHAR) |
| 3080 | +BLOB ST_AsMVT (col0 ANY, col1 VARCHAR, col2 INTEGER, col3 VARCHAR, col4 VARCHAR) |
| 3081 | +``` |
| 3082 | + |
| 3083 | +#### Description |
| 3084 | + |
| 3085 | +Make a Mapbox Vector Tile from a set of geometries and properties |
| 3086 | +The function takes as input a row type (STRUCT) containing a geometry column and any number of property columns. |
| 3087 | +It returns a single binary BLOB containing the Mapbox Vector Tile. |
| 3088 | + |
| 3089 | +The function has the following signature: |
| 3090 | + |
| 3091 | +`ST_AsMVT(row STRUCT, layer_name VARCHAR DEFAULT 'layer', extent INTEGER DEFAULT 4096, geom_column_name VARCHAR DEFAULT NULL, feature_id_column_name VARCHAR DEFAULT NULL) -> BLOB` |
| 3092 | + |
| 3093 | +- The first argument is a struct containing the geometry and properties. |
| 3094 | +- The second argument is the name of the layer in the vector tile. This argument is optional and defaults to 'layer'. |
| 3095 | +- The third argument is the extent of the tile. This argument is optional and defaults to 4096. |
| 3096 | +- The fourth argument is the name of the geometry column in the input row. This argument is optional. If not provided, the first geometry column in the input row will be used. If multiple geometry columns are present, an error will be raised. |
| 3097 | +- The fifth argument is the name of the feature id column in the input row. This argument is optional. If provided, the values in this column will be used as feature ids in the vector tile. The column must be of type INTEGER or BIGINT. If set to negative or NULL, a feature id will not be assigned to the corresponding feature. |
| 3098 | + |
| 3099 | +The input struct must contain exactly one geometry column of type GEOMETRY. It can contain any number of property columns of types VARCHAR, FLOAT, DOUBLE, INTEGER, BIGINT, or BOOLEAN. |
| 3100 | + |
| 3101 | +Example: |
| 3102 | +```sql |
| 3103 | +SELECT ST_AsMVT({'geom': geom, 'id': id, 'name': name}, 'cities', 4096, 'geom', 'id') AS tile |
| 3104 | +FROM cities; |
| 3105 | + ``` |
| 3106 | + |
| 3107 | +This example creates a vector tile named 'cities' with an extent of 4096 from the 'cities' table, using 'geom' as the geometry column and 'id' as the feature id column. |
| 3108 | + |
| 3109 | +However, you probably want to use the ST_AsMVTGeom function to first transform and clip your geometries to the tile extent. |
| 3110 | +The following example assumes the geometry is in WebMercator ("EPSG:3857") coordinates. |
| 3111 | +Replace `{z}`, `{x}`, and `{y}` with the appropriate tile coordinates, `{your table}` with your table name, and `{tile_path}` with the path to write the tile to. |
| 3112 | + |
| 3113 | +```sql |
| 3114 | +COPY ( |
| 3115 | + SELECT ST_AsMVT({{ |
| 3116 | + "geometry": ST_AsMVTGeom( |
| 3117 | + geometry, |
| 3118 | + ST_Extent(ST_TileEnvelope({z}, {x}, {y})), |
| 3119 | + 4096, |
| 3120 | + 256, |
| 3121 | + false |
| 3122 | + ) |
| 3123 | + }}) |
| 3124 | + FROM {your table} WHERE ST_Intersects(geometry, ST_TileEnvelope({z}, {x}, {y})) |
| 3125 | +) to {tile_path} (FORMAT 'BLOB'); |
| 3126 | +``` |
| 3127 | + |
| 3128 | +---- |
| 3129 | + |
3018 | 3130 | ### ST_CoverageInvalidEdges_Agg |
3019 | 3131 |
|
3020 | 3132 |
|
|
0 commit comments