Spatial construction functions
Spatial construction functions are used to create new spatial data types and geometries.
seekdb currently supports the _ST_MakeEnvelope spatial construction function.
_ST_MakeEnvelope
The _ST_MakeEnvelope function creates a rectangle by specifying the coordinates of the lower-left and upper-right corners. This rectangle is commonly used as a bounding box for spatial queries.
Syntax:
_ST_MakeEnvelope(float xmin, float ymin, float xmax, float ymax, integer srid=unknown)
Parameter description:
float xmin: the x-coordinate of the lower-left corner of the rectangle (usually longitude).float ymin: the y-coordinate of the lower-left corner of the rectangle (usually latitude).float xmax: the x-coordinate of the upper-right corner of the rectangle (usually longitude).float ymax: the y-coordinate of the upper-right corner of the rectangle (usually latitude).integer srid: the identifier of the spatial reference system (Spatial Reference System Identifier). It is a valid identifier used to specify the spatial reference system for the coordinates. The default value unknown indicates that no spatial reference system is specified.
Usage limitations:
- The coordinate values must be valid.
xminmust be less thanxmax, andyminmust be less thanymaxto form a valid rectangle.
Example 1:
SELECT ST_AsText(_ST_MakeEnvelope(10, 10, 11, 11, 4326));
In this example, a rectangle with the lower-left corner at (10, 10) and the upper-right corner at (11, 11) is created.
The returned result is as follows:
+-----------------------------------------------------+
| ST_AsText( _ST_MakeEnvelope(10, 10, 11, 11, 4326) ) |
+-----------------------------------------------------+
| POLYGON((10 10,11 10,11 11,10 11,10 10)) |
+-----------------------------------------------------+
1 row in set (0.001 sec)
Example 2:
SELECT ST_ASTEXT(_ST_ClipByBox2D(ST_GEOMFROMTEXT('POLYGON((-2 -2, -2 11, 11 11, 11 -2, -2 -2))'), _ST_MakeEnvelope(0,0,10,10)));
In this example, a rectangle with the lower-left corner at (0, 0) and the upper-right corner at (10, 10) is created as the clipping area. Then, the _ST_ClipByBox2D function is used to clip the original polygon POLYGON((-2 -2, -2 11, 11 11, 11 -2, -2 -2)) with the rectangle.
The returned result is as follows:
+--------------------------------------------------------------------------------------------------------------------------+
| ST_ASTEXT(_ST_ClipByBox2D(ST_GEOMFROMTEXT('POLYGON((-2 -2, -2 11, 11 11, 11 -2, -2 -2))'), _ST_MakeEnvelope(0,0,10,10))) |
+--------------------------------------------------------------------------------------------------------------------------+
| POLYGON((0 0,0 10,10 10,10 0,0 0)) |
+--------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.001 sec)