david-r-edgar/rdp 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

david-r-edgar/rdp

最新稳定版本:0.0.1

Composer 安装命令:

composer require david-r-edgar/rdp

包简介

Ramer–Douglas–Peucker algorithm for polyline simplification

README 文档

README

PHP implementation of the Ramer–Douglas–Peucker algorithm for polyline simplification.

License: Public Domain

Example simplified polyline

Example polyline before and after simplification

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:

$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.

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.

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.

统计信息

  • 总下载量: 31.41k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 23
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 23
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: Public
  • 更新时间: 2016-05-02