Топ-100
 

ST_SIMPLIFY

RDBMS Type: MySQL
Topic

ST_Simplify(g, max_distance)

Simplifies a geometry using the Douglas-Peucker algorithm and returns a
simplified value of the same type.

The geometry may be any geometry type, although the Douglas-Peucker
algorithm may not actually process every type. A geometry collection is
processed by giving its components one by one to the simplification
algorithm, and the returned geometries are put into a geometry
collection as result.

The max_distance argument is the distance (in units of the input
coordinates) of a vertex to other segments to be removed. Vertices
within this distance of the simplified linestring are removed.

According to Boost.Geometry, geometries might become invalid as a
result of the simplification process, and the process might create
self-intersections. To check the validity of the result, pass it to
ST_IsValid().

ST_Simplify() handles its arguments as described in the introduction to
this section, with this exception:

o If the max_distance argument is not positive, or is NaN, an
ER_WRONG_ARGUMENTS
(https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference
.html#error_er_wrong_arguments) error occurs.

URL: https://dev.mysql.com/doc/refman/8.0/en/spatial-convenience-functions.html

Example

mysql> SET @g = ST_GeomFromText('LINESTRING(0 0,0 1,1 1,1 2,2 2,2 3,3 3)');
mysql> SELECT ST_AsText(ST_Simplify(@g, 0.5));
+---------------------------------+
| ST_AsText(ST_Simplify(@g, 0.5)) |
+---------------------------------+
| LINESTRING(0 0,0 1,1 1,2 3,3 3) |
+---------------------------------+
mysql> SELECT ST_AsText(ST_Simplify(@g, 1.0));
+---------------------------------+
| ST_AsText(ST_Simplify(@g, 1.0)) |
+---------------------------------+
| LINESTRING(0 0,3 3) |
+---------------------------------+