Download the PHP package subdee/geotools without Composer
On this page you can find all versions of the php package subdee/geotools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package geotools
Geotools
Geotools is a PHP geo-related library, built atop Geocoder and React libraries.
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 PSR-6 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 ...
Installation
Geotools can be found on Packagist. The recommended way to install Geotools is through composer.
Run the following on the command line:
Protip: you should browse the
league/geotools
page to choose a stable version to use, avoid the @stable
meta constraint.
Important: you should use the 0.4
version if you use Geocoder 2.x
or/and PHP 5.3
.
And install dependencies:
Now you can add the autoloader, and you will have access to the library:
Usage & API
Coordinate & Ellipsoid
The default geodetic datum is WGS84 and coordinates are in decimal degrees.
Here are the available ellipsoids: AIRY
, AUSTRALIAN_NATIONAL
, BESSEL_1841
, BESSEL_1841_NAMBIA
,
CLARKE_1866
, CLARKE_1880
, EVEREST
, FISCHER_1960_MERCURY
, FISCHER_1968
, GRS_1967
, GRS_1980
,
HELMERT_1906
, HOUGH
, INTERNATIONAL
, KRASSOVSKY
, MODIFIED_AIRY
, MODIFIED_EVEREST
,
MODIFIED_FISCHER_1960
, SOUTH_AMERICAN_1969
, WGS60
, WGS66
, WGS72
, and WGS84
.
If you need to use an other ellipsoid, just create an array like this:
Geotools is built atop Geocoder. It means it's possible to use the
\Geocoder\Model\Address
directly but it's also possible to use a string or a simple array with its
latitude and longitude.
It supports valid and acceptable geographic coordinates like:
- 40:26:46N,079:56:55W
- 40:26:46.302N 079:56:55.903W
- 40°26′47″N 079°58′36″W
- 40d 26′ 47″ N 079d 58′ 36″ W
- 40.446195N 79.948862W
- 40.446195, -79.948862
- 40° 26.7717, -79° 56.93172
Latitudes below -90.0 or above 90.0 degrees are capped through \League\Geotools\Coordinate\Coordinate::normalizeLatitude()
.
Longitudes below -180.0 or above 180.0 degrees are wrapped through \League\Geotools\Coordinate\Coordinate::normalizeLongitude()
.
Convert
It provides methods (and aliases) to convert decimal degrees WGS84 coordinates to degrees minutes seconds or decimal minutes WGS84 coordinates. You can format the output string easily.
You can also convert them in the Universal Transverse Mercator (UTM) projection (Southwest coast of Norway and the region of Svalbard are covered).
Here is the mapping:
Decimal minutes | Latitude | Longitude |
---|---|---|
Positive or negative sign | %P |
%p |
Direction | %L |
%l |
Degrees | %D |
%d |
Decimal minutes | %N |
%n |
Degrees minutes seconds | Latitude | Longitude |
---|---|---|
Positive or negative sign | %P |
%p |
Direction | %L |
%l |
Degrees | %D |
%d |
Minutes | %M |
%m |
Seconds | %S |
%s |
Batch
It provides a very handy way to batch geocode and reverse geocoding requests in serie or in parallel against
a set of providers.
Thanks to Geocoder and React libraries.
It's possible to batch one request (a string) or a set of request (an array) against one provider or set of providers.
You can use a provided cache engine or use your own by setting a cache object which should implement
League\Geotools\Cache\CacheInterface
and extend League\Geotools\Cache\AbstractCache
if needed.
At the moment Geotools supports any PSR-6 cache.
NB: Before you implement caching in your app please be sure that doing so does not violate the Terms of Service for your(s) geocoding provider(s).
You should get 24 results (4 values to geocode against 6 providers) something like:
Batch reverse geocoding is something like:
If you want to batch it in serie, replace the method parallel()
by serie()
.
To optimize batch requests you need to register providers according to their capabilities and what you're looking for (geocode street addresses, geocode IPv4, geocode IPv6 or reverse geocoding), please read more at the Geocoder library doc.
Distance
It provides methods to compute the distance in meter (by default), km, mi or ft between two coordinates using flat (most performant), great circle, haversine or vincenty (most accurate) algorithms.
Those coordinates should be in the same ellipsoid.
Point
It provides methods to compute the initial and final bearing in degrees, the initial and final cardinal direction,
the middle point and the destination point. The middle and the destination points returns a
\League\Geotools\Coordinate\Coordinate
object with the same ellipsoid.
Geohash
It provides methods to get the geo hash and its bounding box's coordinates (SouthWest & NorthEast) of a coordinate and the coordinate and its bounding box's coordinates (SouthWest & NorthEast) of a geo hash.
10:10
Represent a location with 10m accuracy using a 10 character code that includes features to prevent errors in entering the code. Read more about the algorithm here.
Vertex
Represents a segment with a direction. You can find if two vertexes are on the same line.
Polygon
It helps you to know if a point (coordinate) is in a Polygon or on the Polygon's boundaries and if this in on a Polygon's vertex.
First you need to create the polygon, you can provide:
- an array of arrays
- an array of
Coordinate
- a
CoordinateCollection
CLI
It provides command lines to compute methods provided by Distance, Point, Geohash and Convert classes. Thanks to the Symfony Console Component.
Compute street addresses, IPv4s or IPv6s geocoding and reverse geocoding right in your console.
It's possible to define and precise your request through these options:
--provider
:bing_maps
,yahoo
,maxmind
...google_maps
is the default one. See the full list here.--raw
: the result output in RAW format, shows Adapter, Provider and Arguments if any.--json
: the result output in JSON string format.--args
: this option accepts multiple values (e.g. --args="API_KEY" --args="LOCALE") if your provider needs or can have arguments.--dumper
: this option is available for geocoding,gpx
,geojson
,kml
,wkb
andwkt
by default. Read more here.--format
: this option is available for reverse geocoding, see the mapping here.
The last command will show an output like this:
Integration with Frameworks
- Laravel 4 & 5
- Silex
- ...
Unit Tests
To run unit tests, you'll need the cURL
extension and a set of dependencies, you can install them using Composer:
Once installed, just launch the following command:
Credits
- Antoine Corcy
- Pascal Borreli
- Phil Sturgeon
- Gabriel Bull
- All contributors
Acknowledgments
- Geocoder - MIT
- ReactPHP - MIT
- Symfony Console Component - MIT
- Symfony Serializer Component - MIT
- PHP client library for Redis - MIT
- Geokit, Geotools-for-CodeIgniter, geotools-php ...
Changelog
Contributing
Please see CONTRIBUTING for details.
Support
Bugs and feature request are tracked on GitHub
Contributor Code of Conduct
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the Contributor Covenant, version 1.0.0, available at http://contributor-covenant.org/version/1/0/0/
License
Geotools is released under the MIT License. See the bundled LICENSE file for details.
All versions of geotools with dependencies
psr/cache Version ^1.0
willdurand/geocoder Version ^4.2
react/promise Version ^2.2
symfony/console Version ^2.7 || ^3.0 || ^4.0 || ^5.0
symfony/property-access Version ^2.7 || ^3.0 || ^4.0 || ^5.0
symfony/serializer Version ^2.7 || ^3.0 || ^4.0 || ^5.0
react/event-loop Version 0.4.*
php-http/discovery Version ^1.0
cache/array-adapter Version ^1.0