2017 © Pedro PelĂĄez
 

library rdp

Ramer–Douglas–Peucker algorithm for polyline simplification

image

david-r-edgar/rdp

Ramer–Douglas–Peucker algorithm for polyline simplification

  • Friday, January 26, 2018
  • by david-r-edgar
  • Repository
  • 1 Watchers
  • 4 Stars
  • 120 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 22 % Grown

The README.md

RDP-PHP

PHP implementation of the Ramer–Douglas–Peucker algorithm for polyline simplification., (*1)

License: Public Domain, (*2)

Example simplified polyline

Example polyline before and after simplification, (*3)

Installation

composer require david-r-edgar/rdp

Example usage

use davidredgar\polyline\RDP;

$line = array(
    array(150, 10),
    array(200, 100),
    array(360, 170),
    array(500, 280));

$rdpResult = RDP::RamerDouglasPeucker2d($line, 30);

$rdpResult will contain a resulting array with the reduced number of points. For this example:, (*4)

$rdpResult == array(
    array(150, 10),
    array(200, 100),
    array(500, 280));

The second parameter to RamerDouglasPeucker2d() is epsilon, the maximum perpendicular distance for any point from the line between two adjacent points. Try replacing it with, say, 10 or 50 and observe the results., (*5)

Use for geographic purposes

I originally implemented this in order to simplify a complex route on a map. Because I was doing this in Great Britain with OSGB36 coordinates, this worked., (*6)

However, be careful if you want to want to attempt this with other coordinate systems. The algorithm assumes cartesian coordinates on a 2D plane. Attempting to use latitudes and longitudes on the surface of a sphere will result in incorrect results. For approximate polyline simplification, the results may still be acceptable. As you approach the poles, errors will become more and more apparent: put simply, the degrees of longitude will become much closer to one another than the degrees of latitude, and so incorrect points will be chosen to be removed from the polyline., (*7)

The Versions

26/01 2018

dev-3d

dev-3d https://github.com/david-r-edgar/RDP-PHP

Ramer–Douglas–Peucker algorithm for polyline simplification

  Sources   Download

Unlicense public domain

The Requires

 

geo polyline ramer-douglas-peucker ramer douglas peucker

26/01 2018

dev-master

9999999-dev https://github.com/david-r-edgar/RDP-PHP

Ramer–Douglas–Peucker algorithm for polyline simplification

  Sources   Download

Unlicense public domain

The Requires

 

geo polyline ramer-douglas-peucker ramer douglas peucker

02/05 2016

0.0.1

0.0.1.0 https://github.com/david-r-edgar/RDP-PHP

Ramer–Douglas–Peucker algorithm for polyline simplification

  Sources   Download

public domain

The Requires

  • php >=5.3.0

 

geo polyline ramer-douglas-peucker ramer douglas peucker