Skip to main content

simplify

Removes vertices that lie within tolerance metres of the line that would replace them (the Douglas-Peucker method), keeping every end point and every ring closed. Points and multipoints come back unchanged. Collections are simplified member by member, and the input is not changed. A shape with no area or length to simplify, such as a polygon whose corners lie on one line, comes back as it is.

This is a function exported by @mapcairn/core, checked against version 0.2.0.

Signature​

import { simplify } from "@mapcairn/core";

function simplify(input: GeometryInput, tolerance: number): Geometry;

Description​

The tolerance is a distance on the ground, the same east-west and north-south, taken at each shape's middle latitude. Near a pole it is only approximate.

Parameters​

  • input (GeometryInput)
  • tolerance (number): Metres, finite and not negative. 0 returns a copy.

Returns​

Geometry

Throws​

  • GeometryError of kind invalid for a malformed geometry or a bad tolerance, empty for a geometry with no positions.

See also​

Source: packages/core/src/geometry/operations.ts:280