#302

Product support

Get help in the plugin support forum.

Categories

  • Developer Tools

Geo-related tools PHP 5.4+ library built atop Geocoder and React libraries http://geotools-php.org

Features

  • Batch geocode & reverse geocoding request(s) in series / in parallel against one or a set of providers. »
  • Cache geocode & reverse geocoding result(s) with Redis, Memcached or MongoDB to improve performances. »
  • Compute geocode & reverse geocoding in the command-line interface (CLI) + dumpers and formatters. »
  • Accept almost all kind of WGS84 geographic coordinates as coordinates. »
  • Support 23 different ellipsoids and it's easy to provide a new one if needed. »
  • Convert and format decimal degrees coordinates to decimal minutes or degrees minutes seconds coordinates. »
  • Convert decimal degrees coordinates in the Universal Transverse Mercator (UTM) projection. »
  • Compute the distance in meter (by default), km, mi or ft between two coordinates using flat, great circle, haversine or vincenty algorithms. »
  • Compute the initial and final bearing from the origin coordinate to the destination coordinate in degrees. »
  • Compute the initial and final cardinal point (direction) from the origin coordinate to the destination coordinate, read more in wikipedia. »
  • Compute the half-way point (coordinate) between the origin and the destination coordinates. »
  • Compute the destination point (coordinate) with given bearing in degrees and a distance in meters. »
  • Encode a coordinate to a geo hash string and decode it to a coordinate, read more in wikipedia and on geohash.org. »
  • Encode a coordinate via the 10:10 algorithm. »
  • Polygon class provides methods to check either a poing (coordinate) is in, or on the polygon's boundaries. »
  • A command-line interface (CLI) for Distance, Point, Geohash and Convert classes. »
  • Integration with Frameworks: Laravel 4, Silex ... »
  • ... more to come ...

This plugin is merely a wrapper of the Geocode project of "The PHP League", brought to the October CMS for you!

Usage example:

$geocoder = new ProviderAggregator();
$adapter = new CurlHttpAdapter();

$geocoder->registerProviders([
    new GoogleMaps($adapter),
    new OpenStreetMap($adapter),
]);

try {

    $geotools = new Geotools(); // this is the Geotools facade for Laravel
    $cache = new CacheManager();

    $results = $geotools::batch($geocoder)->setCache($cache)->geocode([
        "Damrak, Amsterdam, Nederland",
         "Avenue des Champs-Élysées, Paris, France",
         "Tower Bridge, London, GB",
    ])->parallel();
}
catch (Exception $e) {

    throw new SystemException($e->getMessage());
}

foreach ($results as $result) {

    if ($ex = $result->getExceptionMessage()){

        Log::notice($ex);

        continue;
    }
    else {

        $lat = $result->getAddress()->getLatitude();
        $lng = $result->getAddress()->getLongitude();

        // Do stuff with this data in your model or...
        }
    }
}

Don't forget to load the right classes with the 'use' syntax in the beginning of your class:

use Exception;
use Geocoder\Provider\GoogleMaps;
use Geocoder\Provider\OpenStreetMap;
use Geocoder\ProviderAggregator;
use Geotools;
use Ivory\HttpAdapter\CurlHttpAdapter;
use Log;
use SystemException;
use Webplaats\Geotools\Cache\CacheManager;

Links to the original documentation with much more examples:

1.0.4

Bugfix serialization in caching system

Jul 04, 2016

1.0.3

Wrapper for Cache of OctoberCMS included

Jun 24, 2016

1.0.2

Update of Geotools lib

Jun 20, 2016

1.0.1

First version of Geotools

Jun 20, 2016