Download the PHP package emcconville/point-reduction-algorithms without Composer
On this page you can find all versions of the php package emcconville/point-reduction-algorithms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download emcconville/point-reduction-algorithms
More information about emcconville/point-reduction-algorithms
Files in emcconville/point-reduction-algorithms
Package point-reduction-algorithms
Short Description A collection of algorithms for reducing the number of points in polyline
License GNU
Informations about the package point-reduction-algorithms
Point Reduction Algorithms
A collection of algorithms for reducing the number of points in polygon / polyline.
Custom shapes, polygon & polyline in web-map applications, can have too many points. Often a shape will be rendered at a distant zoom-level, and wouldn't require such high-resolution. This library's goal is to provided basic methods to simplify & reduce shapes.
Install
With composer.
$ curl -sS https://getcomposer.org/installer | php
$ cat > composer.json <<EOF
{
"require": {
"emcconville/point-reduction-algorithms" : "~1.0"
}
}
EOF
$ php composer.phar install
Algorithms & Usage
Below is an original, uncompressed, polyline with 2151 points, and is delivered as SVG weighing in @ 175K.
All algorithms share a common abstraction, but each class implements a unique reduce method. Most reduction methods require one argument for tolerance / threshold; except, Visvalingam–Whyatt requires the desired final point count, and Opheim requires two independent thresholds.
Example Pseudo code:
The $myPoints must be an array, or traversable object that supports removing element at index. Each user defined point must implement PointReduction\Common\PointInterface which enforces a getCoordinates method. This common interface allows user objects to have any type of property (ie. x/y, latitude/longitude, left/top).
Ramer–Douglas–Peucker
The original polygon of 2151 points has been reduced to 343.
Visvalingam–Whyatt
The original polygon of 2151 points has been reduced to 343.
Reumann–Witkam
The original polygon of 2151 points has been reduced to 872.
Opheim
The original polygon of 2151 points has been reduced to 684.
Lang
The original polygon of 2151 points has been reduced to 293.
Zhao-Saalfeld
Added in version 1.2.0
.
The original polygon of 2151 points has been reduced to 1493.
Radial Distance
Added in version 1.2.0
.
The original polygon of 2151 points has been reduced to 449.