diff --git a/src/Provider/ArcGISOnline/ArcGISOnline.php b/src/Provider/ArcGISOnline/ArcGISOnline.php index 8c581c692..71d36d3c3 100644 --- a/src/Provider/ArcGISOnline/ArcGISOnline.php +++ b/src/Provider/ArcGISOnline/ArcGISOnline.php @@ -14,6 +14,7 @@ use Geocoder\Collection; use Geocoder\Exception\InvalidArgument; +use Geocoder\Exception\InvalidCredentials; use Geocoder\Exception\InvalidServerResponse; use Geocoder\Exception\UnsupportedOperation; use Geocoder\Model\Address; @@ -32,7 +33,12 @@ final class ArcGISOnline extends AbstractHttpProvider implements Provider /** * @var string */ - const ENDPOINT_URL = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find?text=%s'; + const ENDPOINT_URL = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?SingleLine=%s'; + + /** + * @var string + */ + const TOKEN_ENDPOINT_URL = 'https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/geocodeAddresses?token=%s&addresses=%s'; /** * @var string @@ -45,14 +51,45 @@ final class ArcGISOnline extends AbstractHttpProvider implements Provider private $sourceCountry; /** + * @var string + * + * Currently valid ArcGIS World Geocoding Service token. + * https://developers.arcgis.com/rest/geocode/api-reference/geocoding-authenticate-a-request.htm + */ + private $token; + + /** + * ArcGIS World Geocoding Service. + * https://developers.arcgis.com/rest/geocode/api-reference/overview-world-geocoding-service.htm. + * * @param HttpClient $client An HTTP adapter + * @param string $token Your authentication token * @param string $sourceCountry Country biasing (optional) + * + * @return ArcGISOnline */ - public function __construct(HttpClient $client, string $sourceCountry = null) + public static function token( + HttpClient $client, + string $token, + string $sourceCountry = null + ) { + $provider = new self($client, $sourceCountry, $token); + + return $provider; + } + + /** + * @param HttpClient $client An HTTP adapter + * @param string $sourceCountry Country biasing (optional) + * @param string $token ArcGIS World Geocoding Service token + * Required for the geocodeAddresses endpoint + */ + public function __construct(HttpClient $client, string $sourceCountry = null, string $token = null) { parent::__construct($client); $this->sourceCountry = $sourceCountry; + $this->token = $token; } /** @@ -70,19 +107,25 @@ public function geocodeQuery(GeocodeQuery $query): Collection throw new InvalidArgument('Address cannot be empty.'); } - $url = sprintf(self::ENDPOINT_URL, urlencode($address)); + if (is_null($this->token)) { + $url = sprintf(self::ENDPOINT_URL, urlencode($address)); + } else { + $url = sprintf(self::TOKEN_ENDPOINT_URL, $this->token, urlencode($this->formatAddresses([$address]))); + } $json = $this->executeQuery($url, $query->getLimit()); + $property = is_null($this->token) ? 'candidates' : 'locations'; + // no result - if (empty($json->locations)) { + if (!property_exists($json, $property) || empty($json->{$property})) { return new AddressCollection([]); } $results = []; - foreach ($json->locations as $location) { - $data = $location->feature->attributes; + foreach ($json->{$property} as $location) { + $data = $location->attributes; - $coordinates = (array) $location->feature->geometry; + $coordinates = (array) $location->location; $streetName = !empty($data->StAddr) ? $data->StAddr : null; $streetNumber = !empty($data->AddNum) ? $data->AddNum : null; $city = !empty($data->City) ? $data->City : null; @@ -171,8 +214,11 @@ private function buildQuery(string $query, int $limit): string if (null !== $this->sourceCountry) { $query = sprintf('%s&sourceCountry=%s', $query, $this->sourceCountry); } + if (is_null($this->token)) { + $query = sprintf('%s&maxLocations=%d&outFields=*', $query, $limit); + } - return sprintf('%s&maxLocations=%d&f=%s&outFields=*', $query, $limit, 'json'); + return sprintf('%s&f=%s', $query, 'json'); } /** @@ -191,7 +237,39 @@ private function executeQuery(string $url, int $limit): \stdClass if (!isset($json)) { throw InvalidServerResponse::create($url); } + if (property_exists($json, 'error') && property_exists($json->error, 'message')) { + if ('Invalid Token' == $json->error->message) { + throw new InvalidCredentials(sprintf('Invalid token %s', $this->token)); + } + } return $json; } + + /** + * Formatter for 1..n addresses, for the geocodeAddresses endpoint. + * + * @param array $array an array of SingleLine addresses + * + * @return string an Array formatted as a JSON string + */ + private function formatAddresses(array $array): string + { + // Just in case, get rid of any custom, non-numeric indices. + $array = array_values($array); + + $addresses = [ + 'records' => [], + ]; + foreach ($array as $i => $address) { + $addresses['records'][] = [ + 'attributes' => [ + 'OBJECTID' => $i + 1, + 'SingleLine' => $address, + ], + ]; + } + + return json_encode($addresses); + } } diff --git a/src/Provider/ArcGISOnline/Readme.md b/src/Provider/ArcGISOnline/Readme.md index a9ee04da8..d3b2d293a 100644 --- a/src/Provider/ArcGISOnline/Readme.md +++ b/src/Provider/ArcGISOnline/Readme.md @@ -9,7 +9,36 @@ [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) This is the ArcGIS provider from the PHP Geocoder. This is a **READ ONLY** repository. See the -[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. +[main repo](https://github.com/geocoder-php/Geocoder) for information and documentation. + +## Usage + +```php +$httpClient = new \Http\Adapter\Guzzle6\Client(); + +$provider = new \Geocoder\Provider\ArcGISList\ArcGISList($httpClient); + +$result = $geocoder->geocodeQuery(GeocodeQuery::create('Buckingham Palace, London')); +``` + +### Storing results + +ArcGIS prohibits storing the results of geocoding transactions without providing +a valid ArcGIS Online token, which requires +[ArcGIS Online credentials](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-authenticate-a-request.htm). + +You can use the static `token` method on the provider to create a client which +uses your valid ArcGIS Online token: + +```php + +$httpClient = new \Http\Adapter\Guzzle6\Client(); + +// Client ID is required. Private key is optional. +$provider = \Geocoder\Provider\ArcGISList\ArcGISList::token($httpClient, 'your-token'); + +$result = $geocoder->geocodeQuery(GeocodeQuery::create('Buckingham Palace, London')); +``` ### Install @@ -26,5 +55,5 @@ geocoding). ### Contribute -Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or +Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or report any issues you find on the [issue tracker](https://github.com/geocoder-php/Geocoder/issues). diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_01011153a3b635e874fdc6d47086abc85fef7bb2 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_01011153a3b635e874fdc6d47086abc85fef7bb2 new file mode 100644 index 000000000..b2b6f6367 --- /dev/null +++ b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_01011153a3b635e874fdc6d47086abc85fef7bb2 @@ -0,0 +1 @@ +s:653:"{"address":{"Match_addr":"3-7 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","LongLabel":"3-7 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France, FRA","ShortLabel":"3-7 Avenue Gambetta","Addr_type":"StreetAddress","Type":"","PlaceName":"","AddNum":"5","Address":"5 Avenue Gambetta","Block":"","Sector":"","Neighborhood":"Amandiers","District":"20e Arrondissement","City":"Paris","MetroArea":"","Subregion":"Paris","Region":"Île-de-France","Territory":"","Postal":"75020","PostalExt":"","CountryCode":"FRA"},"location":{"x":2.3890068200591377,"y":48.863333541352212,"spatialReference":{"wkid":4326,"latestWkid":4326}}}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_1231a8e79c63a3e1f4a4e650d43739204679e436 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_1231a8e79c63a3e1f4a4e650d43739204679e436 new file mode 100644 index 000000000..6e4ccabb8 --- /dev/null +++ b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_1231a8e79c63a3e1f4a4e650d43739204679e436 @@ -0,0 +1 @@ +s:1320:"{"spatialReference":{"wkid":4326,"latestWkid":4326},"locations":[{"address":"5754 WI-23, Spring Green, Wisconsin, 53588","location":{"x":-90.13179576999994,"y":43.093662879000078},"score":100,"attributes":{"ResultID":1,"Loc_name":"World","Status":"M","Score":100,"Match_addr":"5754 WI-23, Spring Green, Wisconsin, 53588","LongLabel":"5754 WI-23, Spring Green, WI, 53588, USA","ShortLabel":"5754 WI-23","Addr_type":"StreetAddress","Type":"","PlaceName":"","Place_addr":"5754 WI-23, Spring Green, Wisconsin, 53588","Phone":"","URL":"","Rank":20,"AddBldg":"","AddNum":"5754","AddNumFrom":"5652","AddNumTo":"5754","AddRange":"5652-5754","Side":"L","StPreDir":"","StPreType":"","StName":"WI-23","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"5754 WI-23","Block":"","Sector":"","Nbrhd":"","District":"","City":"Spring Green","MetroArea":"","Subregion":"Iowa County","Region":"Wisconsin","RegionAbbr":"WI","Territory":"","Zone":"","Postal":"53588","PostalExt":"8912","Country":"USA","LangCode":"ENG","Distance":0,"X":-90.131795769692417,"Y":43.093662878656403,"DisplayX":-90.131795769692417,"DisplayY":43.093662878656403,"Xmin":-90.132795769692422,"Xmax":-90.130795769692412,"Ymin":43.092662878656405,"Ymax":43.094662878656401,"ExInfo":""}}]}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_1a09a6437be25de0e1eb0e1993822cc09aa6d6ed b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_1a09a6437be25de0e1eb0e1993822cc09aa6d6ed new file mode 100644 index 000000000..a49dac1ac --- /dev/null +++ b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_1a09a6437be25de0e1eb0e1993822cc09aa6d6ed @@ -0,0 +1 @@ +s:7589:"{"spatialReference":{"wkid":4326,"latestWkid":4326},"candidates":[{"address":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","location":{"x":2.3890699736723207,"y":48.863180009118821},"score":100,"attributes":{"Loc_name":"World","Status":"T","Score":100,"Match_addr":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","LongLabel":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France, FRA","ShortLabel":"10 Avenue Gambetta","Addr_type":"PointAddress","Type":"","PlaceName":"","Place_addr":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","Phone":"","URL":"","Rank":20,"AddBldg":"","AddNum":"10","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"R","StPreDir":"","StPreType":"Avenue","StName":"Gambetta","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"10 Avenue Gambetta","Block":"","Sector":"","Nbrhd":"Père Lachaise Réunion","District":"20e Arrondissement","City":"Paris","MetroArea":"","Subregion":"Paris","Region":"Île-de-France","RegionAbbr":"IDF","Territory":"","Zone":"","Postal":"75020","PostalExt":"","Country":"FRA","LangCode":"FRE","Distance":0,"X":2.3890166647681372,"Y":48.863242873392622,"DisplayX":2.3890699736723207,"DisplayY":48.863180009118821,"Xmin":2.3880699736723208,"Xmax":2.3900699736723205,"Ymin":48.862180009118823,"Ymax":48.864180009118819,"ExInfo":""},"extent":{"xmin":2.3880699736723208,"ymin":48.862180009118823,"xmax":2.3900699736723205,"ymax":48.864180009118819}},{"address":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","location":{"x":2.3984400194131013,"y":48.865300001979477},"score":100,"attributes":{"Loc_name":"World","Status":"T","Score":100,"Match_addr":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","LongLabel":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France, FRA","ShortLabel":"10 Avenue Gambetta","Addr_type":"PointAddress","Type":"","PlaceName":"","Place_addr":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","Phone":"","URL":"","Rank":20,"AddBldg":"","AddNum":"10","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"L","StPreDir":"","StPreType":"Avenue","StName":"Gambetta","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"10 Avenue Gambetta","Block":"","Sector":"","Nbrhd":"Gambetta","District":"20e Arrondissement","City":"Paris","MetroArea":"","Subregion":"Paris","Region":"Île-de-France","RegionAbbr":"IDF","Territory":"","Zone":"","Postal":"75020","PostalExt":"","Country":"FRA","LangCode":"FRE","Distance":0,"X":2.3986787360154822,"Y":48.865183661163428,"DisplayX":2.3984400194131013,"DisplayY":48.865300001979477,"Xmin":2.3974400194131014,"Xmax":2.3994400194131011,"Ymin":48.86430000197948,"Ymax":48.866300001979475,"ExInfo":""},"extent":{"xmin":2.3974400194131014,"ymin":48.86430000197948,"xmax":2.3994400194131011,"ymax":48.866300001979475}},{"address":"10 Place Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","location":{"x":2.3983800049863646,"y":48.865080018930627},"score":97.829999999999998,"attributes":{"Loc_name":"World","Status":"T","Score":97.829999999999998,"Match_addr":"10 Place Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","LongLabel":"10 Place Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France, FRA","ShortLabel":"10 Place Gambetta","Addr_type":"PointAddress","Type":"","PlaceName":"","Place_addr":"10 Place Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","Phone":"","URL":"","Rank":20,"AddBldg":"","AddNum":"10","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"L","StPreDir":"","StPreType":"Place","StName":"Gambetta","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"10 Place Gambetta","Block":"","Sector":"","Nbrhd":"Gambetta","District":"20e Arrondissement","City":"Paris","MetroArea":"","Subregion":"Paris","Region":"Île-de-France","RegionAbbr":"IDF","Territory":"","Zone":"","Postal":"75020","PostalExt":"","Country":"FRA","LangCode":"FRE","Distance":0,"X":2.398404563962663,"Y":48.865037271224445,"DisplayX":2.3983800049863646,"DisplayY":48.865080018930627,"Xmin":2.3973800049863647,"Xmax":2.3993800049863645,"Ymin":48.864080018930629,"Ymax":48.866080018930624,"ExInfo":""},"extent":{"xmin":2.3973800049863647,"ymin":48.864080018930629,"xmax":2.3993800049863645,"ymax":48.866080018930624}},{"address":"10 Passage Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","location":{"x":2.4020399630079226,"y":48.872190010208726},"score":97.829999999999998,"attributes":{"Loc_name":"World","Status":"T","Score":97.829999999999998,"Match_addr":"10 Passage Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","LongLabel":"10 Passage Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France, FRA","ShortLabel":"10 Passage Gambetta","Addr_type":"PointAddress","Type":"","PlaceName":"","Place_addr":"10 Passage Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","Phone":"","URL":"","Rank":20,"AddBldg":"","AddNum":"10","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"R","StPreDir":"","StPreType":"Passage","StName":"Gambetta","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"10 Passage Gambetta","Block":"","Sector":"","Nbrhd":"Télégraphe-Pelleport Saint-Fargeau","District":"20e Arrondissement","City":"Paris","MetroArea":"","Subregion":"Paris","Region":"Île-de-France","RegionAbbr":"IDF","Territory":"","Zone":"","Postal":"75020","PostalExt":"","Country":"FRA","LangCode":"FRE","Distance":0,"X":2.4020104587087521,"Y":48.872198727388025,"DisplayX":2.4020399630079226,"DisplayY":48.872190010208726,"Xmin":2.4010399630079227,"Xmax":2.4030399630079224,"Ymin":48.871190010208728,"Ymax":48.873190010208724,"ExInfo":""},"extent":{"xmin":2.4010399630079227,"ymin":48.871190010208728,"xmax":2.4030399630079224,"ymax":48.873190010208724}},{"address":"Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","location":{"x":2.391313868877178,"y":48.863858948830256},"score":97.409999999999997,"attributes":{"Loc_name":"World","Status":"T","Score":97.409999999999997,"Match_addr":"Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","LongLabel":"Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France, FRA","ShortLabel":"Avenue Gambetta","Addr_type":"StreetName","Type":"","PlaceName":"","Place_addr":"Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","Phone":"","URL":"","Rank":20,"AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"","StPreDir":"","StPreType":"Avenue","StName":"Gambetta","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"Avenue Gambetta","Block":"","Sector":"","Nbrhd":"Amandiers","District":"20e Arrondissement","City":"Paris","MetroArea":"","Subregion":"Paris","Region":"Île-de-France","RegionAbbr":"IDF","Territory":"","Zone":"","Postal":"75020","PostalExt":"","Country":"FRA","LangCode":"FRE","Distance":0,"X":2.391313868877178,"Y":48.863858948830256,"DisplayX":2.391313868877178,"DisplayY":48.863858948830256,"Xmin":2.3903138688771781,"Xmax":2.3923138688771779,"Ymin":48.862858948830258,"Ymax":48.864858948830253,"ExInfo":"10"},"extent":{"xmin":2.3903138688771781,"ymin":48.862858948830258,"xmax":2.3923138688771779,"ymax":48.864858948830253}}]}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_1ce0be7ae2d67336e2a518dd3178c52f76fbcce7 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_1ce0be7ae2d67336e2a518dd3178c52f76fbcce7 deleted file mode 100644 index 6a0f3491e..000000000 --- a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_1ce0be7ae2d67336e2a518dd3178c52f76fbcce7 +++ /dev/null @@ -1 +0,0 @@ -s:4697:"{"spatialReference":{"wkid":4326,"latestWkid":4326},"locations":[{"name":"Hannover, Niedersachsen, Deutschland","extent":{"xmin":9.6292190000000009,"ymin":52.266517,"xmax":9.8372189999999993,"ymax":52.474516999999999},"feature":{"geometry":{"x":9.7332192330004546,"y":52.370516553000471},"attributes":{"Loc_name":"Gaz.WorldGazetteer.POI1","Score":100,"Match_addr":"Hannover, Niedersachsen, Deutschland","Addr_type":"POI","Type":"State Capital","PlaceName":"Hannover","Place_addr":"","Phone":"","URL":"","Rank":"3","AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","Side":"","StPreDir":"","StPreType":"","StName":"","StType":"","StDir":"","StAddr":"","Nbrhd":"","City":"","Subregion":"","Region":"Niedersachsen","Postal":"","PostalExt":"","Country":"DEU","LangCode":"","Distance":0,"X":9.7332190000000001,"Y":52.370517,"DisplayX":9.7332190000000001,"DisplayY":52.370517,"Xmin":9.6292190000000009,"Xmax":9.8372189999999993,"Ymin":52.266517,"Ymax":52.474516999999999}}},{"name":"Hannover, North Dakota, United States","extent":{"xmin":-101.446538,"ymin":47.091388000000002,"xmax":-101.406538,"ymax":47.131388000000001},"feature":{"geometry":{"x":-101.42653668599968,"y":47.111387737000484},"attributes":{"Loc_name":"Gaz.WorldGazetteer.POI1","Score":100,"Match_addr":"Hannover, North Dakota, United States","Addr_type":"POI","Type":"City","PlaceName":"Hannover","Place_addr":"","Phone":"","URL":"","Rank":"12.5","AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","Side":"","StPreDir":"","StPreType":"","StName":"","StType":"","StDir":"","StAddr":"","Nbrhd":"","City":"","Subregion":"Oliver","Region":"North Dakota","Postal":"","PostalExt":"","Country":"USA","LangCode":"","Distance":0,"X":-101.42653799999999,"Y":47.111387999999998,"DisplayX":-101.42653799999999,"DisplayY":47.111387999999998,"Xmin":-101.446538,"Xmax":-101.406538,"Ymin":47.091388000000002,"Ymax":47.131388000000001}}},{"name":"Hannover, Maryland, United States","extent":{"xmin":-77.460260000000005,"ymin":39.371769,"xmax":-77.420259999999999,"ymax":39.411769},"feature":{"geometry":{"x":-77.44025867799968,"y":39.391769260000444},"attributes":{"Loc_name":"Gaz.WorldGazetteer.POI1","Score":100,"Match_addr":"Hannover, Maryland, United States","Addr_type":"POI","Type":"City","PlaceName":"Hannover","Place_addr":"","Phone":"","URL":"","Rank":"12.5","AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","Side":"","StPreDir":"","StPreType":"","StName":"","StType":"","StDir":"","StAddr":"","Nbrhd":"","City":"","Subregion":"Frederick","Region":"Maryland","Postal":"","PostalExt":"","Country":"USA","LangCode":"","Distance":0,"X":-77.440259999999995,"Y":39.391768999999996,"DisplayX":-77.440259999999995,"DisplayY":39.391768999999996,"Xmin":-77.460260000000005,"Xmax":-77.420259999999999,"Ymin":39.371769,"Ymax":39.411769}}},{"name":"Hannöver, Niedersachsen, Deutschland","extent":{"xmin":8.5029389999999996,"ymin":53.170198999999997,"xmax":8.5109390000000005,"ymax":53.178198999999999},"feature":{"geometry":{"x":8.5069385510004167,"y":53.174199236000504},"attributes":{"Loc_name":"Gaz.WorldGazetteer.POI1","Score":100,"Match_addr":"Hannöver, Niedersachsen, Deutschland","Addr_type":"POI","Type":"City","PlaceName":"Hannöver","Place_addr":"","Phone":"","URL":"","Rank":"12.5","AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","Side":"","StPreDir":"","StPreType":"","StName":"","StType":"","StDir":"","StAddr":"","Nbrhd":"","City":"","Subregion":"","Region":"Niedersachsen","Postal":"","PostalExt":"","Country":"DEU","LangCode":"","Distance":0,"X":8.5069389999999991,"Y":53.174199000000002,"DisplayX":8.5069389999999991,"DisplayY":53.174199000000002,"Xmin":8.5029389999999996,"Xmax":8.5109390000000005,"Ymin":53.170198999999997,"Ymax":53.178198999999999}}},{"name":"Hannover","extent":{"xmin":-48.854387000000003,"ymin":-26.286808000000001,"xmax":-48.844386999999998,"ymax":-26.276807999999999},"feature":{"geometry":{"x":-48.849386270999616,"y":-26.281806506999601},"attributes":{"Loc_name":"Gaz.WorldGazetteer.POI2","Score":100,"Match_addr":"Hannover","Addr_type":"POI","Type":"Hotel","PlaceName":"Hannover","Place_addr":"Rua Doutor João Colin, Joinville, Sul","Phone":"","URL":"","Rank":"19","AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","Side":"","StPreDir":"","StPreType":"","StName":"","StType":"","StDir":"","StAddr":"Rua Doutor João Colin","Nbrhd":"América","City":"Joinville","Subregion":"Santa Catarina","Region":"Sul","Postal":"","PostalExt":"","Country":"BRA","LangCode":"POR","Distance":0,"X":-48.849387,"Y":-26.281808000000002,"DisplayX":-48.849387,"DisplayY":-26.281808000000002,"Xmin":-48.854387000000003,"Xmax":-48.844386999999998,"Ymin":-26.286808000000001,"Ymax":-26.276807999999999}}}]}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_1dac1d346611ac8378808669fad531fcc546e3c2 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_1dac1d346611ac8378808669fad531fcc546e3c2 deleted file mode 100644 index eab38ddf4..000000000 --- a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_1dac1d346611ac8378808669fad531fcc546e3c2 +++ /dev/null @@ -1 +0,0 @@ -s:417:"{"address":{"Address":"3 Avenue Gambetta","Neighborhood":"20e Arrondissement","City":"Paris","Subregion":"Paris","Region":"Île-de-France","Postal":"75020","PostalExt":null,"CountryCode":"FRA","Match_addr":"3 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","Loc_name":"FRA.PointAddress"},"location":{"x":2.3890232823788717,"y":48.863307080996805,"spatialReference":{"wkid":4326,"latestWkid":4326}}}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_2d70fe233a6031e3cae5557256cc383c31577858 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_2d70fe233a6031e3cae5557256cc383c31577858 new file mode 100644 index 000000000..3ef5f2745 --- /dev/null +++ b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_2d70fe233a6031e3cae5557256cc383c31577858 @@ -0,0 +1 @@ +s:68:"{"spatialReference":{"wkid":4326,"latestWkid":4326},"candidates":[]}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_3d554607e103a79d60c7bd5d6caf2278ca326002 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_3d554607e103a79d60c7bd5d6caf2278ca326002 new file mode 100644 index 000000000..b7c8c9721 --- /dev/null +++ b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_3d554607e103a79d60c7bd5d6caf2278ca326002 @@ -0,0 +1 @@ +s:651:"{"address":{"Match_addr":"1603-1607 H St NW, Washington, District of Columbia, 20006","LongLabel":"1603-1607 H St NW, Washington, DC, 20006, USA","ShortLabel":"1603-1607 H St NW","Addr_type":"StreetAddress","Type":"","PlaceName":"","AddNum":"1607","Address":"1607 H St NW","Block":"","Sector":"","Neighborhood":"Connecticut Avenue/K Street","District":"","City":"Washington","MetroArea":"Washington DC Metro Area","Subregion":"District of Columbia","Region":"District of Columbia","Territory":"","Postal":"20006","PostalExt":"","CountryCode":"USA"},"location":{"x":-77.036991,"y":38.900257325952872,"spatialReference":{"wkid":4326,"latestWkid":4326}}}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_3ebba005094fe820c607f3791b4087a71d00e854 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_3ebba005094fe820c607f3791b4087a71d00e854 new file mode 100644 index 000000000..be1963369 --- /dev/null +++ b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_3ebba005094fe820c607f3791b4087a71d00e854 @@ -0,0 +1 @@ +s:61:"{"error":{"code":498,"message":"Invalid Token","details":[]}}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_432c074000723c94e37a2554ab99af1deaaa74ba b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_432c074000723c94e37a2554ab99af1deaaa74ba deleted file mode 100644 index e015466ea..000000000 --- a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_432c074000723c94e37a2554ab99af1deaaa74ba +++ /dev/null @@ -1 +0,0 @@ -s:4635:"{"spatialReference":{"wkid":4326,"latestWkid":4326},"locations":[{"name":"10 Downing Street, London, SW1A 2","extent":{"xmin":-0.128608,"ymin":51.502234999999999,"xmax":-0.126608,"ymax":51.504235000000001},"feature":{"geometry":{"x":-0.12760742099959543,"y":51.503234853000492},"attributes":{"Loc_name":"GBR.StreetAddress","Score":100,"Match_addr":"10 Downing Street, London, SW1A 2","Addr_type":"StreetAddress","Type":"","PlaceName":"","Place_addr":"","Phone":"","URL":"","Rank":"","AddBldg":"","AddNum":"10","AddNumFrom":"1","AddNumTo":"12","Side":"R","StPreDir":"","StPreType":"","StName":"Downing Street","StType":"Street","StDir":"","StAddr":"10 Downing Street","Nbrhd":"","City":"London","Subregion":"","Region":"London","Postal":"SW1A 2","PostalExt":"","Country":"GBR","LangCode":"ENG","Distance":0,"X":-0.127608,"Y":51.503234999999997,"DisplayX":-0.127608,"DisplayY":51.503234999999997,"Xmin":-0.128608,"Xmax":-0.126608,"Ymin":51.502234999999999,"Ymax":51.504235000000001}}},{"name":"10 Downing Court, London, WC1N 1","extent":{"xmin":-0.124581,"ymin":51.522365000000001,"xmax":-0.122581,"ymax":51.524365000000003},"feature":{"geometry":{"x":-0.12358029499955592,"y":51.523364551000498},"attributes":{"Loc_name":"GBR.StreetAddress","Score":87.760000000000005,"Match_addr":"10 Downing Court, London, WC1N 1","Addr_type":"StreetAddress","Type":"","PlaceName":"","Place_addr":"","Phone":"","URL":"","Rank":"","AddBldg":"","AddNum":"10","AddNumFrom":"1","AddNumTo":"16","Side":"R","StPreDir":"","StPreType":"","StName":"Downing Court","StType":"Court","StDir":"","StAddr":"10 Downing Court","Nbrhd":"","City":"London","Subregion":"","Region":"London","Postal":"WC1N 1","PostalExt":"","Country":"GBR","LangCode":"ENG","Distance":0,"X":-0.123581,"Y":51.523364999999998,"DisplayX":-0.123581,"DisplayY":51.523364999999998,"Xmin":-0.124581,"Xmax":-0.122581,"Ymin":51.522365000000001,"Ymax":51.524365000000003}}},{"name":"10 Downings, London, E6 6","extent":{"xmin":0.064957000000000001,"ymin":51.511741999999998,"xmax":0.066957000000000003,"ymax":51.513742000000001},"feature":{"geometry":{"x":0.065956714000435568,"y":51.512742433000483},"attributes":{"Loc_name":"GBR.StreetAddress","Score":86.769999999999996,"Match_addr":"10 Downings, London, E6 6","Addr_type":"StreetAddress","Type":"","PlaceName":"","Place_addr":"","Phone":"","URL":"","Rank":"","AddBldg":"","AddNum":"10","AddNumFrom":"2","AddNumTo":"22","Side":"R","StPreDir":"","StPreType":"","StName":"Downings","StType":"","StDir":"","StAddr":"10 Downings","Nbrhd":"","City":"London","Subregion":"","Region":"London","Postal":"E6 6","PostalExt":"","Country":"GBR","LangCode":"ENG","Distance":0,"X":0.065957000000000002,"Y":51.512742000000003,"DisplayX":0.065957000000000002,"DisplayY":51.512742000000003,"Xmin":0.064957000000000001,"Xmax":0.066957000000000003,"Ymin":51.511741999999998,"Ymax":51.513742000000001}}},{"name":"Downing Street, London, SW1A 2","extent":{"xmin":-0.129081,"ymin":51.501170000000002,"xmax":-0.125081,"ymax":51.50517},"feature":{"geometry":{"x":-0.12708007299954716,"y":51.503170023000507},"attributes":{"Loc_name":"GBR.StreetName","Score":100,"Match_addr":"Downing Street, London, SW1A 2","Addr_type":"StreetName","Type":"","PlaceName":"","Place_addr":"","Phone":"","URL":"","Rank":"","AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","Side":"","StPreDir":"","StPreType":"","StName":"Downing Street","StType":"Street","StDir":"","StAddr":"Downing Street","Nbrhd":"","City":"London","Subregion":"","Region":"London","Postal":"SW1A 2","PostalExt":"","Country":"GBR","LangCode":"ENG","Distance":0,"X":-0.127081,"Y":51.503169999999997,"DisplayX":-0.127081,"DisplayY":51.503169999999997,"Xmin":-0.129081,"Xmax":-0.125081,"Ymin":51.501170000000002,"Ymax":51.50517}}},{"name":"London","extent":{"xmin":-0.17721100000000001,"ymin":51.456420000000001,"xmax":-0.077211000000000002,"ymax":51.556420000000003},"feature":{"geometry":{"x":-0.12721005099956528,"y":51.506420009000465},"attributes":{"Loc_name":"GBR.AdminPlaces","Score":100,"Match_addr":"London","Addr_type":"Locality","Type":"","PlaceName":"","Place_addr":"","Phone":"","URL":"","Rank":"1","AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","Side":"","StPreDir":"","StPreType":"","StName":"","StType":"","StDir":"","StAddr":"","Nbrhd":"London","City":"London","Subregion":"","Region":"London","Postal":"","PostalExt":"","Country":"GBR","LangCode":"ENG","Distance":0,"X":-0.12721099999999999,"Y":51.506419999999999,"DisplayX":-0.12721099999999999,"DisplayY":51.506419999999999,"Xmin":-0.17721100000000001,"Xmax":-0.077211000000000002,"Ymin":51.456420000000001,"Ymax":51.556420000000003}}}]}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_515d2e7b47db3a6caee90d685acbd69e7fc2d693 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_515d2e7b47db3a6caee90d685acbd69e7fc2d693 new file mode 100644 index 000000000..f53462229 --- /dev/null +++ b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_515d2e7b47db3a6caee90d685acbd69e7fc2d693 @@ -0,0 +1 @@ +s:4185:"{"spatialReference":{"wkid":4326,"latestWkid":4326},"candidates":[{"address":"10 Downing Street, London, England, SW1A 2","location":{"x":-0.12766996404513975,"y":51.503359983443914},"score":100,"attributes":{"Loc_name":"World","Status":"M","Score":100,"Match_addr":"10 Downing Street, London, England, SW1A 2","LongLabel":"10 Downing Street, London, England, SW1A 2, GBR","ShortLabel":"10 Downing Street","Addr_type":"PointAddress","Type":"","PlaceName":"","Place_addr":"10 Downing Street, London, England, SW1A 2","Phone":"","URL":"","Rank":20,"AddBldg":"","AddNum":"10","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"R","StPreDir":"","StPreType":"","StName":"Downing","StType":"Street","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"10 Downing Street","Block":"","Sector":"","Nbrhd":"","District":"","City":"London","MetroArea":"","Subregion":"London","Region":"England","RegionAbbr":"ENG","Territory":"","Zone":"Westminster","Postal":"SW1A 2","PostalExt":"AA","Country":"GBR","LangCode":"ENG","Distance":0,"X":-0.12767826212928152,"Y":51.503247414484292,"DisplayX":-0.12766996404513975,"DisplayY":51.503359983443914,"Xmin":-0.12866996404513975,"Xmax":-0.12666996404513975,"Ymin":51.502359983443917,"Ymax":51.504359983443912,"ExInfo":""},"extent":{"xmin":-0.12866996404513975,"ymin":51.502359983443917,"xmax":-0.12666996404513975,"ymax":51.504359983443912}},{"address":"10 Downing Court, London, England, WC1N 1","location":{"x":-0.12356545010100203,"y":51.523305627492263},"score":97.829999999999998,"attributes":{"Loc_name":"World","Status":"M","Score":97.829999999999998,"Match_addr":"10 Downing Court, London, England, WC1N 1","LongLabel":"10 Downing Court, London, England, WC1N 1, GBR","ShortLabel":"10 Downing Court","Addr_type":"StreetAddress","Type":"","PlaceName":"","Place_addr":"10 Downing Court, London, England, WC1N 1","Phone":"","URL":"","Rank":20,"AddBldg":"","AddNum":"10","AddNumFrom":"1","AddNumTo":"16","AddRange":"1-16","Side":"R","StPreDir":"","StPreType":"","StName":"Downing","StType":"Court","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"10 Downing Court","Block":"","Sector":"","Nbrhd":"","District":"","City":"London","MetroArea":"","Subregion":"London","Region":"England","RegionAbbr":"ENG","Territory":"","Zone":"St Pancras","Postal":"WC1N 1","PostalExt":"","Country":"GBR","LangCode":"ENG","Distance":0,"X":-0.12356545010100203,"Y":51.523305627492263,"DisplayX":-0.12356545010100203,"DisplayY":51.523305627492263,"Xmin":-0.12456545010100203,"Xmax":-0.12256545010100203,"Ymin":51.522305627492266,"Ymax":51.524305627492261,"ExInfo":""},"extent":{"xmin":-0.12456545010100203,"ymin":51.522305627492266,"xmax":-0.12256545010100203,"ymax":51.524305627492261}},{"address":"10 Downings, London, England, E6 6","location":{"x":0.06595996211561328,"y":51.512900014181099},"score":96.590000000000003,"attributes":{"Loc_name":"World","Status":"M","Score":96.590000000000003,"Match_addr":"10 Downings, London, England, E6 6","LongLabel":"10 Downings, London, England, E6 6, GBR","ShortLabel":"10 Downings","Addr_type":"PointAddress","Type":"","PlaceName":"","Place_addr":"10 Downings, London, England, E6 6","Phone":"","URL":"","Rank":20,"AddBldg":"","AddNum":"10","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"R","StPreDir":"","StPreType":"","StName":"Downings","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"10 Downings","Block":"","Sector":"","Nbrhd":"","District":"","City":"London","MetroArea":"","Subregion":"London","Region":"England","RegionAbbr":"ENG","Territory":"","Zone":"Beckton","Postal":"E6 6","PostalExt":"","Country":"GBR","LangCode":"ENG","Distance":0,"X":0.065941438109599862,"Y":51.512747463543342,"DisplayX":0.06595996211561328,"DisplayY":51.512900014181099,"Xmin":0.064959962115613279,"Xmax":0.066959962115613281,"Ymin":51.511900014181101,"Ymax":51.513900014181097,"ExInfo":""},"extent":{"xmin":0.064959962115613279,"ymin":51.511900014181101,"xmax":0.066959962115613281,"ymax":51.513900014181097}}]}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_8ecf5f1fef7d551b9c90afe05ab806479c0c3272 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_8ecf5f1fef7d551b9c90afe05ab806479c0c3272 deleted file mode 100644 index 2f3bbbf66..000000000 --- a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_8ecf5f1fef7d551b9c90afe05ab806479c0c3272 +++ /dev/null @@ -1 +0,0 @@ -s:67:"{"spatialReference":{"wkid":4326,"latestWkid":4326},"locations":[]}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_95e98a16ccff8138223d767d3ec6393c8b909ec2 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_95e98a16ccff8138223d767d3ec6393c8b909ec2 new file mode 100644 index 000000000..3ef5f2745 --- /dev/null +++ b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_95e98a16ccff8138223d767d3ec6393c8b909ec2 @@ -0,0 +1 @@ +s:68:"{"spatialReference":{"wkid":4326,"latestWkid":4326},"candidates":[]}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_b94a6d7f271cd02d10e005b60bcdcc07af97ba96 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_b94a6d7f271cd02d10e005b60bcdcc07af97ba96 deleted file mode 100644 index 876b4e238..000000000 --- a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_b94a6d7f271cd02d10e005b60bcdcc07af97ba96 +++ /dev/null @@ -1 +0,0 @@ -s:147:"{"error":{"code":400,"message":"Cannot perform query. Invalid query parameters.","details":["Unable to find address for the specified location."]}}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_c7abb019bf97168e3592af5c1bade9fa1776e583 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_c7abb019bf97168e3592af5c1bade9fa1776e583 deleted file mode 100644 index a251d0d75..000000000 --- a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_c7abb019bf97168e3592af5c1bade9fa1776e583 +++ /dev/null @@ -1 +0,0 @@ -s:5299:"{"spatialReference":{"wkid":4326,"latestWkid":4326},"locations":[{"name":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","extent":{"xmin":2.3880270000000001,"ymin":48.862253000000003,"xmax":2.3900269999999999,"ymax":48.864252999999998},"feature":{"geometry":{"x":2.3890265860004547,"y":48.863252753000495},"attributes":{"Loc_name":"FRA.PointAddress","Score":100,"Match_addr":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","Addr_type":"PointAddress","Type":"","PlaceName":"","Place_addr":"","Phone":"","URL":"","Rank":"","AddBldg":"","AddNum":"10","AddNumFrom":"","AddNumTo":"","Side":"R","StPreDir":"","StPreType":"Avenue","StName":"Gambetta","StType":"","StDir":"","StAddr":"10 Avenue Gambetta","Nbrhd":"20e Arrondissement","City":"Paris","Subregion":"Paris","Region":"Île-de-France","Postal":"75020","PostalExt":"","Country":"FRA","LangCode":"FRE","Distance":0,"X":2.389027,"Y":48.863253,"DisplayX":2.3890699999999998,"DisplayY":48.86318,"Xmin":2.3880270000000001,"Xmax":2.3900269999999999,"Ymin":48.862253000000003,"Ymax":48.864252999999998}}},{"name":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","extent":{"xmin":2.3977059999999999,"ymin":48.864201999999999,"xmax":2.3997060000000001,"ymax":48.866202000000001},"feature":{"geometry":{"x":2.3987059300004034,"y":48.865202498000485},"attributes":{"Loc_name":"FRA.PointAddress","Score":100,"Match_addr":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","Addr_type":"PointAddress","Type":"","PlaceName":"","Place_addr":"","Phone":"","URL":"","Rank":"","AddBldg":"","AddNum":"10","AddNumFrom":"","AddNumTo":"","Side":"L","StPreDir":"","StPreType":"Avenue","StName":"Gambetta","StType":"","StDir":"","StAddr":"10 Avenue Gambetta","Nbrhd":"20e Arrondissement","City":"Paris","Subregion":"Paris","Region":"Île-de-France","Postal":"75020","PostalExt":"","Country":"FRA","LangCode":"FRE","Distance":0,"X":2.3987059999999998,"Y":48.865201999999996,"DisplayX":2.3984399999999999,"DisplayY":48.865299999999998,"Xmin":2.3977059999999999,"Xmax":2.3997060000000001,"Ymin":48.864201999999999,"Ymax":48.866202000000001}}},{"name":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","extent":{"xmin":2.3878010000000001,"ymin":48.862192999999998,"xmax":2.3898009999999998,"ymax":48.864193},"feature":{"geometry":{"x":2.3888008510004397,"y":48.863193011000476},"attributes":{"Loc_name":"FRA.StreetAddress","Score":100,"Match_addr":"10 Avenue Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","Addr_type":"StreetAddress","Type":"","PlaceName":"","Place_addr":"","Phone":"","URL":"","Rank":"","AddBldg":"","AddNum":"10","AddNumFrom":"8","AddNumTo":"16","Side":"R","StPreDir":"","StPreType":"Avenue","StName":"Gambetta","StType":"","StDir":"","StAddr":"10 Avenue Gambetta","Nbrhd":"20e Arrondissement","City":"Paris","Subregion":"Paris","Region":"Île-de-France","Postal":"75020","PostalExt":"","Country":"FRA","LangCode":"FRE","Distance":0,"X":2.388801,"Y":48.863193000000003,"DisplayX":2.388801,"DisplayY":48.863193000000003,"Xmin":2.3878010000000001,"Xmax":2.3898009999999998,"Ymin":48.862192999999998,"Ymax":48.864193}}},{"name":"10 Place Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","extent":{"xmin":2.397427,"ymin":48.864136999999999,"xmax":2.3994270000000002,"ymax":48.866137000000002},"feature":{"geometry":{"x":2.3984267120004574,"y":48.865136839000456},"attributes":{"Loc_name":"FRA.StreetAddress","Score":84.069999999999993,"Match_addr":"10 Place Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","Addr_type":"StreetAddress","Type":"","PlaceName":"","Place_addr":"","Phone":"","URL":"","Rank":"","AddBldg":"","AddNum":"10","AddNumFrom":"10","AddNumTo":"8","Side":"L","StPreDir":"","StPreType":"Place","StName":"Gambetta","StType":"","StDir":"","StAddr":"10 Place Gambetta","Nbrhd":"20e Arrondissement","City":"Paris","Subregion":"Paris","Region":"Île-de-France","Postal":"75020","PostalExt":"","Country":"FRA","LangCode":"FRE","Distance":0,"X":2.3984269999999999,"Y":48.865136999999997,"DisplayX":2.3984269999999999,"DisplayY":48.865136999999997,"Xmin":2.397427,"Xmax":2.3994270000000002,"Ymin":48.864136999999999,"Ymax":48.866137000000002}}},{"name":"10 Passage Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","extent":{"xmin":2.4010570000000002,"ymin":48.871127999999999,"xmax":2.403057,"ymax":48.873128000000001},"feature":{"geometry":{"x":2.4020572500004391,"y":48.872127939000507},"attributes":{"Loc_name":"FRA.StreetAddress","Score":84.069999999999993,"Match_addr":"10 Passage Gambetta, 75020, 20e Arrondissement, Paris, Île-de-France","Addr_type":"StreetAddress","Type":"","PlaceName":"","Place_addr":"","Phone":"","URL":"","Rank":"","AddBldg":"","AddNum":"10","AddNumFrom":"2","AddNumTo":"32","Side":"R","StPreDir":"","StPreType":"Passage","StName":"Gambetta","StType":"","StDir":"","StAddr":"10 Passage Gambetta","Nbrhd":"20e Arrondissement","City":"Paris","Subregion":"Paris","Region":"Île-de-France","Postal":"75020","PostalExt":"","Country":"FRA","LangCode":"FRE","Distance":0,"X":2.4020570000000001,"Y":48.872127999999996,"DisplayX":2.4020570000000001,"DisplayY":48.872127999999996,"Xmin":2.4010570000000002,"Xmax":2.403057,"Ymin":48.871127999999999,"Ymax":48.873128000000001}}}]}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_cec6934eb0dd48c6df916f7bb4e3b529dbdcd987 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_cec6934eb0dd48c6df916f7bb4e3b529dbdcd987 deleted file mode 100644 index 2f3bbbf66..000000000 --- a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_cec6934eb0dd48c6df916f7bb4e3b529dbdcd987 +++ /dev/null @@ -1 +0,0 @@ -s:67:"{"spatialReference":{"wkid":4326,"latestWkid":4326},"locations":[]}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_d3125f5ef97748b899feb60216aa6d7794f8b9e4 b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_d3125f5ef97748b899feb60216aa6d7794f8b9e4 deleted file mode 100644 index cd15b7392..000000000 --- a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_d3125f5ef97748b899feb60216aa6d7794f8b9e4 +++ /dev/null @@ -1 +0,0 @@ -s:394:"{"address":{"Address":"800 16th St NW","Neighborhood":null,"City":"Washington","Subregion":null,"Region":"District of Columbia","Postal":"20006","PostalExt":null,"CountryCode":"USA","Match_addr":"800 16th St NW, Washington, District of Columbia, 20006","Loc_name":"USA.PointAddress"},"location":{"x":-77.036585430395661,"y":38.90051027770501,"spatialReference":{"wkid":4326,"latestWkid":4326}}}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_d34258095230696c13312bcfb445fe533235edae b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_d34258095230696c13312bcfb445fe533235edae new file mode 100644 index 000000000..f2c87ee76 --- /dev/null +++ b/src/Provider/ArcGISOnline/Tests/.cached_responses/geocode.arcgis.com_d34258095230696c13312bcfb445fe533235edae @@ -0,0 +1 @@ +s:6238:"{"spatialReference":{"wkid":4326,"latestWkid":4326},"candidates":[{"address":"Hannover, Niedersachsen","location":{"x":9.7381500000000756,"y":52.372270000000071},"score":100,"attributes":{"Loc_name":"World","Status":"T","Score":100,"Match_addr":"Hannover, Niedersachsen","LongLabel":"Hannover, Niedersachsen, DEU","ShortLabel":"Hannover","Addr_type":"Locality","Type":"City","PlaceName":"Hannover","Place_addr":"Hannover, Niedersachsen","Phone":"","URL":"","Rank":3,"AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"","StPreDir":"","StPreType":"","StName":"","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"","Block":"","Sector":"","Nbrhd":"","District":"","City":"Hannover","MetroArea":"","Subregion":"Region Hannover","Region":"Niedersachsen","RegionAbbr":"NI","Territory":"","Zone":"","Postal":"","PostalExt":"","Country":"DEU","LangCode":"GER","Distance":0,"X":9.7381500000000756,"Y":52.372270000000071,"DisplayX":9.7381500000000756,"DisplayY":52.372270000000071,"Xmin":9.6221500000000759,"Xmax":9.8541500000000752,"Ymin":52.256270000000072,"Ymax":52.488270000000071,"ExInfo":""},"extent":{"xmin":9.6221500000000759,"ymin":52.256270000000072,"xmax":9.8541500000000752,"ymax":52.488270000000071}},{"address":"Hannover, Maryland","location":{"x":-77.440259999999967,"y":39.391770000000065},"score":100,"attributes":{"Loc_name":"World","Status":"T","Score":100,"Match_addr":"Hannover, Maryland","LongLabel":"Hannover, MD, USA","ShortLabel":"Hannover","Addr_type":"Locality","Type":"City","PlaceName":"Hannover","Place_addr":"Hannover, Maryland","Phone":"","URL":"","Rank":12.5,"AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"","StPreDir":"","StPreType":"","StName":"","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"","Block":"","Sector":"","Nbrhd":"","District":"","City":"Hannover","MetroArea":"","Subregion":"Frederick","Region":"Maryland","RegionAbbr":"MD","Territory":"","Zone":"","Postal":"","PostalExt":"","Country":"USA","LangCode":"ENG","Distance":0,"X":-77.440259999999967,"Y":39.391770000000065,"DisplayX":-77.440259999999967,"DisplayY":39.391770000000065,"Xmin":-77.460259999999963,"Xmax":-77.420259999999971,"Ymin":39.371770000000062,"Ymax":39.411770000000068,"ExInfo":""},"extent":{"xmin":-77.460259999999963,"ymin":39.371770000000062,"xmax":-77.420259999999971,"ymax":39.411770000000068}},{"address":"Hannöver, Niedersachsen","location":{"x":8.5069400000000428,"y":53.174200000000042},"score":100,"attributes":{"Loc_name":"World","Status":"T","Score":100,"Match_addr":"Hannöver, Niedersachsen","LongLabel":"Hannöver, Niedersachsen, DEU","ShortLabel":"Hannöver","Addr_type":"Locality","Type":"City","PlaceName":"Hannöver","Place_addr":"Hannöver, Niedersachsen","Phone":"","URL":"","Rank":12.5,"AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"","StPreDir":"","StPreType":"","StName":"","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"","Block":"","Sector":"","Nbrhd":"","District":"","City":"Hannöver","MetroArea":"","Subregion":"","Region":"Niedersachsen","RegionAbbr":"","Territory":"","Zone":"","Postal":"","PostalExt":"","Country":"DEU","LangCode":"GER","Distance":0,"X":8.5069400000000428,"Y":53.174200000000042,"DisplayX":8.5069400000000428,"DisplayY":53.174200000000042,"Xmin":8.5029400000000432,"Xmax":8.5109400000000424,"Ymin":53.170200000000044,"Ymax":53.178200000000039,"ExInfo":""},"extent":{"xmin":8.5029400000000432,"ymin":53.170200000000044,"xmax":8.5109400000000424,"ymax":53.178200000000039}},{"address":"Hannover, North Dakota","location":{"x":-101.42142999999999,"y":47.111290000000054},"score":100,"attributes":{"Loc_name":"World","Status":"T","Score":100,"Match_addr":"Hannover, North Dakota","LongLabel":"Hannover, ND, USA","ShortLabel":"Hannover","Addr_type":"Locality","Type":"Village","PlaceName":"Hannover","Place_addr":"Hannover, North Dakota","Phone":"","URL":"","Rank":15,"AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"","StPreDir":"","StPreType":"","StName":"","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"","Block":"","Sector":"","Nbrhd":"","District":"","City":"Hannover","MetroArea":"","Subregion":"Oliver County","Region":"North Dakota","RegionAbbr":"ND","Territory":"","Zone":"","Postal":"","PostalExt":"","Country":"USA","LangCode":"ENG","Distance":0,"X":-101.42142999999999,"Y":47.111290000000054,"DisplayX":-101.42142999999999,"DisplayY":47.111290000000054,"Xmin":-101.43142999999999,"Xmax":-101.41142999999998,"Ymin":47.101290000000056,"Ymax":47.121290000000052,"ExInfo":""},"extent":{"xmin":-101.43142999999999,"ymin":47.101290000000056,"xmax":-101.41142999999998,"ymax":47.121290000000052}},{"address":"Hannover, Mississippi","location":{"x":-90.062989999999957,"y":32.518790000000024},"score":100,"attributes":{"Loc_name":"World","Status":"T","Score":100,"Match_addr":"Hannover, Mississippi","LongLabel":"Hannover, MS, USA","ShortLabel":"Hannover","Addr_type":"Locality","Type":"Neighborhood","PlaceName":"Hannover","Place_addr":"Mississippi","Phone":"","URL":"","Rank":15,"AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"","StPreDir":"","StPreType":"","StName":"","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"","Block":"","Sector":"","Nbrhd":"Hannover","District":"","City":"","MetroArea":"","Subregion":"Madison County","Region":"Mississippi","RegionAbbr":"MS","Territory":"","Zone":"","Postal":"","PostalExt":"","Country":"USA","LangCode":"ENG","Distance":0,"X":-90.062989999999957,"Y":32.518790000000024,"DisplayX":-90.062989999999957,"DisplayY":32.518790000000024,"Xmin":-90.072989999999962,"Xmax":-90.052989999999951,"Ymin":32.508790000000026,"Ymax":32.528790000000022,"ExInfo":""},"extent":{"xmin":-90.072989999999962,"ymin":32.508790000000026,"xmax":-90.052989999999951,"ymax":32.528790000000022}}]}"; \ No newline at end of file diff --git a/src/Provider/ArcGISOnline/Tests/ArcGISOnlineTest.php b/src/Provider/ArcGISOnline/Tests/ArcGISOnlineTest.php index 4fec2cc38..5bc70d941 100644 --- a/src/Provider/ArcGISOnline/Tests/ArcGISOnlineTest.php +++ b/src/Provider/ArcGISOnline/Tests/ArcGISOnlineTest.php @@ -82,10 +82,42 @@ public function testGeocodeWithRealAddress() $this->assertNull($result->getTimezone()); } + public function testGeocodeWithToken() + { + if (!isset($_SERVER['ARCGIS_TOKEN'])) { + $this->markTestSkipped('You need to configure the ARCGIS_TOKEN value in phpunit.xml'); + } + $provider = ArcGISOnline::token($this->getHttpClient(), $_SERVER['ARCGIS_TOKEN']); + $results = $provider->geocodeQuery(GeocodeQuery::create('5754 WI-23, Spring Green, WI 53588, USA')); + + $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); + + /** @var Location $result */ + $result = $results->first(); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(43.093663, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-90.131796, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertEquals(5754, $result->getStreetNumber()); + $this->assertEquals('5754 WI-23', $result->getStreetName()); + $this->assertEquals(53588, $result->getPostalCode()); + $this->assertEquals('Spring Green', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('Wisconsin', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('Iowa County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('USA', $result->getCountry()->getCode()); + + $this->assertNull($result->getBounds()); + $this->assertNull($result->getSubLocality()); + $this->assertNull($result->getAdminLevels()->get(2)->getCode()); + $this->assertNull($result->getAdminLevels()->get(1)->getCode()); + $this->assertNull($result->getCountry()->getName()); + $this->assertNull($result->getTimezone()); + } + public function testGeocodeWithInvalidAddressWithSourceCountry() { - $provider = new ArcGISOnline($this->getHttpClient(), 'Denmark', true); - $result = $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); + $provider = new ArcGISOnline($this->getHttpClient(), 'DNK'); + $result = $provider->geocodeQuery(GeocodeQuery::create('1 Chome-1-2 Oshiage, Sumida, Tokyo 131-8634, Japan')); $this->assertInstanceOf(Collection::class, $result); $this->assertEquals(0, $result->count()); @@ -105,7 +137,7 @@ public function testReverseWithRealCoordinates() $this->assertEquals(48.863279997000461, $result->getCoordinates()->getLatitude(), '', 0.0001); $this->assertEquals(2.3890199980004354, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getStreetNumber()); - $this->assertEquals('3 Avenue Gambetta', $result->getStreetName()); + $this->assertEquals('5 Avenue Gambetta', $result->getStreetName()); $this->assertEquals(75020, $result->getPostalCode()); $this->assertEquals('Paris', $result->getLocality()); $this->assertEquals('FRA', $result->getCountry()->getCode()); @@ -128,13 +160,13 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->first(); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.370518568000477, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(9.7332166860004463, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertEquals(52.37227000000007, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(9.738150000000076, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getStreetName()); $this->assertNull($result->getPostalCode()); - $this->assertNull($result->getLocality()); - $this->assertCount(1, $result->getAdminLevels()); + $this->assertEquals('Hannover', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Niedersachsen', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('DEU', $result->getCountry()->getCode()); @@ -146,45 +178,47 @@ public function testGeocodeWithCity() /** @var Location $result */ $result = $results->get(1); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(47.111386795000499, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(-101.4265391569997, $result->getCoordinates()->getLongitude(), '', 0.0001); - $this->assertNull($result->getStreetName()); - $this->assertNull($result->getLocality()); - $this->assertCount(2, $result->getAdminLevels()); - $this->assertEquals('North Dakota', $result->getAdminLevels()->get(1)->getName()); - $this->assertEquals('USA', $result->getCountry()->getCode()); - - /** @var Location $result */ - $result = $results->get(2); - $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(39.391768472000479, $result->getCoordinates()->getLatitude(), '', 0.0001); $this->assertEquals(-77.440257128999633, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getStreetName()); - $this->assertNull($result->getLocality()); + $this->assertEquals('Hannover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Maryland', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('USA', $result->getCountry()->getCode()); /** @var Location $result */ - $result = $results->get(3); + $result = $results->get(2); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(53.174198173, $result->getCoordinates()->getLatitude(), '', 0.0001); $this->assertEquals(8.5069383810005, $result->getCoordinates()->getLongitude(), '', 0.0001); $this->assertNull($result->getStreetName()); - $this->assertNull($result->getLocality()); + $this->assertEquals('Hannöver', $result->getLocality()); $this->assertCount(1, $result->getAdminLevels()); $this->assertEquals('Niedersachsen', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('DEU', $result->getCountry()->getCode()); + /** @var Location $result */ + $result = $results->get(3); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(47.111290000000054, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-101.42142999999999, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertNull($result->getStreetName()); + $this->assertEquals('Hannover', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('North Dakota', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('USA', $result->getCountry()->getCode()); + /** @var Location $result */ $result = $results->get(4); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(-26.281805980999593, $result->getCoordinates()->getLatitude(), '', 0.0001); - $this->assertEquals(-48.849389793999649, $result->getCoordinates()->getLongitude(), '', 0.0001); - $this->assertEquals('Rua Doutor João Colin', $result->getStreetName()); + $this->assertEquals(32.518790000000024, $result->getCoordinates()->getLatitude(), '', 0.0001); + $this->assertEquals(-90.06298999999996, $result->getCoordinates()->getLongitude(), '', 0.0001); + $this->assertNull($result->getStreetName()); + $this->assertNull($result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); - $this->assertEquals('Sul', $result->getAdminLevels()->get(1)->getName()); - $this->assertEquals('BRA', $result->getCountry()->getCode()); + $this->assertEquals('Mississippi', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('Madison County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('USA', $result->getCountry()->getCode()); } /** @@ -206,4 +240,14 @@ public function testGeocodeWithRealIPv6() $provider = new ArcGISOnline($this->getHttpClient()); $provider->geocodeQuery(GeocodeQuery::create('::ffff:88.188.221.14')); } + + /** + * @expectedException \Geocoder\Exception\InvalidCredentials + * @expectedExceptionMessage Invalid token invalid-token + */ + public function testGeocodeWithInvalidToken() + { + $provider = ArcGISOnline::token($this->getHttpClient(), 'invalid-token'); + $results = $provider->geocodeQuery(GeocodeQuery::create('1313 Disneyland Dr, Anaheim, CA 92802, USA')); + } } diff --git a/src/Provider/ArcGISOnline/Tests/IntegrationTest.php b/src/Provider/ArcGISOnline/Tests/IntegrationTest.php index d9c992b84..cd4fd8911 100644 --- a/src/Provider/ArcGISOnline/Tests/IntegrationTest.php +++ b/src/Provider/ArcGISOnline/Tests/IntegrationTest.php @@ -25,6 +25,10 @@ class IntegrationTest extends ProviderIntegrationTest protected $testIpv6 = false; + protected $skippedTests = [ + 'testReverseQueryWithNoResults' => 'ArcGIS REST API returns "אצטדיון כדורגל עירוני" for reverse query at 0,0.', + ]; + protected function createProvider(HttpClient $httpClient) { return new ArcGISOnline($httpClient); diff --git a/src/Provider/ArcGISOnline/phpunit.xml.dist b/src/Provider/ArcGISOnline/phpunit.xml.dist index a158c9a38..f32adc6ed 100644 --- a/src/Provider/ArcGISOnline/phpunit.xml.dist +++ b/src/Provider/ArcGISOnline/phpunit.xml.dist @@ -7,6 +7,7 @@ bootstrap="vendor/autoload.php" > +