Geolocation utilities
Installs: 4 430
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 16
Forks: 1
Open Issues: 0
Requires
- curl/curl: ~1.1.0
- icecave/isolator: ~3.0.3
- phayes/geophp: dev-master
- vlucas/phpdotenv: ^1.1|^2.0
Requires (Dev)
- mockery/mockery: ~0.9.1
- phpunit/phpunit: ~4.3
This package is auto-updated.
Last update: 2022-02-01 12:46:10 UTC
README
leroy-merlin-br/geo
is a simple to use set of tools for geolocation. It's an abstraction built on top of the powerfull phayes/geophp
.
Region matching
With the LeroyMerlin\GeoTools\RegionMatcher
you can easily test if a coordinate is inside of a region.
Example of use:
$regionMatcher = new LeroyMerlin\GeoTools\RegionMatcher; $regionMatcher->loadRegion('/path/to/myRegion.kml'); $regionMatcher->loadRegion('/path/to/intersectingRegion.kml'); $regionMatcher->loadRegion('/path/to/farAwayRegion.kml'); $regionMatcher->getRegionsThatMatches(23, 23); // returns ['myRegion', 'intersectingRegion']
IP to geolocation
LeroyMerlin\GeoTools\IpLocator
uses ip-api.com to find out the geolocation of a given IP address.
Example of use:
$locator = new LeroyMerlin\GeoTools\IpLocator; $locator->getLocation('208.80.152.201'); // array( // 'as' => 'AS14907 Wikimedia Foundation Inc.', // 'city' => 'San Francisco', // 'country' => 'United States', // 'countryCode' => 'US', // 'isp' => 'Wikimedia Foundation', // 'lat' => 37.7898, // 'lon' => -122.3942, // 'org' => 'Wikimedia Foundation', // 'query' => '208.80.152.201', // 'region' => 'CA', // 'regionName' => 'California', // 'status' => 'success', // 'timezone' => 'America/Los_Angeles', // 'zip' => '94105' // ) $locator->getCoordinates('208.80.152.201'); // array( // 'x' => 37.7898, // 'y' => -122.3942 // )