Skip to content

Commit ff2b1e9

Browse files
committed
update function docs
1 parent 1877d5a commit ff2b1e9

File tree

2 files changed

+116
-2
lines changed

2 files changed

+116
-2
lines changed

docs/functions.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
| [`ST_Area_Spheroid`](#st_area_spheroid) | Returns the area of a geometry in meters, using an ellipsoidal model of the earth |
1313
| [`ST_AsGeoJSON`](#st_asgeojson) | Returns the geometry as a GeoJSON fragment |
1414
| [`ST_AsHEXWKB`](#st_ashexwkb) | Returns the geometry as a HEXWKB string |
15+
| [`ST_AsMVTGeom`](#st_asmvtgeom) | Transform and clip geometry to a tile boundary |
1516
| [`ST_AsSVG`](#st_assvg) | Convert the geometry into a SVG fragment or path |
1617
| [`ST_AsText`](#st_astext) | Returns the geometry as a WKT string |
1718
| [`ST_AsWKB`](#st_aswkb) | Returns the geometry as a WKB (Well-Known-Binary) blob |
@@ -88,6 +89,7 @@
8889
| [`ST_MakeBox2D`](#st_makebox2d) | Create a BOX2D from two POINT geometries |
8990
| [`ST_MakeEnvelope`](#st_makeenvelope) | Create a rectangular polygon from min/max coordinates |
9091
| [`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. |
9193
| [`ST_MakePolygon`](#st_makepolygon) | Create a POLYGON from a LINESTRING shell |
9294
| [`ST_MakeValid`](#st_makevalid) | Returns a valid representation of the geometry |
9395
| [`ST_MaximumInscribedCircle`](#st_maximuminscribedcircle) | Returns the maximum inscribed circle of the input geometry, optionally with a tolerance. |
@@ -144,6 +146,7 @@
144146

145147
| Function | Summary |
146148
| --- | --- |
149+
| [`ST_AsMVT`](#st_asmvt) | Make a Mapbox Vector Tile from a set of geometries and properties |
147150
| [`ST_CoverageInvalidEdges_Agg`](#st_coverageinvalidedges_agg) | Returns the invalid edges of a coverage geometry |
148151
| [`ST_CoverageSimplify_Agg`](#st_coveragesimplify_agg) | Simplifies a set of geometries while maintaining coverage |
149152
| [`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);
402405

403406
----
404407

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+
405428
### ST_AsSVG
406429

407430

@@ -1937,6 +1960,35 @@ LINESTRING(0 0, 1 1)
19371960

19381961
----
19391962

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+
19401992
### ST_MakePolygon
19411993

19421994

@@ -3015,6 +3067,66 @@ SELECT ST_ZMin(ST_Point(1, 2, 3))
30153067

30163068
## Aggregate Functions
30173069

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+
30183130
### ST_CoverageInvalidEdges_Agg
30193131

30203132

src/spatial/modules/geos/geos_module.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,11 @@ struct ST_AsMVTGeom {
439439
variant.SetBind(Bind);
440440
});
441441

442-
func.SetDescription(R"(Transform and clip geometry to a tile boundary
442+
func.SetDescription(R"(
443+
Transform and clip geometry to a tile boundary
444+
445+
See "ST_AsMVT" for more details)");
443446

444-
- See "ST_AsMVT" for more details)");
445447
func.SetTag("ext", "spatial");
446448
func.SetTag("category", "construction");
447449
});

0 commit comments

Comments
 (0)