定制 emcconville/polyline-encoder 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

emcconville/polyline-encoder

最新稳定版本:v1.1.1

Composer 安装命令:

composer require emcconville/polyline-encoder

包简介

PHP Traits algorithms for Encoded Polyline & Bing Point Compression

README 文档

README

Build Status Latest Stable Version License

Formerly emcconville/google-map-polyline-encoding-tool, this library provides encoding/decoding methods for Google Map's Encoded Polyline, and Microsoft's Point Compression Algorithm. The intent of the Polyline Encoder library is to shift the core algorithms to PHP Traits over traditional class implementations.

Installation

Add emcconville/polyline-encoder to composer's required list.

{
  "require" : {
    "emcconville/polyline-encoder" : "1.*"
  }
}

Follow basic composer installation & guide.

curl -sS https://getcomposer.org/installer | php
./composer.phar install

Usage

Both BingTrait & GoogleTrait cover the same two methods.

string <object>::encodePoints( array $points )

// Convert list of points into encoded string.
$points = [
  [41.89084,-87.62386],
  [41.89086,-87.62279],
  [41.89028,-87.62277],
  [41.89028,-87.62385],
  [41.89084,-87.62386]
];

$googleObject->encodePoints($points); //=> "wxt~Fd`yuOCuErBC?vEoB@"
$bingObject->encodePoints($points);   //=> "yg7qol5jxJjqX3iH01W5sG"

array <object>::decodeString( string $string )

// Restore list from encode string.
$points = $googleObject->decodeString("wxt~Fd`yuOCuErBC?vEoB@");
$points[3]; //=> array(41.89028,-87.62385)
$points = $bingObject->decodeString("yg7qol5jxJjqX3iH01W5sG");
$points[4]; //=> array(41.89084,-87.62386)

Goolge Map

// Apply Google Trait.
class MyGooglePolyline
{
  use emcconville\Polyline\GoogleTrait;
}

Bing Map

// Apply Bing Trait.
class MyBingPolyline
{
  use emcconville\Polyline\BingTrait;
}

OSRM Map

// Apply Google Trait with precision overwrite.
class MyProjectOsrmPolyline
{
  use emcconville\Polyline\GoogleTrait;
  
  /**
   * Implement precision method in sub-class.
   * @return int
   */
  public function polylinePrecision()
  {
      return 6;
  }
}

统计信息

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

GitHub 信息

  • Stars: 30
  • Watchers: 4
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: GNU
  • 更新时间: 2014-03-22