diff --git a/apiconfig.php b/apiconfig.php index 0a23d19..59c20ab 100644 --- a/apiconfig.php +++ b/apiconfig.php @@ -12,14 +12,13 @@ $APIS = [ "vars" => [ ] ], -// "gis/geocode" => [ -// "load" => "gis.geocode.php", -// "vars" => [ -// "latitude" => "/\-?[0-9]{1,3}(\.[0-9]{0,10})?/", -// "longitude" => "/\-?[0-9]{1,3}(\.[0-9]{0,10})?/", -// "nocache (optional)" => "" -// ] -// ], + "gis/geocode" => [ + "load" => "gis.geocode.php", + "vars" => [ + "address" => "", + "nocache (optional)" => "" + ] + ], "gis/geocode/reverse" => [ "load" => "gis.geocode.reverse.php", "vars" => [ diff --git a/composer.json b/composer.json index 366c2ec..e43f0a0 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,13 @@ "shippo/shippo-php": "^1.4", "easypost/easypost-php": "^3.5", "bogdaan/open-location-code": "dev-master", - "singpolyma/openpgp-php": "^0.5.0" + "singpolyma/openpgp-php": "^0.5.0", + "geocoder-php/chain-provider": "^4.3", + "geocoder-php/mapbox-provider": "^1.3", + "geocoder-php/mapquest-provider": "^4.2", + "guzzlehttp/psr7": "^2.1", + "php-http/curl-client": "^2.2", + "guzzlehttp/guzzle": "^7.4", + "php-http/guzzle7-adapter": "^1.0" } } diff --git a/composer.lock b/composer.lock index c34d5bb..bc4aae2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d376050c7d4fdf9dd835d99448acdf0b", + "content-hash": "31ba0c721e534735c0c9475c310d5841", "packages": [ { "name": "bogdaan/open-location-code", @@ -129,6 +129,72 @@ ], "time": "2021-05-12T17:55:47+00:00" }, + { + "name": "clue/stream-filter", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/clue/stream-filter.git", + "reference": "aeb7d8ea49c7963d3b581378955dbf5bc49aa320" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/clue/stream-filter/zipball/aeb7d8ea49c7963d3b581378955dbf5bc49aa320", + "reference": "aeb7d8ea49c7963d3b581378955dbf5bc49aa320", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "psr-4": { + "Clue\\StreamFilter\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering" + } + ], + "description": "A simple and modern approach to stream filtering in PHP", + "homepage": "https://github.com/clue/php-stream-filter", + "keywords": [ + "bucket brigade", + "callback", + "filter", + "php_user_filter", + "stream", + "stream_filter_append", + "stream_filter_register" + ], + "support": { + "issues": "https://github.com/clue/stream-filter/issues", + "source": "https://github.com/clue/stream-filter/tree/v1.5.0" + }, + "funding": [ + { + "url": "https://clue.engineering/support", + "type": "custom" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2020-10-02T12:38:20+00:00" + }, { "name": "composer/ca-bundle", "version": "1.2.9", @@ -259,6 +325,248 @@ }, "time": "2021-04-06T02:57:46+00:00" }, + { + "name": "geocoder-php/chain-provider", + "version": "4.3.0", + "source": { + "type": "git", + "url": "https://github.com/geocoder-php/chain-provider.git", + "reference": "0f6241a89ee3f26021ef0036619b10081af53b18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/geocoder-php/chain-provider/zipball/0f6241a89ee3f26021ef0036619b10081af53b18", + "reference": "0f6241a89ee3f26021ef0036619b10081af53b18", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "psr/log": "^1.0", + "willdurand/geocoder": "^4.0" + }, + "provide": { + "geocoder-php/provider-implementation": "1.0" + }, + "require-dev": { + "nyholm/nsa": "^1.1", + "php-http/curl-client": "^2.2", + "php-http/message": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "psr-4": { + "Geocoder\\Provider\\Chain\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com" + } + ], + "description": "Geocoder chain adapter", + "homepage": "http://geocoder-php.org/Geocoder/", + "support": { + "source": "https://github.com/geocoder-php/chain-provider/tree/4.3.0" + }, + "time": "2020-12-21T16:41:18+00:00" + }, + { + "name": "geocoder-php/common-http", + "version": "4.4.0", + "source": { + "type": "git", + "url": "https://github.com/geocoder-php/php-common-http.git", + "reference": "9f44a006d4b45d01dd31ea9b38ee7fb5724cd73e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/geocoder-php/php-common-http/zipball/9f44a006d4b45d01dd31ea9b38ee7fb5724cd73e", + "reference": "9f44a006d4b45d01dd31ea9b38ee7fb5724cd73e", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "php-http/client-implementation": "^1.0", + "php-http/discovery": "^1.6", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0.2", + "psr/http-message": "^1.0", + "psr/http-message-implementation": "^1.0", + "willdurand/geocoder": "^4.0" + }, + "require-dev": { + "nyholm/psr7": "^1.0", + "php-http/message": "^1.0", + "php-http/mock-client": "^1.0", + "phpunit/phpunit": "^9.5", + "symfony/stopwatch": "~2.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "psr-4": { + "Geocoder\\Http\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + } + ], + "description": "Common files for HTTP based Geocoders", + "homepage": "http://geocoder-php.org", + "keywords": [ + "http geocoder" + ], + "support": { + "source": "https://github.com/geocoder-php/php-common-http/tree/4.4.0" + }, + "time": "2020-12-21T09:30:01+00:00" + }, + { + "name": "geocoder-php/mapbox-provider", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/geocoder-php/mapbox-provider.git", + "reference": "c1648853a481160c1431590f48ba135da2087da3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/geocoder-php/mapbox-provider/zipball/c1648853a481160c1431590f48ba135da2087da3", + "reference": "c1648853a481160c1431590f48ba135da2087da3", + "shasum": "" + }, + "require": { + "geocoder-php/common-http": "^4.0", + "php": "^7.3 || ^8.0", + "willdurand/geocoder": "^4.0" + }, + "provide": { + "geocoder-php/provider-implementation": "1.0" + }, + "require-dev": { + "geocoder-php/provider-integration-tests": "^1.0", + "php-http/curl-client": "^2.2", + "php-http/message": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Geocoder\\Provider\\Mapbox\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fede Isas", + "email": "federicoisas@gmail.com" + } + ], + "description": "Geocoder Mapbox adapter", + "homepage": "http://geocoder-php.org/Geocoder/", + "support": { + "source": "https://github.com/geocoder-php/mapbox-provider/tree/1.3.0" + }, + "time": "2020-12-21T16:41:18+00:00" + }, + { + "name": "geocoder-php/mapquest-provider", + "version": "4.2.0", + "source": { + "type": "git", + "url": "https://github.com/geocoder-php/mapquest-provider.git", + "reference": "8c7b4b415bb606d6dbb7e6c61233be25f4bfe10b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/geocoder-php/mapquest-provider/zipball/8c7b4b415bb606d6dbb7e6c61233be25f4bfe10b", + "reference": "8c7b4b415bb606d6dbb7e6c61233be25f4bfe10b", + "shasum": "" + }, + "require": { + "geocoder-php/common-http": "^4.0", + "php": "^7.3 || ^8.0", + "willdurand/geocoder": "^4.0" + }, + "provide": { + "geocoder-php/provider-implementation": "1.0" + }, + "require-dev": { + "geocoder-php/provider-integration-tests": "^1.1", + "php-http/curl-client": "^2.2", + "php-http/message": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "psr-4": { + "Geocoder\\Provider\\MapQuest\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com" + } + ], + "description": "Geocoder MapQuest adapter", + "homepage": "http://geocoder-php.org/Geocoder/", + "support": { + "source": "https://github.com/geocoder-php/mapquest-provider/tree/4.2.0" + }, + "time": "2020-12-21T16:41:18+00:00" + }, { "name": "geoip2/geoip2", "version": "v2.11.0", @@ -316,6 +624,329 @@ }, "time": "2020-10-01T18:48:34+00:00" }, + { + "name": "guzzlehttp/guzzle", + "version": "7.4.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/868b3571a039f0ebc11ac8f344f4080babe2cb94", + "reference": "868b3571a039f0ebc11ac8f344f4080babe2cb94", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5", + "guzzlehttp/psr7": "^1.8.3 || ^2.1", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "ext-curl": "*", + "php-http/client-integration-tests": "^3.0", + "phpunit/phpunit": "^8.5.5 || ^9.3.5", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.4.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2021-10-18T09:52:00+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/fe752aedc9fd8fcca3fe7ad05d419d32998a06da", + "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "symfony/phpunit-bridge": "^4.4 || ^5.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/1.5.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "time": "2021-10-22T20:56:57+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/089edd38f5b8abba6cb01567c2a8aaa47cec4c72", + "reference": "089edd38f5b8abba6cb01567c2a8aaa47cec4c72", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.8 || ^9.3.10" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.1.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "time": "2021-10-06T17:43:30+00:00" + }, { "name": "io-developer/php-whois", "version": "4.0.0", @@ -493,6 +1124,452 @@ }, "time": "2020-11-02T17:00:53+00:00" }, + { + "name": "php-http/curl-client", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/curl-client.git", + "reference": "15b11b7c2f39fe61ef6a70e0c247b4a84e845cdb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/curl-client/zipball/15b11b7c2f39fe61ef6a70e0c247b4a84e845cdb", + "reference": "15b11b7c2f39fe61ef6a70e0c247b4a84e845cdb", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": "^7.1 || ^8.0", + "php-http/discovery": "^1.6", + "php-http/httplug": "^2.0", + "php-http/message": "^1.2", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "symfony/options-resolver": "^3.4 || ^4.0 || ^5.0" + }, + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0", + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "guzzlehttp/psr7": "^1.0", + "laminas/laminas-diactoros": "^2.0", + "php-http/client-integration-tests": "^3.0", + "phpunit/phpunit": "^7.5 || ^9.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\Curl\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Михаил Красильников", + "email": "m.krasilnikov@yandex.ru" + } + ], + "description": "PSR-18 and HTTPlug Async client with cURL", + "homepage": "http://php-http.org", + "keywords": [ + "curl", + "http", + "psr-18" + ], + "support": { + "issues": "https://github.com/php-http/curl-client/issues", + "source": "https://github.com/php-http/curl-client/tree/2.2.0" + }, + "time": "2020-12-14T08:36:51+00:00" + }, + { + "name": "php-http/discovery", + "version": "1.14.1", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "de90ab2b41d7d61609f504e031339776bc8c7223" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/de90ab2b41d7d61609f504e031339776bc8c7223", + "reference": "de90ab2b41d7d61609f504e031339776bc8c7223", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "nyholm/psr7": "<1.0" + }, + "require-dev": { + "graham-campbell/phpspec-skip-example-extension": "^5.0", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^5.1 || ^6.1", + "puli/composer-plugin": "1.0.0-beta10" + }, + "suggest": { + "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds installed HTTPlug implementations and PSR-7 message factories", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr7" + ], + "support": { + "issues": "https://github.com/php-http/discovery/issues", + "source": "https://github.com/php-http/discovery/tree/1.14.1" + }, + "time": "2021-09-18T07:57:46+00:00" + }, + { + "name": "php-http/guzzle7-adapter", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/guzzle7-adapter.git", + "reference": "fb075a71dbfa4847cf0c2938c4e5a9c478ef8b01" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/guzzle7-adapter/zipball/fb075a71dbfa4847cf0c2938c4e5a9c478ef8b01", + "reference": "fb075a71dbfa4847cf0c2938c4e5a9c478ef8b01", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^7.0", + "php": "^7.2 | ^8.0", + "php-http/httplug": "^2.0", + "psr/http-client": "^1.0" + }, + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0", + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "php-http/client-integration-tests": "^3.0", + "phpunit/phpunit": "^8.0|^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Adapter\\Guzzle7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + } + ], + "description": "Guzzle 7 HTTP Adapter", + "homepage": "http://httplug.io", + "keywords": [ + "Guzzle", + "http" + ], + "support": { + "issues": "https://github.com/php-http/guzzle7-adapter/issues", + "source": "https://github.com/php-http/guzzle7-adapter/tree/1.0.0" + }, + "time": "2021-03-09T07:35:15+00:00" + }, + { + "name": "php-http/httplug", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/httplug.git", + "reference": "191a0a1b41ed026b717421931f8d3bd2514ffbf9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/httplug/zipball/191a0a1b41ed026b717421931f8d3bd2514ffbf9", + "reference": "191a0a1b41ed026b717421931f8d3bd2514ffbf9", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "php-http/promise": "^1.1", + "psr/http-client": "^1.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.1", + "phpspec/phpspec": "^5.1 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http" + ], + "support": { + "issues": "https://github.com/php-http/httplug/issues", + "source": "https://github.com/php-http/httplug/tree/master" + }, + "time": "2020-07-13T15:43:23+00:00" + }, + { + "name": "php-http/message", + "version": "1.12.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/message.git", + "reference": "39eb7548be982a81085fe5a6e2a44268cd586291" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message/zipball/39eb7548be982a81085fe5a6e2a44268cd586291", + "reference": "39eb7548be982a81085fe5a6e2a44268cd586291", + "shasum": "" + }, + "require": { + "clue/stream-filter": "^1.5", + "php": "^7.1 || ^8.0", + "php-http/message-factory": "^1.0.2", + "psr/http-message": "^1.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.6", + "ext-zlib": "*", + "guzzlehttp/psr7": "^1.0", + "laminas/laminas-diactoros": "^2.0", + "phpspec/phpspec": "^5.1 || ^6.3", + "slim/slim": "^3.0" + }, + "suggest": { + "ext-zlib": "Used with compressor/decompressor streams", + "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", + "laminas/laminas-diactoros": "Used with Diactoros Factories", + "slim/slim": "Used with Slim Framework PSR-7 implementation" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + }, + "files": [ + "src/filters.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTP Message related tools", + "homepage": "http://php-http.org", + "keywords": [ + "http", + "message", + "psr-7" + ], + "support": { + "issues": "https://github.com/php-http/message/issues", + "source": "https://github.com/php-http/message/tree/1.12.0" + }, + "time": "2021-08-29T09:13:12+00:00" + }, + { + "name": "php-http/message-factory", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-http/message-factory.git", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Factory interfaces for PSR-7 HTTP Message", + "homepage": "http://php-http.org", + "keywords": [ + "factory", + "http", + "message", + "stream", + "uri" + ], + "support": { + "issues": "https://github.com/php-http/message-factory/issues", + "source": "https://github.com/php-http/message-factory/tree/master" + }, + "time": "2015-12-19T14:08:53+00:00" + }, + { + "name": "php-http/promise", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/promise.git", + "reference": "4c4c1f9b7289a2ec57cde7f1e9762a5789506f88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/promise/zipball/4c4c1f9b7289a2ec57cde7f1e9762a5789506f88", + "reference": "4c4c1f9b7289a2ec57cde7f1e9762a5789506f88", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.3.2", + "phpspec/phpspec": "^5.1.2 || ^6.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Promise used for asynchronous HTTP requests", + "homepage": "http://httplug.io", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/php-http/promise/issues", + "source": "https://github.com/php-http/promise/tree/1.1.0" + }, + "time": "2020-07-07T09:29:14+00:00" + }, { "name": "phpseclib/phpseclib", "version": "2.0.32", @@ -602,6 +1679,260 @@ ], "time": "2021-06-12T12:12:59+00:00" }, + { + "name": "psr/http-client", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client/tree/master" + }, + "time": "2020-06-29T06:28:15+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/master" + }, + "time": "2019-04-30T12:38:16+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/master" + }, + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "psr/log", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "time": "2021-05-03T11:20:27+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, { "name": "shippo/shippo-php", "version": "v1.4.4", @@ -725,6 +2056,142 @@ ], "time": "2021-05-26T00:35:20+00:00" }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-23T23:28:01+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v5.3.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "4b78e55b179003a42523a362cc0e8327f7a69b5e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/4b78e55b179003a42523a362cc0e8327f7a69b5e", + "reference": "4b78e55b179003a42523a362cc0e8327f7a69b5e", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-php73": "~1.0", + "symfony/polyfill-php80": "^1.16" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v5.3.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-08-04T21:20:46+00:00" + }, { "name": "symfony/polyfill-mbstring", "version": "v1.22.1", @@ -805,6 +2272,168 @@ ], "time": "2021-01-22T09:19:47+00:00" }, + { + "name": "symfony/polyfill-php73", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010", + "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", + "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-28T13:41:28+00:00" + }, { "name": "true/punycode", "version": "v2.1.1", @@ -854,6 +2483,68 @@ "source": "https://github.com/true/php-punycode/tree/master" }, "time": "2016-11-16T10:37:54+00:00" + }, + { + "name": "willdurand/geocoder", + "version": "4.4.0", + "source": { + "type": "git", + "url": "https://github.com/geocoder-php/php-common.git", + "reference": "3e86f5b10ab0cef1cf03f979fe8e34b6476daff0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/geocoder-php/php-common/zipball/3e86f5b10ab0cef1cf03f979fe8e34b6476daff0", + "reference": "3e86f5b10ab0cef1cf03f979fe8e34b6476daff0", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "nyholm/nsa": "^1.1", + "phpunit/phpunit": "^9.5", + "symfony/stopwatch": "~2.5" + }, + "suggest": { + "symfony/stopwatch": "If you want to use the TimedGeocoder" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "autoload": { + "psr-4": { + "Geocoder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "William Durand", + "email": "william.durand1@gmail.com" + } + ], + "description": "Common files for PHP Geocoder", + "homepage": "http://geocoder-php.org", + "keywords": [ + "abstraction", + "geocoder", + "geocoding", + "geoip" + ], + "support": { + "source": "https://github.com/geocoder-php/php-common/tree/4.4.0" + }, + "time": "2020-12-21T09:30:01+00:00" } ], "packages-dev": [], diff --git a/endpoints/gis.geocode.php b/endpoints/gis.geocode.php new file mode 100644 index 0000000..083580d --- /dev/null +++ b/endpoints/gis.geocode.php @@ -0,0 +1,91 @@ +get("gis.geocode." . sha1($origaddress)); +if ($cacheresp !== false && empty($VARS["nocache"])) { + exitWithJson(json_decode($cacheresp, true)); +} + +$geocoder = new \Geocoder\ProviderAggregator(); +$adapter = new \Http\Adapter\Guzzle7\Client(); + +$chain = new \Geocoder\Provider\Chain\Chain([ + new \Geocoder\Provider\Mapbox\Mapbox($adapter, env("mapbox_key")), + new \Geocoder\Provider\MapQuest\MapQuest($adapter, env("mapquest_key")) + ]); + +$geocoder->registerProvider($chain); + +$query = GeocodeQuery::create($address)->withLimit(1); + +if (isset($VARS["country"]) && preg_match("/^[A-Z]{2}$/", $VARS["country"])) { + $query = $query->withData("country", $VARS["country"]); +} + + +$results = $geocoder->geocodeQuery($query); + +if ($results->count() > 0) { + $result = $results->first(); +} else { + $output = [ + "status" => "ERROR", + "message" => "Address not found.", + "address" => [ + "original" => $origaddress, + "street" => "", + "postalCode" => "" + ], + "coords" => [ + 0, + 0 + ], + "accuracy" => [ + "ok" => false + ], + "provider" => "" + ]; + goto cacheout; +} + +$geolatitude = $result->getCoordinates()->getLatitude(); +$geolongitude = $result->getCoordinates()->getLongitude(); + +$accurate = !empty($result->getStreetNumber()); + +if ($accurate) { + $address = implode(" ", [$result->getStreetNumber(), $result->getStreetName()]); +} else { + $address = $result->getStreetName(); +} + +$output = [ + "status" => "OK", + "address" => [ + "original" => $origaddress, + "street" => ucwords(strtolower(StreetNormalizer::normalizeAddress($address))), + "postalCode" => $result->getPostalCode() + ], + "coords" => [ + $geolatitude, + $geolongitude + ], + "accuracy" => [ + "ok" => $accurate + ], + "provider" => $result->getProvidedBy() +]; + +cacheout: +$memcache->set("gis.geocode." . sha1($origaddress), json_encode($output)); +exitWithJson($output); diff --git a/lib/StreetNormalizer.lib.php b/lib/StreetNormalizer.lib.php new file mode 100644 index 0000000..622fe5c --- /dev/null +++ b/lib/StreetNormalizer.lib.php @@ -0,0 +1,471 @@ +lp added + */ + + const SUFFIX_TABLE = [ + 'ALLEE' => 'ALY', + 'ALLEY' => 'ALY', + 'ALLY' => 'ALY', + 'ANEX' => 'ANX', + 'ANNEX' => 'ANX', + 'ANNX' => 'ANX', + 'ARC ' => 'ARC', + 'ARCADE ' => 'ARC', + 'AV' => 'AVE', + 'AVEN' => 'AVE', + 'AVENU' => 'AVE', + 'AVENUE' => 'AVE', + 'AVN' => 'AVE', + 'AVNUE' => 'AVE', + 'BAYOO' => 'BYU', + 'BAYOU' => 'BYU', + 'BEACH' => 'BCH', + 'BEND' => 'BND', + 'BLUF' => 'BLF', + 'BLUFF' => 'BLF', + 'BLUFFS ' => 'BLFS', + 'BOT' => 'BTM', + 'BOTTM' => 'BTM', + 'BOTTOM' => 'BTM', + 'BOUL' => 'BLVD', + 'BOULEVARD ' => 'BLVD', + 'BOULV' => 'BLVD', + 'BRNCH' => 'BR', + 'BRANCH' => 'BR', + 'BRDGE' => 'BRG', + 'BRIDGE' => 'BRG', + 'BROOK' => 'BRK', + 'BROOKS ' => 'BRKS', + 'BURG' => 'BG', + 'BURGS' => 'BGS', + 'BYPA' => 'BYP', + 'BYPAS' => 'BYP', + 'BYPASS' => 'BYP', + 'BYPS' => 'BYP', + 'CAMP' => 'CP', + 'CMP' => 'CP', + 'CANYN' => 'CYN', + 'CANYON' => 'CYN', + 'CNYN' => 'CYN', + 'CAPE' => 'CPE', + 'CAUSEWAY' => 'CSWY', + 'CAUSWA' => 'CSWY', + 'CEN' => 'CTR', + 'CENT' => 'CTR', + 'CENTER' => 'CTR', + 'CENTR' => 'CTR', + 'CENTRE' => 'CTR', + 'CNTER' => 'CTR', + 'CNTR' => 'CTR', + 'CENTERS ' => 'CTRS', + 'CIRC' => 'CIR', + 'CIRCL' => 'CIR', + 'CIRCLE' => 'CIR', + 'CRCL' => 'CIR', + 'CRCLE' => 'CIR', + 'CIRCLES' => 'CIRS', + 'CLIFF' => 'CLF', + 'CLIFFS' => 'CLFS', + 'CLUB' => 'CLB', + 'COMMON' => 'CMN', + 'COMMONS' => 'CMNS', + 'CORNER' => 'COR', + 'CORNERS' => 'CORS', + 'COURSE' => 'CRSE', + 'COURT' => 'CT', + 'COURTS' => 'CTS', + 'COVE' => 'CV', + 'COVES' => 'CVS', + 'CREEK' => 'CRK', + 'CRESCENT' => 'CRES', + 'CRSENT' => 'CRES', + 'CRSNT' => 'CRES', + 'CREST' => 'CRST', + 'CROSSING ' => 'XING', + 'CRSSNG ' => 'XING', + 'XING ' => 'XING', + 'CROSSROAD' => 'XRD', + 'CROSSROADS' => 'XRDS', + 'CURVE ' => 'CURV', + 'DALE ' => 'DL', + 'DL ' => 'DL', + 'DAM ' => 'DM', + 'DM ' => 'DM', + 'DIV' => 'DV', + 'DIVIDE' => 'DV', + 'DVD' => 'DV', + 'DRIV' => 'DR', + 'DRIVE' => 'DR', + 'DRV' => 'DR', + 'DRIVES' => 'DRS', + 'ESTATE' => 'EST', + 'ESTATES' => 'ESTS', + 'EXP' => 'EXPY', + 'EXPR' => 'EXPY', + 'EXPRESS' => 'EXPY', + 'EXPRESSWAY' => 'EXPY', + 'EXPW' => 'EXPY', + 'EXTENSION' => 'EXT', + 'EXTN' => 'EXT', + 'EXTNSN' => 'EXT', + 'FALLS' => 'FLS', + 'FERRY' => 'FRY', + 'FRRY' => 'FRY', + 'FIELD' => 'FLD', + 'FIELDS' => 'FLDS', + 'FLAT' => 'FLT', + 'FLATS' => 'FLTS', + 'FORD' => 'FRD', + 'FORDS' => 'FRDS', + 'FOREST' => 'FRST', + 'FORESTS' => 'FRST', + 'FORG' => 'FRG', + 'FORGE' => 'FRG', + 'FORGES' => 'FRGS', + 'FORK' => 'FRK', + 'FORKS' => 'FRKS', + 'FORT' => 'FT', + 'FRT' => 'FT', + 'FREEWAY' => 'FWY', + 'FREEWY' => 'FWY', + 'FRWAY' => 'FWY', + 'FRWY' => 'FWY', + 'GARDEN' => 'GDN', + 'GARDN' => 'GDN', + 'GRDEN' => 'GDN', + 'GRDN' => 'GDN', + 'GARDENS' => 'GDNS', + 'GRDNS' => 'GDNS', + 'GATEWAY' => 'GTWY', + 'GATEWY' => 'GTWY', + 'GATWAY' => 'GTWY', + 'GTWAY' => 'GTWY', + 'GLEN' => 'GLN', + 'GLENS' => 'GLNS', + 'GREEN' => 'GRN', + 'GREENS' => 'GRNS', + 'GROV' => 'GRV', + 'GROVE' => 'GRV', + 'GROVES' => 'GRVS', + 'HARB' => 'HBR', + 'HARBOR' => 'HBR', + 'HARBR' => 'HBR', + 'HRBOR' => 'HBR', + 'HARBORS' => 'HBRS', + 'HAVEN' => 'HVN', + 'HT' => 'HTS', + 'HIGHWAY' => 'HWY', + 'HIGHWY' => 'HWY', + 'HIWAY' => 'HWY', + 'HIWY' => 'HWY', + 'HWAY' => 'HWY', + 'HILL' => 'HL', + 'HILLS' => 'HLS', + 'HLLW' => 'HOLW', + 'HOLLOW' => 'HOLW', + 'HOLLOWS' => 'HOLW', + 'HOLWS' => 'HOLW', + 'ISLAND' => 'IS', + 'ISLND' => 'IS', + 'ISLANDS' => 'ISS', + 'ISLNDS' => 'ISS', + 'ISLES' => 'ISLE', + 'JCTION' => 'JCT', + 'JCTN' => 'JCT', + 'JUNCTION' => 'JCT', + 'JUNCTN' => 'JCT', + 'JUNCTON' => 'JCT', + 'JCTNS' => 'JCTS', + 'JUNCTIONS' => 'JCTS', + 'KEY' => 'KY', + 'KEYS' => 'KYS', + 'KNL' => 'KNL', + 'KNOL' => 'KNL', + 'KNOLL' => 'KNL', + 'KNOLLS' => 'KNLS', + 'LAKE' => 'LK', + 'LAKES' => 'LKS', + 'LANDING' => 'LNDG', + 'LNDNG' => 'LNDG', + 'LANE' => 'LN', + 'LIGHT' => 'LGT', + 'LIGHTS' => 'LGTS', + 'LOAF' => 'LF', + 'LOCK' => 'LCK', + 'LOCKS' => 'LCKS', + 'LDGE' => 'LDG', + 'LODG' => 'LDG', + 'LODGE' => 'LDG', + 'MANOR' => 'MNR', + 'MANORS' => 'MNRS', + 'MEADOW' => 'MDW', + 'MDW' => 'MDWS', + 'MEADOWS' => 'MDWS', + 'MEDOWS' => 'MDWS', + 'MILL' => 'ML', + 'MILLS' => 'MLS', + 'MISSN' => 'MSN', + 'MSSN' => 'MSN', + 'MOTORWAY' => 'MTWY', + 'MNT' => 'MT', + 'MOUNT' => 'MT', + 'MNTAIN' => 'MTN', + 'MNTN' => 'MTN', + 'MOUNTAIN' => 'MTN', + 'MOUNTIN' => 'MTN', + 'MTIN' => 'MTN', + 'MNTNS' => 'MTNS', + 'MOUNTAINS' => 'MTNS', + 'NECK' => 'NCK', + 'ORCHARD' => 'ORCH', + 'ORCHRD' => 'ORCH', + 'OVL' => 'OVAL', + 'OVERPASS' => 'OPAS', + 'PRK' => 'PARK', + 'PARKS' => 'PARK', + 'PARKWAY' => 'PKWY', + 'PARKWY' => 'PKWY', + 'PKWAY' => 'PKWY', + 'PKY' => 'PKWY', + 'PARKWAYS' => 'PKWY', + 'PKWYS' => 'PKWY', + 'PASSAGE' => 'PSGE', + 'PATHS' => 'PATH', + 'PIKES' => 'PIKE', + 'PINE' => 'PNE', + 'PINES' => 'PNES', + 'PLAIN' => 'PLN', + 'PLAINS' => 'PLNS', + 'PLAZA' => 'PLZ', + 'PLZA' => 'PLZ', + 'POINT' => 'PT', + 'POINTS' => 'PTS', + 'PORT' => 'PRT', + 'PORTS' => 'PRTS', + 'PRAIRIE' => 'PR', + 'PRR' => 'PR', + 'RAD' => 'RADL', + 'RADIAL' => 'RADL', + 'RADIEL' => 'RADL', + 'RANCH' => 'RNCH', + 'RANCHES' => 'RNCH', + 'RNCHS' => 'RNCH', + 'RAPID' => 'RPD', + 'RAPIDS' => 'RPDS', + 'REST' => 'RST', + 'RDGE' => 'RDG', + 'RIDGE' => 'RDG', + 'RIDGES' => 'RDGS', + 'RIVER' => 'RIV', + 'RVR' => 'RIV', + 'RIVR' => 'RIV', + 'ROAD' => 'RD', + 'ROADS' => 'RDS', + 'ROUTE' => 'RTE', + 'SHOAL' => 'SHL', + 'SHOALS' => 'SHLS', + 'SHOAR' => 'SHR', + 'SHORE' => 'SHR', + 'SHOARS' => 'SHRS', + 'SHORES' => 'SHRS', + 'SKYWAY' => 'SKWY', + 'SPNG' => 'SPG', + 'SPRING' => 'SPG', + 'SPRNG' => 'SPG', + 'SPNGS' => 'SPGS', + 'SPRINGS' => 'SPGS', + 'SPRNGS' => 'SPGS', + 'SPURS' => 'SPUR', + 'SQR' => 'SQ', + 'SQRE' => 'SQ', + 'SQU' => 'SQ', + 'SQUARE' => 'SQ', + 'SQRS' => 'SQS', + 'SQUARES' => 'SQS', + 'STATION' => 'STA', + 'STATN' => 'STA', + 'STN' => 'STA', + 'STRAV' => 'STRA', + 'STRAVEN' => 'STRA', + 'STRAVENUE' => 'STRA', + 'STRAVN' => 'STRA', + 'STRVN' => 'STRA', + 'STRVNUE' => 'STRA', + 'STREAM' => 'STRM', + 'STREME' => 'STRM', + 'STREET' => 'ST', + 'STRT' => 'ST', + 'STR' => 'ST', + 'STREETS' => 'STS', + 'SUMIT' => 'SMT', + 'SUMITT' => 'SMT', + 'SUMMIT' => 'SMT', + 'TERR' => 'TER', + 'TERRACE' => 'TER', + 'THROUGHWAY' => 'TRWY', + 'TRACE' => 'TRCE', + 'TRACES' => 'TRCE', + 'TRACK' => 'TRAK', + 'TRACKS' => 'TRAK', + 'TRK' => 'TRAK', + 'TRKS' => 'TRAK', + 'TRAFFICWAY' => 'TRFY', + 'TRAIL' => 'TRL', + 'TRAILS' => 'TRL', + 'TRLS' => 'TRL', + 'TRAILER' => 'TRLR', + 'TRLRS' => 'TRLR', + 'TUNEL' => 'TUNL', + 'TUNLS' => 'TUNL', + 'TUNNEL' => 'TUNL', + 'TUNNELS' => 'TUNL', + 'TUNNL' => 'TUNL', + 'TRNPK' => 'TPKE', + 'TURNPIKE' => 'TPKE', + 'TURNPK' => 'TPKE', + 'UNDERPASS' => 'UPAS', + 'UNION' => 'UN', + 'UNIONS' => 'UNS', + 'VALLEY' => 'VLY', + 'VALLY' => 'VLY', + 'VLLY' => 'VLY', + 'VALLEYS' => 'VLYS', + 'VDCT' => 'VIA', + 'VIADCT' => 'VIA', + 'VIADUCT' => 'VIA', + 'VIEW' => 'VW', + 'VIEWS' => 'VWS', + 'VILL' => 'VLG', + 'VILLAG' => 'VLG', + 'VILLAGE' => 'VLG', + 'VILLG' => 'VLG', + 'VILLIAGE' => 'VLG', + 'VILLAGES' => 'VLGS', + 'VILLE' => 'VL', + 'VIST' => 'VIS', + 'VISTA' => 'VIS', + 'VST' => 'VIS', + 'VSTA' => 'VIS', + 'WALKS' => 'WALK', + 'WY' => 'WAY', + 'WELL' => 'WL', + 'WELLS' => 'WLS' + ]; + const CARDINAL_TABLE = [ + "NORTH" => "N", + "SOUTH" => "S", + "EAST" => "E", + "WEST" => "W", + "NORTHWEST" => "NW", + "SOUTHWEST" => "SW", + "NORTHEAST" => "NE", + "SOUTHEAST" => "SE" + ]; + + /** + * Normalize a street name (ex. Street Road) + * @param string $street + * @param bool $python Set to false to use built-in less-accurate code, + * or true to use normalize.py and https://github.com/mcmire/address_standardization + * @return string + */ + public static function normalizeStreet(string $street, bool $python = true): string { + // Give the script a dummy house number so it doesn't get lost + $filler_address = "10000001 "; + + return str_replace($filler_address, "", static::normalizeAddress($filler_address . $street)); + } + + /** + * Normalize an address line (ex. 1234 street road) + * @param string $address + * @param bool $python Set to false to use built-in less-accurate code, + * or true to use normalize.py and https://github.com/mcmire/address_standardization + * @return string + * @throws Exception + */ + public static function normalizeAddress(string $address, bool $python = true): string { + global $SETTINGS; + try { + if (empty($SETTINGS["normalize_python_script"]) || !file_exists($SETTINGS["normalize_python_script"])) { + throw new Exception("failing back to builtin: python script missing"); + } + if (!$python) { + throw new Exception("failing back to builtin due to user request"); + } + + $escaped = escapeshellarg($address); + + $json = shell_exec($SETTINGS["normalize_python_script"] . " " . $escaped); + + $address = json_decode($json, true); + if (empty($address)) { + throw new Exception("failing back to builtin due to JSON error"); + } + + $address = $address["address_line_1"]; + return $address; + } catch (Exception $ex) { + $address = strtoupper(trim($address)); + + $address = static::normalizeSuffix($address); + $address = static::normalizeCardinals($address); + + return $address; + } + } + + private static function findReplace(string $str, array $lookuptable) { + foreach ($lookuptable as $find => $replace) { + if ($str == $find) { + $str = $replace; + break; + } + } + + return $str; + } + + private static function findReplaceAll(string $str, array $lookuptable, string $seperator = " ") { + $words = explode($seperator, $str); + for ($i = 0; $i < count($words); $i++) { + $words[$i] = static::findReplace($words[$i], $lookuptable); + } + + return implode($seperator, $words); + } + + /** + * Replace cardinal/compass directions with abbreviations + * @param string $street + * @return string + */ + public static function normalizeCardinals(string $street): string { + $street = strtoupper(trim($street)); + + return static::findReplaceAll($street, static::CARDINAL_TABLE); + } + + /** + * Replace the street suffix with the standard abbreviation. + * @param string $street + * @return string + */ + public static function normalizeSuffix(string $street): string { + $street = strtoupper(trim($street)); + + $parts = explode(" ", $street); + + $suffix = static::findReplace(end($parts), static::SUFFIX_TABLE); + + $parts[count($parts) - 1] = $suffix; + + return implode(" ", $parts); + } + +} diff --git a/lib/geoutil.lib.php b/lib/geoutil.lib.php new file mode 100644 index 0000000..63157a2 --- /dev/null +++ b/lib/geoutil.lib.php @@ -0,0 +1,157 @@ + $matches[1], + "state" => $matches[2], + "zip" => isset($matches[3]) ? $matches[3] : null + ]; +} + +function parse_citystate($citystate) { + $citystate = strtoupper(trim($citystate)); + + $regex = "/^(\w+)[,\s]+([A-Z]{2,})+$/"; + + if (!preg_match($regex, $citystate, $matches)) { + return null; + } + + return [ + "city" => $matches[1], + "state" => $matches[2] + ]; +} + +function geocode_returnresult($query) { + global $SETTINGS, $database; + + $geocoder = new \Geocoder\ProviderAggregator(); + $adapter = new \Http\Adapter\Guzzle6\Client(); + + $chain = new \Geocoder\Provider\Chain\Chain([ + new \Geocoder\Provider\LocalDatabase\LocalDatabase($database), + new \Geocoder\Provider\Mapbox\Mapbox($adapter, $SETTINGS["mapbox_key"]), + new \Geocoder\Provider\MapQuest\MapQuest($adapter, $SETTINGS["mapquest_key"]) + ]); + + $geocoder->registerProvider($chain); + + $results = $geocoder->geocodeQuery($query); + + + if ($results->count() > 0) { + $result = $results->first(); + } else { + header("Content-Type: application/json"); + return [ + "status" => "ERROR", + "message" => "That address doesn't seem to exist. If this is an error, please send the full address (including city, state, and ZIP) to support@netsyms.com.", + "address" => [ + "street" => "", + "postalCode" => "" + ], + "coords" => [ + 0, + 0 + ], + "accuracy" => [ + "ok" => false + ], + "provider" => "" + ]; + } + + $geolatitude = $result->getCoordinates()->getLatitude(); + $geolongitude = $result->getCoordinates()->getLongitude(); + + $accurate = !empty($result->getStreetNumber()); + + if ($accurate) { + $address = implode(" ", [$result->getStreetNumber(), $result->getStreetName()]); + } else { + $address = $result->getStreetName(); + } + + + return [ + "status" => "OK", + "address" => [ + "street" => ucwords(strtolower(StreetNormalizer::normalizeAddress($address))), + "postalCode" => $result->getPostalCode() + ], + "coords" => [ + $geolatitude, + $geolongitude + ], + "accuracy" => [ + "ok" => $accurate + ], + "provider" => $result->getProvidedBy() + ]; +} + +function geocode_addrstring($address) { + $query = Geocoder\Query\GeocodeQuery::create($address)->withLimit(1); + return geocode_returnresult($query); +} + +/** + * Geocode an address. + * @global type $SETTINGS + * @param type $number + * @param type $street + * @param type $unit + * @param type $city + * @param type $state + * @param type $zip + * @param type $country + * @param type $type + * @return type + */ +function geocode($number, $street, $unit = null, $city, $state, $zip = null, $country = null, $type = null) { + $address = "$number $street $city $state"; + $origaddress = "$number $street"; + + $query = Geocoder\Query\GeocodeQuery::create($address) + ->withLimit(1) + ->withData("number", $number) + ->withData("street", $street) + ->withData("city", $city) + ->withData("state", $state); + if (!is_null($zip) && preg_match("/^([0-9]{5})/", $zip, $matches)) { + if (count($matches) > 0) { + $query = $query->withData("zip", $matches[0]); + } + } + if (!is_null($unit) && !empty($unit)) { + $query = $query->withData("unit", $unit); + } + + if (!is_null($type) && count(array_diff(explode("|", $type), $SETTINGS["address_types"])) == 0) { + $query = $query->withData("locationtype", $type); + } + + if (!is_null($country) && preg_match("/^[A-Z]{2}$/", $country)) { + $query = $query->withData("country", $country); + } + + return geocode_returnresult($query); +}