0.1.0 • Published 7 years ago

@mapbox/geosimplify-js v0.1.0

Weekly downloads
-
License
BSD-2-Clause
Repository
github
Last release
7 years ago

geosimplify-js

This module simplifies sequences of longitude,latitude pairs using geography-aware measurement thresholds.

Based on https://github.com/mourner/simplify-js, geosimplify-js fixes the problem that the simple pythagorean measure used in simplify-js changes size if you simply give it longitude/latitude sequences to simplify.

Usage:

simplify([[lon,lat],[lon,lat],[lon,lat]], offsetThresholdInMetres, gapThresholdInMetres);

path - an array of longitude,latitude pairs

offsetThreshold - how far outside the straight line a point needs to be for it to be "kept"

gapThreshold - if removing a point would create a segment longer than this, do not remove it

Example:

var geosimplify = require('geosimplify');
var coords = [ [ 15.603332, 78.227070 ],
               [ 15.606422, 78.226824 ],
               [ 15.608782, 78.226667 ],
               [ 15.610799, 78.226535 ] ];
var result = geosimplify(coords, 5, 50);