-- This example demonstrates how to use the SE_Generalize function
-- to remove unnecessary vertices from a geometry.  This process is
-- also known as "thinning".  It can be used to clean up data, and
-- it can also be used to reduce amount of data transmitted from the
-- server to a client application which draws geometries.

CREATE TABLE jagged_lines(line ST_LineString);

INSERT INTO jagged_lines VALUES(
   "0 linestring(10 10, 20 20, 20 18, 30 30, 30 28, 40 40)"
);

-- Small threshold; no vertices removed:
SELECT SE_Generalize(line, 0.5) FROM jagged_lines;

-- Larger threshold; some vertices removed:
SELECT SE_Generalize(line, 2) FROM jagged_lines;

