2017 © Pedro Peláez
 

library distance

Geo distance library for PHP.

image

bogdaan/distance

Geo distance library for PHP.

  • Tuesday, July 21, 2015
  • by Bogdan
  • Repository
  • 1 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHP distance library

Build
Status, (*1)

This library provide: - distance calculation - distance matrix calculation, (*2)

Note that the library does not provide geocoding features (for these purposes, you can use this library)., (*3)

Example


use Distance\Model\Distance; use Distance\Model\Coordinate; use Distance\Exception\PoolError; // for HTTP providers $client = new GuzzleHttp\Client(); // fail-safe distance source $pool = new Distance\ProviderPool([ // Google distance matrix provider new Distance\Provider\GoogleProvider($client), // OSRM server with distance_table plugin new Distance\Provider\OsrmProvider($client, [ 'baseUrl' => 'http://localhost:2233/', ]), // graphhopper service new Distance\Provider\GraphhopperProvider($client,[ 'key' => 'YOU_API_KEY' ]), // routexl.com distance matrix new Distance\Provider\RoutexlProvider($client, [ 'username' => 'YOU_API_USERNAME', 'password' => 'YOU_API_PASSWORD', ]), // optinal (If all previous fails) - math provider new Distance\Provider\HaversinaProvider(), ]); // GPS coordinates $coords = [ new Coordinate(48.41, 34.81), new Coordinate(48.43, 35.22), new Coordinate(48.43, 36.22). ]; // case1: single distance $distanceObject = $pool->getDistance($coords[0], $coords[1]); $distanceInMeters = $distanceObject->getDistance(Distance::UNIT_METER); $distanceInMiles = $distanceObject->getDistance(Distance::UNIT_MILE); // case2: distance matrix 3x3 $matrix = $pool->getDistanceMatrix($coords); $distanceInMeters = $matrix->getDistance($coords[0], $coords[1], Distance::UNIT_METER);

Instalation

Using composer:, (*4)

$ composer require bogdaan/distance

Providers

Currently supported providers:, (*5)

The Versions

21/07 2015

dev-master

9999999-dev

Geo distance library for PHP.

  Sources   Download

MIT

The Requires

 

distance geo matrix