black / geo
PHP 5.4+ library to make working with Geo coordinates safer, easier, and fun
This package is auto-updated.
Last update: 2024-10-29 04:10:13 UTC
README
PHP 5.4+ library to make working with Geo coordinates safer, easier, and fun!
Installation
The recommended way to install Geo is through Composer:
{ "require": { "black/geo": "@stable" } }
Protip: You should browse the [black/geo
](https://packagist.org/packages/black/geo page to choose a stable version to use, avoid the @stable
meta
constraint.
Usage
Usage of this class is simple. First, Geo coordinates are based on three values : latitude, longitude and elevation. Elevation is not required and initialised to 0 if arguments are not provided.
There are three ways to create a Geo object:
$geo = new Geo\Coordinates(37.42242, -122.08585, 0); $geo->getCoordinates(); // will return "37.42242,-122.08585,0"
Geo\Coordinates::fromCoordinatesAsString("37.42242,-122.08585,0") ->getLatitude(); // will return "37.42242"
Geo\Coordinates::fromCoordinatesAsArray([37.42242, -122.08585, 0]) ->getCoordinates(); // will return "37.42242,-122.08585,0"
Getter
List of available getters:
getLatitude()
getLongitude()
getElevation()
getCoordinates()
getCoordinatesAsArray()
Check if two geo are equals
isEqualTo(Geo $geo)
Exception
If you want to pass 1 or less OR 4 or more arguments, a Geo\Exception\InvalidCoordinatesException()
will be thrown.
License
Geo is released under the MIT License. See the bundled LICENSE file for details.
Contributing
See CONTRIBUTING file.
Credits
This README is heavily inspired by Geocoder library by the great @willdurand. This guy needs your PR for the sake of the REST in PHP.
Alexandre "pocky" Balmes alexandre@lablackroom.com. Send me Flattrs if you love my work, buy me gift or hire me!