Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Ruby implementation of the Douglas-Peucker algorithm

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 douglas_peucker.gemspec
README.md

Douglas-Peucker Algorithm

This algorithm simplifies a line by recursively dividing a line and removing points outside of a predefined threshold. Check out the Wikipedia page to read up on it more.

Usage

>> require "douglas_peucker"
=> true
>> line = [[0, 0], [1, 1], [2, 1], [3, 2.5], [4, 4]]
=> [[0, 0], [1, 1], [2, 1], [3, 2.5], [4, 4]]
>> DouglasPeucker::LineSimplifier.new(line).threshold(1).points
=> [[0, 0], [4, 4]]
>> DouglasPeucker::LineSimplifier.new(line).threshold(0.5).points
=> [[0, 0], [2, 1], [4, 4]]
>> DouglasPeucker::LineSimplifier.new(line).points
=> [[0, 0], [1, 1], [2, 1], [4, 4]]

License

See the LICENSE

Author

Written by Josh Clayton, although the algorithm and its various implementations have been written before.

Something went wrong with that request. Please try again.