public class ST_Simplify
extends GenericUDF
Generates a new ST_Geometry object by simplifying the input geometry using the Douglas-Peucker algorithm.
Format:
ST_Simplify(geometry ST_Geometry, threshold NUMBER) - return a new ST_Geometry object by simplifying the input geometry using the Douglas-Peucker Algorithm
This method takes a threshold as the input.
Depending on the threshold value, a polygon can simplify into a line or a point.
A line can simplify into a point. So the output should be checked for type as the type may by different from the input geometry type.
Example:
select ST_Simplify(
ST_Polygon('{"type": "Polygon","coordinates": [[[1, 2], [1.01, 2.01], [5, 2], [5, 6], [1, 6], [1, 2]]]}', 8307)
, 1) from hivetable LIMIT 1; -- return {"type":"Polygon", "coordinates":[[[1,2],[5,2],[5,6],[1,6],[1,2]]],"crs":{"type":"name","properties":{"name":"EPSG:8307"}}}