mv/roadlength

PHP connector to calc road distance between locations

1.0 2020-08-11 08:44 UTC

This package is auto-updated.

Last update: 2024-04-11 17:04:21 UTC


README

This API is to calc distance between two points by road.

Install

composer require mv/roadlength

Examples

With postal address

use Mv\RoadLength\Api\HereApi;
use Mv\RoadLength\Geo\Location;
use Mv\RoadLength\Geo\Distance;

$hereApi = new HereApi('---Your HERE API KEY---');

$origin = Location::createByAddress('mairie de hyeres 83400 HYERES', $hereApi);
$destination = Location::createByAddress('mairie de sollies-toucas 83210 SOLLIES-TOUCAS', $hereApi);

$distance = new Distance($hereApi);
$distance->setStartLocation($origin);
$distance->setEndLocation($destination);

$distanceInMeters = $distance->getDistance();

With geoloc coordinates

use Mv\RoadLength\Api\HereApi;
use Mv\RoadLength\Geo\Location;
use Mv\RoadLength\Geo\Distance;

$hereApi = new HereApi('---Your HERE API KEY---');

$origin = Location::createByCoords(43.119840, 6.129904);
$destination = Location::createByCoords(43.206368, 6.026157);

$distance = new Distance($hereApi);
$distance->setStartLocation($origin);
$distance->setEndLocation($destination);

$distanceInMeters = $distance->getDistance();

Enjoy it!

To be continued...