2017 © Pedro Peláez
 

library polyline-encoder

PHP Traits algorithms for Encoded Polyline & Bing Point Compression

image

emcconville/polyline-encoder

PHP Traits algorithms for Encoded Polyline & Bing Point Compression

  • Saturday, January 3, 2015
  • by emcconville
  • Repository
  • 3 Watchers
  • 18 Stars
  • 29,405 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 10 % Grown

The README.md

Polyline Encoder

Build Status Latest Stable Version License, (*1)

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., (*2)

Installation

Add emcconville/polyline-encoder to composer's required list., (*3)

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

Follow basic composer installation & guide., (*4)

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

Usage

Both BingTrait & GoogleTrait cover the same two methods., (*5)

string <object>::encodePoints( array $points ), (*6)

// 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 ), (*7)

// 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;
  }
}

The Versions

03/01 2015

dev-master

9999999-dev

PHP Traits algorithms for Encoded Polyline & Bing Point Compression

  Sources   Download

GNU

The Requires

  • php >=5.4

 

The Development Requires

by Eric McConville

google maps compression bing point polyline

08/08 2014

v1.1.1

1.1.1.0

PHP Traits algorithms for Encoded Polyline & Bing Point Compression

  Sources   Download

GNU

The Requires

  • php >=5.4

 

by Eric McConville

google maps compression bing point polyline

07/04 2014

1.1.0

1.1.0.0

PHP Traits algorithms for Encoded Polyline & Bing Point Compression

  Sources   Download

GNU

The Requires

  • php >=5.4

 

by Eric McConville

google maps compression bing point polyline

24/03 2014

1.0.1

1.0.1.0

PHP Traits algorithms for Encoded Polyline & Bing Point Compression

  Sources   Download

GNU

The Requires

  • php >=5.4

 

by Eric McConville

google maps compression bing point polyline

23/03 2014

1.0.0

1.0.0.0

PHP Traits algorithms for Encoded Polyline & Bing Point Compression

  Sources   Download

GNU

The Requires

  • php >=5.4

 

by Eric McConville

google maps compression bing point polyline