mapbox / geosimplify-js

Simplify WGS84 LineStrings using latitude-sensitive thresholds

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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('@mapbox/geosimplify-js');
var coords = [ [ 15.603332, 78.227070 ],
               [ 15.606422, 78.226824 ],
               [ 15.608782, 78.226667 ],
               [ 15.610799, 78.226535 ] ];
var result = geosimplify(coords, 5, 50);

About

Simplify WGS84 LineStrings using latitude-sensitive thresholds

License:Other


Languages

Language:JavaScript 100.0%