From 3022c12156436be577b2e596c7b6087a8eb8b993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Mon, 14 May 2018 11:33:35 +0100 Subject: [PATCH 1/5] Changes to common files for PR #840 --- src/Common/Query/GeocodeQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Common/Query/GeocodeQuery.php b/src/Common/Query/GeocodeQuery.php index 46be7ed1c..1f193dd72 100644 --- a/src/Common/Query/GeocodeQuery.php +++ b/src/Common/Query/GeocodeQuery.php @@ -19,7 +19,7 @@ /** * @author Tobias Nyholm */ -final class GeocodeQuery implements Query +class GeocodeQuery implements Query { /** * The address or text that should be geocoded. From c05351abcfe4cfa9f11166d97da1859c1d16f2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Mon, 14 May 2018 11:33:35 +0100 Subject: [PATCH 2/5] MapQuest support 5Box address specification --- src/Provider/MapQuest/GeocodeQuery.php | 109 ++++++ src/Provider/MapQuest/GetAddressInterface.php | 21 ++ src/Provider/MapQuest/MapQuest.php | 329 +++++++++++++++--- src/Provider/MapQuest/Readme.md | 59 ++++ ...m_00e393f649a7c0571a788302e9b747eb2ed102e8 | 1 - ..._0e6c6ae415a9f06275a1cf806b84b76ce02b7067} | 2 +- ...m_18d9ead8c32cddb4a3e06b17971685ea711214a5 | 2 +- ...m_2936b2a8b50cb1ed2c60f2a47b928148410464b6 | 1 + ...m_2c689521a921228087301ae7c2b4aac6b14d56f8 | 1 + ...m_6d58a2755e3b2b48c91491749077d0bff866e466 | 1 - ...m_78a9d0bf0db0faee36f1bdda968c372699dded44 | 1 + ..._7eebf1200cb65bb0572e14a007e02c1c4f92ac27} | 2 +- ...m_8466d8c846339d0fabe066566868adab6fd26bbe | 1 + ...m_8e66a9540d4157894f4c9c78173254892f289f6e | 1 - ...m_d23f5a3ba833ade87000e0eed0b4435615e066b0 | 1 + ...m_df6afc6a1f7550fdef3174b5bf434bc25e98ba89 | 1 + ..._e46463942e3d84f3742ae7b44b16c2c587b401a8} | 2 +- ..._f811f4ea729035e359bca202ff88ecd5a7fd17c7} | 2 +- src/Provider/MapQuest/Tests/MapQuestTest.php | 279 ++++++++++++++- 19 files changed, 747 insertions(+), 69 deletions(-) create mode 100644 src/Provider/MapQuest/GeocodeQuery.php create mode 100644 src/Provider/MapQuest/GetAddressInterface.php delete mode 100644 src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_00e393f649a7c0571a788302e9b747eb2ed102e8 rename src/Provider/MapQuest/Tests/.cached_responses/{open.mapquestapi.com_ab45b4bc10e142bdede13b52b19edc0adf411759 => open.mapquestapi.com_0e6c6ae415a9f06275a1cf806b84b76ce02b7067} (63%) create mode 100644 src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_2936b2a8b50cb1ed2c60f2a47b928148410464b6 create mode 100644 src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_2c689521a921228087301ae7c2b4aac6b14d56f8 delete mode 100644 src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_6d58a2755e3b2b48c91491749077d0bff866e466 create mode 100644 src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_78a9d0bf0db0faee36f1bdda968c372699dded44 rename src/Provider/MapQuest/Tests/.cached_responses/{open.mapquestapi.com_91756cf6f4ac43dc3046c9a8a4c48fdaaa16d5f1 => open.mapquestapi.com_7eebf1200cb65bb0572e14a007e02c1c4f92ac27} (84%) create mode 100644 src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_8466d8c846339d0fabe066566868adab6fd26bbe delete mode 100644 src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_8e66a9540d4157894f4c9c78173254892f289f6e create mode 100644 src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_d23f5a3ba833ade87000e0eed0b4435615e066b0 create mode 100644 src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_df6afc6a1f7550fdef3174b5bf434bc25e98ba89 rename src/Provider/MapQuest/Tests/.cached_responses/{open.mapquestapi.com_44aea91743871378ac841bf130d569bb55d4787e => open.mapquestapi.com_e46463942e3d84f3742ae7b44b16c2c587b401a8} (85%) rename src/Provider/MapQuest/Tests/.cached_responses/{open.mapquestapi.com_d6c5af9b89f9861e0cdb3f3a578e84957c063dd5 => open.mapquestapi.com_f811f4ea729035e359bca202ff88ecd5a7fd17c7} (71%) diff --git a/src/Provider/MapQuest/GeocodeQuery.php b/src/Provider/MapQuest/GeocodeQuery.php new file mode 100644 index 000000000..97f30f489 --- /dev/null +++ b/src/Provider/MapQuest/GeocodeQuery.php @@ -0,0 +1,109 @@ +data[static::DATA_KEY_ADDRESS] = $address; + } else { + if (empty($address)) { + throw new InvalidArgument('Geocode query cannot be empty'); + } + $this->text = $address; + } + } + + public static function create(string $text): BaseGeocodeQuery + { + return new self($text); + } + + public static function createFromAddress(Location $address): self + { + return new self($address); + } + + public function withText(string $text): BaseGeocodeQuery + { + $new = clone $this; + $new->text = $text; + + return $new; + } + + public function withData(string $name, $value): BaseGeocodeQuery + { + $new = clone $this; + $new->data[$name] = $value; + + return $new; + } + + public function getAddress() + { + return $this->getData(static::DATA_KEY_ADDRESS); + } + + public function getText(): string + { + if (!$this->text) { + $address = $this->getAddress(); + if ($address instanceof Location) { + $this->text = $this->formatAddress($address); + } + } + + return $this->text; + } + + public function getData(string $name, $default = null) + { + if (!array_key_exists($name, $this->data)) { + return $default; + } + + return $this->data[$name]; + } + + public function getAllData(): array + { + return $this->data; + } + + protected function formatAddress(Location $address): string + { + $formatter = new StringFormatter(); + + return trim($formatter->format($address, '%n %S, %L, %a1 %z, %C')); + } +} diff --git a/src/Provider/MapQuest/GetAddressInterface.php b/src/Provider/MapQuest/GetAddressInterface.php new file mode 100644 index 000000000..c6a1c08e8 --- /dev/null +++ b/src/Provider/MapQuest/GetAddressInterface.php @@ -0,0 +1,21 @@ + */ final class MapQuest extends AbstractHttpProvider implements Provider { - /** - * @var string - */ - const OPEN_GEOCODE_ENDPOINT_URL = 'https://open.mapquestapi.com/geocoding/v1/address?location=%s&outFormat=json&maxResults=%d&key=%s&thumbMaps=false'; + const KEY_API_KEY = 'key'; - /** - * @var string - */ - const OPEN_REVERSE_ENDPOINT_URL = 'https://open.mapquestapi.com/geocoding/v1/reverse?key=%s&lat=%F&lng=%F'; + const KEY_LOCATION = 'location'; - /** - * @var string - */ - const LICENSED_GEOCODE_ENDPOINT_URL = 'https://www.mapquestapi.com/geocoding/v1/address?location=%s&outFormat=json&maxResults=%d&key=%s&thumbMaps=false'; + const KEY_OUT_FORMAT = 'outFormat'; - /** - * @var string - */ - const LICENSED_REVERSE_ENDPOINT_URL = 'https://www.mapquestapi.com/geocoding/v1/reverse?key=%s&lat=%F&lng=%F'; + const KEY_MAX_RESULTS = 'maxResults'; + + const KEY_THUMB_MAPS = 'thumbMaps'; + + const KEY_INTL_MODE = 'intlMode'; + + const KEY_BOUNDING_BOX = 'boundingBox'; + + const KEY_LAT = 'lat'; + + const KEY_LNG = 'lng'; + + const MODE_5BOX = '5BOX'; + + const OPEN_BASE_URL = 'https://open.mapquestapi.com/geocoding/v1/'; + + const LICENSED_BASE_URL = 'https://www.mapquestapi.com/geocoding/v1/'; + + const GEOCODE_ENDPOINT = 'address'; + + const DEFAULT_GEOCODE_PARAMS = [ + self::KEY_LOCATION => '', + self::KEY_OUT_FORMAT => 'json', + self::KEY_API_KEY => '', + ]; + + const DEFAULT_GEOCODE_OPTIONS = [ + self::KEY_MAX_RESULTS => 3, + self::KEY_THUMB_MAPS => false, + ]; + + const REVERSE_ENDPOINT = 'reverse'; + + const ADMIN_LEVEL_STATE = 1; + + const ADMIN_LEVEL_COUNTY = 2; /** * MapQuest offers two geocoding endpoints one commercial (true) and one open (false) @@ -56,17 +87,23 @@ final class MapQuest extends AbstractHttpProvider implements Provider */ private $licensed; + /** + * @var bool + */ + private $useRoadPosition; + /** * @var string */ private $apiKey; /** - * @param HttpClient $client an HTTP adapter - * @param string $apiKey an API key - * @param bool $licensed true to use MapQuest's licensed endpoints, default is false to use the open endpoints (optional) + * @param HttpClient $client an HTTP adapter + * @param string $apiKey an API key + * @param bool $licensed true to use MapQuest's licensed endpoints, default is false to use the open endpoints (optional) + * @param bool $useRoadPosition true to use nearest point on a road for the entrance, false to use map display position */ - public function __construct(HttpClient $client, string $apiKey, bool $licensed = false) + public function __construct(HttpClient $client, string $apiKey, bool $licensed = false, bool $useRoadPosition = false) { if (empty($apiKey)) { throw new InvalidCredentials('No API key provided.'); @@ -74,28 +111,67 @@ public function __construct(HttpClient $client, string $apiKey, bool $licensed = $this->apiKey = $apiKey; $this->licensed = $licensed; + $this->useRoadPosition = $useRoadPosition; parent::__construct($client); } /** * {@inheritdoc} */ - public function geocodeQuery(GeocodeQuery $query): Collection + public function geocodeQuery(CommonGeocodeQuery $query): Collection { - $address = $query->getText(); + $params = static::DEFAULT_GEOCODE_PARAMS; + $params[static::KEY_API_KEY] = $this->apiKey; + + $options = static::DEFAULT_GEOCODE_OPTIONS; + $options[static::KEY_MAX_RESULTS] = $query->getLimit(); + + $useGetQuery = true; + + $address = $this->extractAddressFromQuery($query); + if ($address instanceof Location) { + $params[static::KEY_LOCATION] = $this->mapAddressToArray($address); + $options[static::KEY_INTL_MODE] = static::MODE_5BOX; + $useGetQuery = false; + } else { + $addressAsText = $query->getText(); + + if (!$addressAsText) { + throw new InvalidArgument('Cannot geocode empty address'); + } - // This API doesn't handle IPs - if (filter_var($address, FILTER_VALIDATE_IP)) { - throw new UnsupportedOperation('The MapQuest provider does not support IP addresses, only street addresses.'); + // This API doesn't handle IPs + if (filter_var($addressAsText, FILTER_VALIDATE_IP)) { + throw new UnsupportedOperation('The MapQuest provider does not support IP addresses, only street addresses.'); + } + + $params[static::KEY_LOCATION] = $addressAsText; } - if ($this->licensed) { - $url = sprintf(self::LICENSED_GEOCODE_ENDPOINT_URL, urlencode($address), $query->getLimit(), $this->apiKey); + $bounds = $query->getBounds(); + if ($bounds instanceof Bounds) { + $options[static::KEY_BOUNDING_BOX] = $this->mapBoundsToArray($bounds); + $useGetQuery = false; + } + + if ($useGetQuery) { + $params = $this->addOptionsForGetQuery($params, $options); + + return $this->executeGetQuery(static::GEOCODE_ENDPOINT, $params); } else { - $url = sprintf(self::OPEN_GEOCODE_ENDPOINT_URL, urlencode($address), $query->getLimit(), $this->apiKey); + $params = $this->addOptionsForPostQuery($params, $options); + + return $this->executePostQuery(static::GEOCODE_ENDPOINT, $params); + } + } + + private function extractAddressFromQuery(CommonGeocodeQuery $query) + { + if ($query instanceof GetAddressInterface) { + return $query->getAddress(); } - return $this->executeQuery($url); + return $query->getData(GeocodeQuery::DATA_KEY_ADDRESS); } /** @@ -107,13 +183,13 @@ public function reverseQuery(ReverseQuery $query): Collection $longitude = $coordinates->getLongitude(); $latitude = $coordinates->getLatitude(); - if ($this->licensed) { - $url = sprintf(self::LICENSED_REVERSE_ENDPOINT_URL, $this->apiKey, $latitude, $longitude); - } else { - $url = sprintf(self::OPEN_REVERSE_ENDPOINT_URL, $this->apiKey, $latitude, $longitude); - } + $params = [ + static::KEY_API_KEY => $this->apiKey, + static::KEY_LAT => $latitude, + static::KEY_LNG => $longitude, + ]; - return $this->executeQuery($url); + return $this->executeGetQuery(static::REVERSE_ENDPOINT, $params); } /** @@ -124,14 +200,77 @@ public function getName(): string return 'map_quest'; } + private function getUrl($endpoint): string + { + if ($this->licensed) { + $baseUrl = static::LICENSED_BASE_URL; + } else { + $baseUrl = static::OPEN_BASE_URL; + } + + return $baseUrl.$endpoint; + } + + private function addGetQuery(string $url, array $params): string + { + return $url.'?'.http_build_query($params, '', '&', PHP_QUERY_RFC3986); + } + + private function addOptionsForGetQuery(array $params, array $options): array + { + foreach ($options as $key => $value) { + if (false === $value) { + $value = 'false'; + } elseif (true === $value) { + $value = 'true'; + } + $params[$key] = $value; + } + + return $params; + } + + private function addOptionsForPostQuery(array $params, array $options): array + { + $params['options'] = $options; + + return $params; + } + + private function executePostQuery(string $endpoint, array $params) + { + $url = $this->getUrl($endpoint); + + $appKey = $params[static::KEY_API_KEY]; + unset($params[static::KEY_API_KEY]); + $url .= '?key='.$appKey; + + $requestBody = json_encode($params); + $request = $this->getMessageFactory()->createRequest('POST', $url, [], $requestBody); + + $response = $this->getHttpClient()->sendRequest($request); + $content = $this->parseHttpResponse($response, $url); + + return $this->parseResponseContent($content); + } + /** * @param string $url * * @return AddressCollection */ - private function executeQuery(string $url): AddressCollection + private function executeGetQuery(string $endpoint, array $params): AddressCollection { + $baseUrl = $this->getUrl($endpoint); + $url = $this->addGetQuery($baseUrl, $params); + $content = $this->getUrlContents($url); + + return $this->parseResponseContent($content); + } + + private function parseResponseContent(string $content): AddressCollection + { $json = json_decode($content, true); if (!isset($json['results']) || empty($json['results'])) { @@ -149,20 +288,37 @@ private function executeQuery(string $url): AddressCollection if ($location['street'] || $location['postalCode'] || $location['adminArea5'] || $location['adminArea4'] || $location['adminArea3']) { $admins = []; - if ($location['adminArea3']) { - $admins[] = ['name' => $location['adminArea3'], 'level' => 1]; + $state = $location['adminArea3']; + if ($state) { + $code = null; + if (2 == strlen($state)) { + $code = $state; + } + $admins[] = [ + 'name' => $state, + 'code' => $code, + 'level' => static::ADMIN_LEVEL_STATE, + ]; } if ($location['adminArea4']) { - $admins[] = ['name' => $location['adminArea4'], 'level' => 2]; + $admins[] = ['name' => $location['adminArea4'], 'level' => static::ADMIN_LEVEL_COUNTY]; + } + + $position = $location['latLng']; + if (!$this->useRoadPosition) { + if ($location['displayLatLng']) { + $position = $location['displayLatLng']; + } } $results[] = Address::createFromArray([ 'providedBy' => $this->getName(), - 'latitude' => $location['latLng']['lat'], - 'longitude' => $location['latLng']['lng'], + 'latitude' => $position['lat'], + 'longitude' => $position['lng'], 'streetName' => $location['street'] ?: null, 'locality' => $location['adminArea5'] ?: null, + 'subLocality' => $location['adminArea6'] ?: null, 'postalCode' => $location['postalCode'] ?: null, 'adminLevels' => $admins, 'country' => $location['adminArea1'] ?: null, @@ -171,10 +327,93 @@ private function executeQuery(string $url): AddressCollection } } - if (empty($results)) { - return new AddressCollection([]); + return new AddressCollection($results); + } + + private function mapAddressToArray(Location $address): array + { + $location = []; + + $streetParts = [ + trim($address->getStreetNumber() ?: ''), + trim($address->getStreetName() ?: ''), + ]; + $street = implode(' ', array_filter($streetParts)); + if ($street) { + $location['street'] = $street; } - return new AddressCollection($results); + if ($address->getSubLocality()) { + $location['adminArea6'] = $address->getSubLocality(); + $location['adminArea6Type'] = 'Neighborhood'; + } + + if ($address->getLocality()) { + $location['adminArea5'] = $address->getLocality(); + $location['adminArea5Type'] = 'City'; + } + + /** @var AdminLevel $adminLevel */ + foreach ($address->getAdminLevels() as $adminLevel) { + switch ($adminLevel->getLevel()) { + case static::ADMIN_LEVEL_STATE: + $state = $adminLevel->getCode(); + if (!$state) { + $state = $adminLevel->getName(); + } + $location['adminArea3'] = $state; + $location['adminArea3Type'] = 'State'; + + break; + case static::ADMIN_LEVEL_COUNTY: + $county = $adminLevel->getName(); + $location['adminArea4'] = $county; + $location['adminArea4Type'] = 'County'; + } + } + + $country = $address->getCountry(); + if ($country instanceof Country) { + $code = $country->getCode(); + if (!$code) { + $code = $country->getName(); + } + $location['adminArea1'] = $code; + $location['adminArea1Type'] = 'Country'; + } + + $postalCode = $address->getPostalCode(); + if ($postalCode) { + $location['postalCode'] = $address->getPostalCode(); + } + + return $location; + } + + private function mapBoundsToArray(Bounds $bounds) + { + return [ + 'ul' => [static::KEY_LAT => $bounds->getNorth(), static::KEY_LNG => $bounds->getWest()], + 'lr' => [static::KEY_LAT => $bounds->getSouth(), static::KEY_LNG => $bounds->getEast()], + ]; + } + + protected function parseHttpResponse(ResponseInterface $response, string $url): string + { + $statusCode = $response->getStatusCode(); + if (401 === $statusCode || 403 === $statusCode) { + throw new InvalidCredentials(); + } elseif (429 === $statusCode) { + throw new QuotaExceeded(); + } elseif ($statusCode >= 300) { + throw InvalidServerResponse::create($url, $statusCode); + } + + $body = (string) $response->getBody(); + if (empty($body)) { + throw InvalidServerResponse::emptyResponse($url); + } + + return $body; } } diff --git a/src/Provider/MapQuest/Readme.md b/src/Provider/MapQuest/Readme.md index 6b0e4ca9a..859cd4c20 100644 --- a/src/Provider/MapQuest/Readme.md +++ b/src/Provider/MapQuest/Readme.md @@ -16,6 +16,65 @@ This is the MapQuest provider from the PHP Geocoder. This is a **READ ONLY** rep composer require geocoder-php/mapquest-provider ``` +### Geocode with more exact addresses + +The MapQuest Provider allows you to create and pass geocode queries based on a full Address object of +class `Geocoder\Model\Address` or any other object that implements `Geocoder\Location`. + +This will take advantage of what MapQuest calls the 5-box Input address format. +Quote from [MapQuest Developer: Specifying Locations](https://developer.mapquest.com/documentation/common/forming-locations/): +> The 5-Box Input address format (which is compatible with JSON and XML), +> allows for a higher degree of address specification by entering the full address in its individual location parameters. +> The 5-Box Input format is beneficial as it bypasses the parsing functionality of the single-line request. + +To pass an Address object as a part of the geocode query, we provide the class `Geocoder\Provider\MapQuest\GeocodeQuery`. +An object of class `Geocoder\Provider\MapQuest\GeocodeQuery` can be passed instead of the regular `Geocoder\Query\GeocodeQuery` +as the argument to the `geocodeQuery` method of the provider. If you have an object of a class that implements +`Geocoder\Location` stored in the variable `$address`, this new type of GeocodeQuery can be created with: +``` +$query = \Geocoder\Provider\MapQuest\GeocodeQuery::createFromAddress($address); +``` + +This new GeocodeQuery class will also work fine with all the other providers. It will provide them with +a text version of the address when they require a location as a string instead of a `Geocoder\Location` implementation. + +**Example** +``` +use Geocoder\Model\AddressBuilder; +use Geocoder\Provider\MapQuest\GeocodeQuery as MapQuestGeocodeQuery; +use Geocoder\Provider\MapQuest\MapQuest; + +$provider = new MapQuest($httpClient, $apiKey); + +$addressBuilder = new AddressBuilder('Address provided by me'); +$addressBuilder + ->setStreetNumber(4868) + ->setStreetName('Payne Rd'); + ->setLocality('Nashville'); + ->setSubLocality('Antioch'); + ->setAdminLevels([ + new AdminLevel(1, 'Tennessee', 'TN') + ]) + ->setPostalCode('37013'); + ->setCountry('USA'); + ->setCountryCode('US'); +$address = $addressBuilder->build(); + +$query = MapQuestGeocodeQuery::createFromAddress($address); +$results = $provider->geocodeQuery($query); +``` + + +Alternatively you may use the regular `Geocoder\Query\GeocodeQuery` instead with the address passed as data, like this: +``` +use Geocoder\Model\Address; +use Geocoder\Provider\MapQuest\GeocodeQuery as MapQuestGeocodeQuery; +use Geocoder\Query\GeocodeQuery; + +$address = new Address( ... ); +$query = GeocodeQuery::create('location string'); +$query = $query->withData(MapQuestGeocodeQuery::DATA_KEY_ADDRESS, $address); +``` ### Contribute Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_00e393f649a7c0571a788302e9b747eb2ed102e8 b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_00e393f649a7c0571a788302e9b747eb2ed102e8 deleted file mode 100644 index 1c3dd6c90..000000000 --- a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_00e393f649a7c0571a788302e9b747eb2ed102e8 +++ /dev/null @@ -1 +0,0 @@ -s:1068:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2016 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2016 MapQuest, Inc."},"messages":[]},"options":{"maxResults":1,"thumbMaps":true,"ignoreLatLngInput":false},"results":[{"providedLocation":{"latLng":{"lat":54.048407,"lng":-2.799034}},"locations":[{"street":"Collegian W.M.C.","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Lancaster","adminArea5Type":"City","adminArea4":"","adminArea4Type":"County","adminArea3":"England","adminArea3Type":"State","adminArea1":"GB","adminArea1Type":"Country","postalCode":"LA1 1NP","geocodeQualityCode":"P1AAA","geocodeQuality":"POINT","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":54.048412,"lng":-2.798955},"displayLatLng":{"lat":54.048412,"lng":-2.798955},"mapUrl":"http://open.mapquestapi.com/staticmap/v4/getmap?key=io5RY14NTLzVuX48xoga7ICStRa8bOpR&type=map&size=225,160&pois=purple-1,54.0484116,-2.7989546,0,0,|¢er=54.0484116,-2.7989546&zoom=15&rand=-824440547"}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_ab45b4bc10e142bdede13b52b19edc0adf411759 b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_0e6c6ae415a9f06275a1cf806b84b76ce02b7067 similarity index 63% rename from src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_ab45b4bc10e142bdede13b52b19edc0adf411759 rename to src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_0e6c6ae415a9f06275a1cf806b84b76ce02b7067 index 301942614..6f49ee846 100644 --- a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_ab45b4bc10e142bdede13b52b19edc0adf411759 +++ b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_0e6c6ae415a9f06275a1cf806b84b76ce02b7067 @@ -1 +1 @@ -s:2788:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2016 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2016 MapQuest, Inc."},"messages":[]},"options":{"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"location":"Hanover"},"locations":[{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"Region Hannover","adminArea4Type":"County","adminArea3":"Lower Saxony","adminArea3Type":"State","adminArea1":"DE","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":52.374478,"lng":9.738553},"displayLatLng":{"lat":52.374478,"lng":9.738553}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"","adminArea5Type":"City","adminArea4":"Hanover","adminArea4Type":"County","adminArea3":"","adminArea3Type":"State","adminArea1":"JM","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A4XAX","geocodeQuality":"COUNTY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":18.384049,"lng":-78.131485},"displayLatLng":{"lat":18.384049,"lng":-78.131485}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"Grafton County","adminArea4Type":"County","adminArea3":"NH","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":43.703307,"lng":-72.288566},"displayLatLng":{"lat":43.703307,"lng":-72.288566}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"York County","adminArea4Type":"County","adminArea3":"PA","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":39.806325,"lng":-76.984273},"displayLatLng":{"lat":39.806325,"lng":-76.984273}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"","adminArea5Type":"City","adminArea4":"Hanover County","adminArea4Type":"County","adminArea3":"VA","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A4XXX","geocodeQuality":"COUNTY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":37.744783,"lng":-77.446416},"displayLatLng":{"lat":37.744783,"lng":-77.446416}}]}]}"; \ No newline at end of file +s:2793:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2018 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2018 MapQuest, Inc."},"messages":[]},"options":{"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"location":"Hanover"},"locations":[{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"Region Hannover","adminArea4Type":"County","adminArea3":"Lower Saxony","adminArea3Type":"State","adminArea1":"DE","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":52.374478,"lng":9.738553},"displayLatLng":{"lat":52.374478,"lng":9.738553}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"","adminArea5Type":"City","adminArea4":"Hanover","adminArea4Type":"County","adminArea3":"","adminArea3Type":"State","adminArea1":"JM","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A4XAX","geocodeQuality":"COUNTY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":18.384049,"lng":-78.131485},"displayLatLng":{"lat":18.384049,"lng":-78.131485}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"Grafton County","adminArea4Type":"County","adminArea3":"NH","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":43.703622,"lng":-72.288666},"displayLatLng":{"lat":43.703622,"lng":-72.288666}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"York County","adminArea4Type":"County","adminArea3":"PA","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"17331","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":39.806325,"lng":-76.984273},"displayLatLng":{"lat":39.806325,"lng":-76.984273}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"","adminArea5Type":"City","adminArea4":"Hanover County","adminArea4Type":"County","adminArea3":"VA","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A4XXX","geocodeQuality":"COUNTY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":37.744783,"lng":-77.446416},"displayLatLng":{"lat":37.744783,"lng":-77.446416}}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_18d9ead8c32cddb4a3e06b17971685ea711214a5 b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_18d9ead8c32cddb4a3e06b17971685ea711214a5 index 9f938135a..1a093b30f 100644 --- a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_18d9ead8c32cddb4a3e06b17971685ea711214a5 +++ b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_18d9ead8c32cddb4a3e06b17971685ea711214a5 @@ -1 +1 @@ -s:1115:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2017 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2017 MapQuest, Inc."},"messages":[]},"options":{"maxResults":1,"thumbMaps":true,"ignoreLatLngInput":false},"results":[{"providedLocation":{"latLng":{"lat":38.900206,"lng":-77.036991}},"locations":[{"street":"H Street Northwest","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Washington","adminArea5Type":"City","adminArea4":"","adminArea4Type":"County","adminArea3":"District of Columbia","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"20006","geocodeQualityCode":"B1AAA","geocodeQuality":"STREET","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":38.900201,"lng":-77.036991},"displayLatLng":{"lat":38.900201,"lng":-77.036991},"mapUrl":"http://open.mapquestapi.com/staticmap/v4/getmap?key=io5RY14NTLzVuX48xoga7ICStRa8bOpR&type=map&size=225,160&pois=purple-1,38.90020133976049,-77.03699100349493,0,0,|¢er=38.90020133976049,-77.03699100349493&zoom=15&rand=507277093"}]}]}"; \ No newline at end of file +s:1091:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2018 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2018 MapQuest, Inc."},"messages":[]},"options":{"maxResults":1,"thumbMaps":true,"ignoreLatLngInput":false},"results":[{"providedLocation":{"latLng":{"lat":38.900206,"lng":-77.036991}},"locations":[{"street":"H Street Northwest","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Washington","adminArea5Type":"City","adminArea4":"","adminArea4Type":"County","adminArea3":"District of Columbia","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"20006","geocodeQualityCode":"B1AAA","geocodeQuality":"STREET","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":38.900201,"lng":-77.036991},"displayLatLng":{"lat":38.900201,"lng":-77.036991},"mapUrl":"http://open.mapquestapi.com/staticmap/v5/map?key=SHdXK7bioK4sEXCacV5iCAsEbzUtQQ23&type=map&size=225,160&locations=38.90020133976049,-77.03699100349493|marker-sm-50318A-1&scalebar=true&zoom=15&rand=669762425"}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_2936b2a8b50cb1ed2c60f2a47b928148410464b6 b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_2936b2a8b50cb1ed2c60f2a47b928148410464b6 new file mode 100644 index 000000000..c75ab6bdc --- /dev/null +++ b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_2936b2a8b50cb1ed2c60f2a47b928148410464b6 @@ -0,0 +1 @@ +s:1062:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2018 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2018 MapQuest, Inc."},"messages":[]},"options":{"maxResults":1,"thumbMaps":true,"ignoreLatLngInput":false},"results":[{"providedLocation":{"latLng":{"lat":54.0484068,"lng":-2.7990345}},"locations":[{"street":"Collegian W.M.C.","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Lancaster","adminArea5Type":"City","adminArea4":"","adminArea4Type":"County","adminArea3":"England","adminArea3Type":"State","adminArea1":"GB","adminArea1Type":"Country","postalCode":"LA1 1NP","geocodeQualityCode":"P1AAA","geocodeQuality":"POINT","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":54.048412,"lng":-2.798955},"displayLatLng":{"lat":54.048412,"lng":-2.798955},"mapUrl":"http://open.mapquestapi.com/staticmap/v5/map?key=SHdXK7bioK4sEXCacV5iCAsEbzUtQQ23&type=map&size=225,160&locations=54.0484116,-2.7989546|marker-sm-50318A-1&scalebar=true&zoom=15&rand=-1252404079"}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_2c689521a921228087301ae7c2b4aac6b14d56f8 b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_2c689521a921228087301ae7c2b4aac6b14d56f8 new file mode 100644 index 000000000..41a873a1e --- /dev/null +++ b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_2c689521a921228087301ae7c2b4aac6b14d56f8 @@ -0,0 +1 @@ +s:1407:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2018 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2018 MapQuest, Inc."},"messages":[]},"options":{"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"location":"10 avenue Gambetta, Paris, France"},"locations":[{"street":"10 Avenue Gambetta","adminArea6":"St-Fargeau","adminArea6Type":"Neighborhood","adminArea5":"Paris","adminArea5Type":"City","adminArea4":"Paris","adminArea4Type":"County","adminArea3":"Ile-de-France","adminArea3Type":"State","adminArea1":"FR","adminArea1Type":"Country","postalCode":"75020","geocodeQualityCode":"P1AAX","geocodeQuality":"POINT","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":48.863193,"lng":2.389089},"displayLatLng":{"lat":48.863193,"lng":2.389089}},{"street":"10 Avenue Gambetta","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Maisons-Alfort","adminArea5Type":"City","adminArea4":"Cr\u00E9teil","adminArea4Type":"County","adminArea3":"Ile-de-France","adminArea3Type":"State","adminArea1":"FR","adminArea1Type":"Country","postalCode":"94700","geocodeQualityCode":"P1AXX","geocodeQuality":"POINT","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":48.810071,"lng":2.435937},"displayLatLng":{"lat":48.810071,"lng":2.435937}}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_6d58a2755e3b2b48c91491749077d0bff866e466 b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_6d58a2755e3b2b48c91491749077d0bff866e466 deleted file mode 100644 index 49a7a8bbf..000000000 --- a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_6d58a2755e3b2b48c91491749077d0bff866e466 +++ /dev/null @@ -1 +0,0 @@ -s:883:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2016 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2016 MapQuest, Inc."},"messages":[]},"options":{"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"location":"10 avenue Gambetta, Paris, France"},"locations":[{"street":"10 Avenue Gambetta","adminArea6":"P\u00E8re-Lachaise","adminArea6Type":"Neighborhood","adminArea5":"Paris","adminArea5Type":"City","adminArea4":"Paris","adminArea4Type":"County","adminArea3":"Ile-de-France","adminArea3Type":"State","adminArea1":"FR","adminArea1Type":"Country","postalCode":"75020","geocodeQualityCode":"P1AAX","geocodeQuality":"POINT","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":48.863193,"lng":2.389089},"displayLatLng":{"lat":48.863193,"lng":2.389089}}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_78a9d0bf0db0faee36f1bdda968c372699dded44 b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_78a9d0bf0db0faee36f1bdda968c372699dded44 new file mode 100644 index 000000000..14dcafcb7 --- /dev/null +++ b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_78a9d0bf0db0faee36f1bdda968c372699dded44 @@ -0,0 +1 @@ +s:2841:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2018 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2018 MapQuest, Inc."},"messages":[]},"options":{"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"adminArea5":"Hanover","adminArea5Type":"City"},"locations":[{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"Region Hannover","adminArea4Type":"County","adminArea3":"Lower Saxony","adminArea3Type":"State","adminArea1":"DE","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":52.374478,"lng":9.738553},"displayLatLng":{"lat":52.374478,"lng":9.738553}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"Grafton County","adminArea4Type":"County","adminArea3":"NH","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":43.703622,"lng":-72.288666},"displayLatLng":{"lat":43.703622,"lng":-72.288666}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"York County","adminArea4Type":"County","adminArea3":"PA","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"17331","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":39.806325,"lng":-76.984273},"displayLatLng":{"lat":39.806325,"lng":-76.984273}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"Northampton County","adminArea4Type":"County","adminArea3":"PA","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":40.661764,"lng":-75.412404},"displayLatLng":{"lat":40.661764,"lng":-75.412404}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"Lehigh County","adminArea4Type":"County","adminArea3":"PA","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":40.651401,"lng":-75.440663},"displayLatLng":{"lat":40.651401,"lng":-75.440663}}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_91756cf6f4ac43dc3046c9a8a4c48fdaaa16d5f1 b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_7eebf1200cb65bb0572e14a007e02c1c4f92ac27 similarity index 84% rename from src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_91756cf6f4ac43dc3046c9a8a4c48fdaaa16d5f1 rename to src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_7eebf1200cb65bb0572e14a007e02c1c4f92ac27 index 42746be91..e31b13844 100644 --- a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_91756cf6f4ac43dc3046c9a8a4c48fdaaa16d5f1 +++ b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_7eebf1200cb65bb0572e14a007e02c1c4f92ac27 @@ -1 +1 @@ -s:825:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2017 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2017 MapQuest, Inc."},"messages":[]},"options":{"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"location":"jsajhgsdkfjhsfkjhaldkadjaslgldasd"},"locations":[{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"","adminArea5Type":"City","adminArea4":"","adminArea4Type":"County","adminArea3":"","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A1XXX","geocodeQuality":"COUNTRY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":39.78373,"lng":-100.445882},"displayLatLng":{"lat":39.78373,"lng":-100.445882}}]}]}"; \ No newline at end of file +s:825:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2018 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2018 MapQuest, Inc."},"messages":[]},"options":{"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"location":"jsajhgsdkfjhsfkjhaldkadjaslgldasd"},"locations":[{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"","adminArea5Type":"City","adminArea4":"","adminArea4Type":"County","adminArea3":"","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A1XXX","geocodeQuality":"COUNTRY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":39.78373,"lng":-100.445882},"displayLatLng":{"lat":39.78373,"lng":-100.445882}}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_8466d8c846339d0fabe066566868adab6fd26bbe b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_8466d8c846339d0fabe066566868adab6fd26bbe new file mode 100644 index 000000000..679c89b2c --- /dev/null +++ b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_8466d8c846339d0fabe066566868adab6fd26bbe @@ -0,0 +1 @@ +s:2927:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2018 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2018 MapQuest, Inc."},"messages":[]},"options":{"boundingBox":{"ul":{"lat":41.0,"lng":-77.0},"lr":{"lat":39.0,"lng":-75.0}},"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"adminArea5":"Hanover","adminArea5Type":"City"},"locations":[{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"York County","adminArea4Type":"County","adminArea3":"PA","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"17331","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":39.806325,"lng":-76.984273},"displayLatLng":{"lat":39.806325,"lng":-76.984273}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"Northampton County","adminArea4Type":"County","adminArea3":"PA","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":40.661764,"lng":-75.412404},"displayLatLng":{"lat":40.661764,"lng":-75.412404}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"Lehigh County","adminArea4Type":"County","adminArea3":"PA","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":40.651401,"lng":-75.440663},"displayLatLng":{"lat":40.651401,"lng":-75.440663}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"Howard County","adminArea4Type":"County","adminArea3":"MD","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"20794:21076","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":39.192885,"lng":-76.724137},"displayLatLng":{"lat":39.192885,"lng":-76.724137}},{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Hanover","adminArea5Type":"City","adminArea4":"Region Hannover","adminArea4Type":"County","adminArea3":"Lower Saxony","adminArea3Type":"State","adminArea1":"DE","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A5XAX","geocodeQuality":"CITY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":52.374478,"lng":9.738553},"displayLatLng":{"lat":52.374478,"lng":9.738553}}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_8e66a9540d4157894f4c9c78173254892f289f6e b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_8e66a9540d4157894f4c9c78173254892f289f6e deleted file mode 100644 index bb5f83080..000000000 --- a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_8e66a9540d4157894f4c9c78173254892f289f6e +++ /dev/null @@ -1 +0,0 @@ -s:896:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2016 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2016 MapQuest, Inc."},"messages":[]},"options":{"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"location":"Kalbacher Hauptstra\u00DFe 10, 60437 Frankfurt, Germany"},"locations":[{"street":"Kalbacher Hauptstra\u00DFe 10","adminArea6":"Kalbach","adminArea6Type":"Neighborhood","adminArea5":"Frankfurt","adminArea5Type":"City","adminArea4":"","adminArea4Type":"County","adminArea3":"Hesse","adminArea3Type":"State","adminArea1":"DE","adminArea1Type":"Country","postalCode":"60437","geocodeQualityCode":"P1AAA","geocodeQuality":"POINT","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":50.189062,"lng":8.636567},"displayLatLng":{"lat":50.189062,"lng":8.636567}}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_d23f5a3ba833ade87000e0eed0b4435615e066b0 b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_d23f5a3ba833ade87000e0eed0b4435615e066b0 new file mode 100644 index 000000000..8bb4d9a69 --- /dev/null +++ b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_d23f5a3ba833ade87000e0eed0b4435615e066b0 @@ -0,0 +1 @@ +s:903:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2018 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2018 MapQuest, Inc."},"messages":[]},"options":{"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"location":"Kalbacher Hauptstra\u00DFe 10, 60437 Frankfurt, Germany"},"locations":[{"street":"Kalbacher Hauptstra\u00DFe 10","adminArea6":"Kalbach","adminArea6Type":"Neighborhood","adminArea5":"Frankfurt","adminArea5Type":"City","adminArea4":"Frankfurt","adminArea4Type":"County","adminArea3":"Hesse","adminArea3Type":"State","adminArea1":"DE","adminArea1Type":"Country","postalCode":"60437","geocodeQualityCode":"P1AAA","geocodeQuality":"POINT","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":50.189046,"lng":8.63661},"displayLatLng":{"lat":50.189046,"lng":8.63661}}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_df6afc6a1f7550fdef3174b5bf434bc25e98ba89 b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_df6afc6a1f7550fdef3174b5bf434bc25e98ba89 new file mode 100644 index 000000000..252e2add1 --- /dev/null +++ b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_df6afc6a1f7550fdef3174b5bf434bc25e98ba89 @@ -0,0 +1 @@ +s:1056:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2018 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2018 MapQuest, Inc."},"messages":[]},"options":{"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"street":"4868 Payne Rd","adminArea5":"Nashville","adminArea3":"TN","postalCode":"37013","adminArea1":"US","adminArea6":"Antioch","adminArea5Type":"City","adminArea1Type":"Country","adminArea6Type":"Neighborhood","adminArea3Type":"State"},"locations":[{"street":"Payne Road","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"Nashville","adminArea5Type":"City","adminArea4":"Davidson County","adminArea4Type":"County","adminArea3":"TN","adminArea3Type":"State","adminArea1":"US","adminArea1Type":"Country","postalCode":"37013","geocodeQualityCode":"B1XAA","geocodeQuality":"STREET","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":36.062933,"lng":-86.672811},"displayLatLng":{"lat":36.062933,"lng":-86.672811}}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_44aea91743871378ac841bf130d569bb55d4787e b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_e46463942e3d84f3742ae7b44b16c2c587b401a8 similarity index 85% rename from src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_44aea91743871378ac841bf130d569bb55d4787e rename to src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_e46463942e3d84f3742ae7b44b16c2c587b401a8 index 63a5860d2..8801273b8 100644 --- a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_44aea91743871378ac841bf130d569bb55d4787e +++ b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_e46463942e3d84f3742ae7b44b16c2c587b401a8 @@ -1 +1 @@ -s:862:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2017 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2017 MapQuest, Inc."},"messages":[]},"options":{"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"location":"10 Downing St, London, UK"},"locations":[{"street":"10 Downing Street","adminArea6":"Covent Garden","adminArea6Type":"Neighborhood","adminArea5":"London","adminArea5Type":"City","adminArea4":"","adminArea4Type":"County","adminArea3":"England","adminArea3Type":"State","adminArea1":"GB","adminArea1Type":"Country","postalCode":"SW1A 2AA","geocodeQualityCode":"P1CAX","geocodeQuality":"POINT","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":51.50344,"lng":-0.127708},"displayLatLng":{"lat":51.50344,"lng":-0.127708}}]}]}"; \ No newline at end of file +s:862:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2018 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2018 MapQuest, Inc."},"messages":[]},"options":{"maxResults":5,"thumbMaps":false,"ignoreLatLngInput":false},"results":[{"providedLocation":{"location":"10 Downing St, London, UK"},"locations":[{"street":"10 Downing Street","adminArea6":"Covent Garden","adminArea6Type":"Neighborhood","adminArea5":"London","adminArea5Type":"City","adminArea4":"","adminArea4Type":"County","adminArea3":"England","adminArea3Type":"State","adminArea1":"GB","adminArea1Type":"Country","postalCode":"SW1A 2AA","geocodeQualityCode":"P1CAX","geocodeQuality":"POINT","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":51.50344,"lng":-0.127708},"displayLatLng":{"lat":51.50344,"lng":-0.127708}}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_d6c5af9b89f9861e0cdb3f3a578e84957c063dd5 b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_f811f4ea729035e359bca202ff88ecd5a7fd17c7 similarity index 71% rename from src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_d6c5af9b89f9861e0cdb3f3a578e84957c063dd5 rename to src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_f811f4ea729035e359bca202ff88ecd5a7fd17c7 index ee0d228c7..548da85c5 100644 --- a/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_d6c5af9b89f9861e0cdb3f3a578e84957c063dd5 +++ b/src/Provider/MapQuest/Tests/.cached_responses/open.mapquestapi.com_f811f4ea729035e359bca202ff88ecd5a7fd17c7 @@ -1 +1 @@ -s:965:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2017 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2017 MapQuest, Inc."},"messages":[]},"options":{"maxResults":1,"thumbMaps":true,"ignoreLatLngInput":false},"results":[{"providedLocation":{"latLng":{"lat":0.0,"lng":0.0}},"locations":[{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"","adminArea5Type":"City","adminArea4":"","adminArea4Type":"County","adminArea3":"","adminArea3Type":"State","adminArea1":"XZ","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A1XAX","geocodeQuality":"COUNTRY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":0.0,"lng":0.0},"displayLatLng":{"lat":0.0,"lng":0.0},"mapUrl":"http://open.mapquestapi.com/staticmap/v4/getmap?key=io5RY14NTLzVuX48xoga7ICStRa8bOpR&type=map&size=225,160&pois=purple-1,0.0,0.0,0,0,|¢er=0.0,0.0&zoom=2&rand=551965888"}]}]}"; \ No newline at end of file +s:972:"{"info":{"statuscode":0,"copyright":{"text":"\u00A9 2018 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"\u00A9 2018 MapQuest, Inc."},"messages":[]},"options":{"maxResults":1,"thumbMaps":true,"ignoreLatLngInput":false},"results":[{"providedLocation":{"latLng":{"lat":0.0,"lng":0.0}},"locations":[{"street":"","adminArea6":"","adminArea6Type":"Neighborhood","adminArea5":"","adminArea5Type":"City","adminArea4":"","adminArea4Type":"County","adminArea3":"","adminArea3Type":"State","adminArea1":"XZ","adminArea1Type":"Country","postalCode":"","geocodeQualityCode":"A1XAX","geocodeQuality":"COUNTRY","dragPoint":false,"sideOfStreet":"N","linkId":"0","unknownInput":"","type":"s","latLng":{"lat":0.0,"lng":0.0},"displayLatLng":{"lat":0.0,"lng":0.0},"mapUrl":"http://open.mapquestapi.com/staticmap/v5/map?key=SHdXK7bioK4sEXCacV5iCAsEbzUtQQ23&type=map&size=225,160&locations=0.0,0.0|marker-sm-50318A-1&scalebar=true&zoom=2&rand=-1446168363"}]}]}"; \ No newline at end of file diff --git a/src/Provider/MapQuest/Tests/MapQuestTest.php b/src/Provider/MapQuest/Tests/MapQuestTest.php index bae7ac6e8..0c8bda158 100644 --- a/src/Provider/MapQuest/Tests/MapQuestTest.php +++ b/src/Provider/MapQuest/Tests/MapQuestTest.php @@ -15,6 +15,10 @@ use Geocoder\Collection; use Geocoder\IntegrationTest\BaseTestCase; use Geocoder\Location; +use Geocoder\Model\AddressBuilder; +use Geocoder\Model\AdminLevel; +use Geocoder\Model\Bounds; +use Geocoder\Provider\MapQuest\GeocodeQuery as MapQuestGeocodeQuery; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; use Geocoder\Provider\MapQuest\MapQuest; @@ -65,7 +69,7 @@ public function testGeocodeWithRealAddress() $results = $provider->geocodeQuery(GeocodeQuery::create('10 avenue Gambetta, Paris, France')); $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); - $this->assertCount(1, $results); + $this->assertCount(2, $results); /** @var Location $result */ $result = $results->first(); @@ -85,6 +89,71 @@ public function testGeocodeWithRealAddress() $this->assertNull($result->getStreetNumber()); $this->assertNull($result->getAdminLevels()->get(1)->getCode()); $this->assertNull($result->getTimezone()); + + $result = $results->get(1); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(48.810071, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(2.435937, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('10 Avenue Gambetta', $result->getStreetName()); + $this->assertEquals(94700, $result->getPostalCode()); + $this->assertEquals('Maisons-Alfort', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('Créteil', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('Ile-de-France', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('FR', $result->getCountry()->getName()); + $this->assertEquals('FR', $result->getCountry()->getCode()); + + $this->assertNull($result->getBounds()); + $this->assertNull($result->getStreetNumber()); + $this->assertNull($result->getAdminLevels()->get(1)->getCode()); + $this->assertNull($result->getTimezone()); + } + + public function testGeocodeWithRealSpecificAddress() + { + if (!isset($_SERVER['MAPQUEST_API_KEY'])) { + $this->markTestSkipped('You need to configure the MAPQUEST_API_KEY value in phpunit.xml'); + } + + $provider = new MapQuest($this->getHttpClient($_SERVER['MAPQUEST_API_KEY']), $_SERVER['MAPQUEST_API_KEY']); + + $addressBuilder = new AddressBuilder('tests'); + $addressBuilder + ->setStreetNumber('4868') + ->setStreetName('Payne Rd') + ->setLocality('Nashville') + ->setSubLocality('Antioch') + ->setAdminLevels([ + new AdminLevel(1, 'Tennessee', 'TN'), + ]) + ->setPostalCode('37013') + ->setCountry('USA') + ->setCountryCode('US'); + $address = $addressBuilder->build(); + + $results = $provider->geocodeQuery(MapQuestGeocodeQuery::createFromAddress($address)); + + $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); + $this->assertCount(1, $results); + + /** @var Location $result */ + $result = $results->first(); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(36.062933, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-86.672811, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('Payne Road', $result->getStreetName()); + $this->assertEquals('37013', $result->getPostalCode()); + $this->assertEquals('Nashville', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('Davidson County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('TN', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('TN', $result->getAdminLevels()->get(1)->getCode()); + $this->assertEquals('US', $result->getCountry()->getName()); + $this->assertEquals('US', $result->getCountry()->getCode()); + + $this->assertNull($result->getBounds()); + $this->assertNull($result->getStreetNumber()); + $this->assertNull($result->getTimezone()); } public function testReverseWithRealCoordinates() @@ -130,8 +199,10 @@ public function testGeocodeWithCity() $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); + $resultsArray = $results->all(); + /** @var Location $result */ - $result = $results->first(); + $result = reset($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); $this->assertEquals(52.374478, $result->getCoordinates()->getLatitude(), '', 0.01); $this->assertEquals(9.738553, $result->getCoordinates()->getLongitude(), '', 0.01); @@ -143,22 +214,77 @@ public function testGeocodeWithCity() $this->assertEquals('DE', $result->getCountry()->getCode()); /** @var Location $result */ - $result = $results->first(); + $result = next($resultsArray); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(18.384049, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-78.131485, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('', $result->getLocality()); + $this->assertCount(1, $result->getAdminLevels()); + $this->assertEquals('Hanover', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('JM', $result->getCountry()->getName()); + $this->assertEquals('JM', $result->getCountry()->getCode()); + + /** @var Location $result */ + $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.374478000000003, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(9.7385529999999996, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals(43.703622, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-72.288666, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); - $this->assertEquals('Region Hannover', $result->getAdminLevels()->get(2)->getName()); - $this->assertEquals('Lower Saxony', $result->getAdminLevels()->get(1)->getName()); - $this->assertEquals('DE', $result->getCountry()->getName()); - $this->assertEquals('DE', $result->getCountry()->getCode()); + $this->assertEquals('Grafton County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('NH', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('US', $result->getCountry()->getName()); + $this->assertEquals('US', $result->getCountry()->getCode()); /** @var Location $result */ - $result = $results->first(); + $result = next($resultsArray); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(39.806325, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-76.984273, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('Hanover', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('York County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('PA', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('US', $result->getCountry()->getName()); + $this->assertEquals('US', $result->getCountry()->getCode()); + + /** @var Location $result */ + $result = next($resultsArray); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(37.744783, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-77.446416, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('Hanover County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('VA', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('US', $result->getCountry()->getName()); + $this->assertEquals('US', $result->getCountry()->getCode()); + } + + public function testGeocodeWithSpecificCity() + { + if (!isset($_SERVER['MAPQUEST_API_KEY'])) { + $this->markTestSkipped('You need to configure the MAPQUEST_API_KEY value in phpunit.xml'); + } + + $provider = new MapQuest($this->getHttpClient($_SERVER['MAPQUEST_API_KEY']), $_SERVER['MAPQUEST_API_KEY']); + + $addressBuilder = new AddressBuilder('tests'); + $addressBuilder->setLocality('Hanover'); + $address = $addressBuilder->build(); + + $results = $provider->geocodeQuery(MapQuestGeocodeQuery::createFromAddress($address)); + + $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); + $this->assertCount(5, $results); + + $resultsArray = $results->all(); + + /** @var Location $result */ + $result = reset($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.374478000000003, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(9.7385529999999996, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals(52.374478, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(9.738553, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Region Hannover', $result->getAdminLevels()->get(2)->getName()); @@ -167,10 +293,130 @@ public function testGeocodeWithCity() $this->assertEquals('DE', $result->getCountry()->getCode()); /** @var Location $result */ - $result = $results->first(); + $result = next($resultsArray); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(43.703622, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-72.288666, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('Hanover', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('Grafton County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('NH', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('US', $result->getCountry()->getName()); + $this->assertEquals('US', $result->getCountry()->getCode()); + + /** @var Location $result */ + $result = next($resultsArray); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(39.806325, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-76.984273, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('Hanover', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('York County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('PA', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('US', $result->getCountry()->getName()); + $this->assertEquals('US', $result->getCountry()->getCode()); + + /** @var Location $result */ + $result = next($resultsArray); $this->assertInstanceOf('\Geocoder\Model\Address', $result); - $this->assertEquals(52.374478000000003, $result->getCoordinates()->getLatitude(), '', 0.01); - $this->assertEquals(9.7385529999999996, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals(40.661764, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-75.412404, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('Hanover', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('Northampton County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('PA', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('US', $result->getCountry()->getName()); + $this->assertEquals('US', $result->getCountry()->getCode()); + + /** @var Location $result */ + $result = next($resultsArray); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(40.651401, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-75.440663, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('Hanover', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('Lehigh County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('PA', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('US', $result->getCountry()->getName()); + $this->assertEquals('US', $result->getCountry()->getCode()); + } + + public function testGeocodeWithSpecificCityAndBounds() + { + if (!isset($_SERVER['MAPQUEST_API_KEY'])) { + $this->markTestSkipped('You need to configure the MAPQUEST_API_KEY value in phpunit.xml'); + } + + $provider = new MapQuest($this->getHttpClient($_SERVER['MAPQUEST_API_KEY']), $_SERVER['MAPQUEST_API_KEY']); + + $addressBuilder = new AddressBuilder('tests'); + $addressBuilder->setLocality('Hanover'); + $address = $addressBuilder->build(); + + $query = MapQuestGeocodeQuery::createFromAddress($address) + ->withBounds(new Bounds('39', '-77', '41', '-75')); + $results = $provider->geocodeQuery($query); + + $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); + $this->assertCount(5, $results); + + $resultsArray = $results->all(); + + /** @var Location $result */ + $result = reset($resultsArray); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals('17331', $result->getPostalCode()); + $this->assertEquals(39.806325, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-76.984273, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('Hanover', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('York County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('PA', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('US', $result->getCountry()->getName()); + $this->assertEquals('US', $result->getCountry()->getCode()); + + /** @var Location $result */ + $result = next($resultsArray); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(40.661764, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-75.412404, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('Hanover', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('Northampton County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('PA', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('US', $result->getCountry()->getName()); + $this->assertEquals('US', $result->getCountry()->getCode()); + + /** @var Location $result */ + $result = next($resultsArray); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(40.651401, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-75.440663, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('Hanover', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('Lehigh County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('PA', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('US', $result->getCountry()->getName()); + $this->assertEquals('US', $result->getCountry()->getCode()); + + /** @var Location $result */ + $result = next($resultsArray); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals('20794:21076', $result->getPostalCode()); + $this->assertEquals(39.192885, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(-76.724137, $result->getCoordinates()->getLongitude(), '', 0.01); + $this->assertEquals('Hanover', $result->getLocality()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('Howard County', $result->getAdminLevels()->get(2)->getName()); + $this->assertEquals('MD', $result->getAdminLevels()->get(1)->getName()); + $this->assertEquals('US', $result->getCountry()->getName()); + $this->assertEquals('US', $result->getCountry()->getCode()); + + /** @var Location $result */ + $result = next($resultsArray); + $this->assertInstanceOf('\Geocoder\Model\Address', $result); + $this->assertEquals(52.374478, $result->getCoordinates()->getLatitude(), '', 0.01); + $this->assertEquals(9.738553, $result->getCoordinates()->getLongitude(), '', 0.01); $this->assertEquals('Hanover', $result->getLocality()); $this->assertCount(2, $result->getAdminLevels()); $this->assertEquals('Region Hannover', $result->getAdminLevels()->get(2)->getName()); @@ -199,7 +445,8 @@ public function testGeocodeWithCityDistrict() $this->assertEquals('Kalbacher Hauptstraße 10', $result->getStreetName()); $this->assertEquals(60437, $result->getPostalCode()); $this->assertEquals('Frankfurt', $result->getLocality()); - $this->assertCount(1, $result->getAdminLevels()); + $this->assertCount(2, $result->getAdminLevels()); + $this->assertEquals('Frankfurt', $result->getAdminLevels()->get(2)->getName()); $this->assertEquals('Hesse', $result->getAdminLevels()->get(1)->getName()); $this->assertEquals('DE', $result->getCountry()->getName()); $this->assertEquals('DE', $result->getCountry()->getCode()); From e46b8742be451a44a18268e07bf45b6cf5f5d4a5 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Tue, 26 Jun 2018 18:24:55 +0200 Subject: [PATCH 3/5] With these changes I find it way easier to merge your PR --- src/Common/Query/GeocodeQuery.php | 2 +- src/Provider/MapQuest/GeocodeQuery.php | 109 ------------------- src/Provider/MapQuest/MapQuest.php | 34 +----- src/Provider/MapQuest/Tests/MapQuestTest.php | 14 ++- src/Provider/MapQuest/composer.json | 2 +- 5 files changed, 16 insertions(+), 145 deletions(-) delete mode 100644 src/Provider/MapQuest/GeocodeQuery.php diff --git a/src/Common/Query/GeocodeQuery.php b/src/Common/Query/GeocodeQuery.php index 1f193dd72..46be7ed1c 100644 --- a/src/Common/Query/GeocodeQuery.php +++ b/src/Common/Query/GeocodeQuery.php @@ -19,7 +19,7 @@ /** * @author Tobias Nyholm */ -class GeocodeQuery implements Query +final class GeocodeQuery implements Query { /** * The address or text that should be geocoded. diff --git a/src/Provider/MapQuest/GeocodeQuery.php b/src/Provider/MapQuest/GeocodeQuery.php deleted file mode 100644 index 97f30f489..000000000 --- a/src/Provider/MapQuest/GeocodeQuery.php +++ /dev/null @@ -1,109 +0,0 @@ -data[static::DATA_KEY_ADDRESS] = $address; - } else { - if (empty($address)) { - throw new InvalidArgument('Geocode query cannot be empty'); - } - $this->text = $address; - } - } - - public static function create(string $text): BaseGeocodeQuery - { - return new self($text); - } - - public static function createFromAddress(Location $address): self - { - return new self($address); - } - - public function withText(string $text): BaseGeocodeQuery - { - $new = clone $this; - $new->text = $text; - - return $new; - } - - public function withData(string $name, $value): BaseGeocodeQuery - { - $new = clone $this; - $new->data[$name] = $value; - - return $new; - } - - public function getAddress() - { - return $this->getData(static::DATA_KEY_ADDRESS); - } - - public function getText(): string - { - if (!$this->text) { - $address = $this->getAddress(); - if ($address instanceof Location) { - $this->text = $this->formatAddress($address); - } - } - - return $this->text; - } - - public function getData(string $name, $default = null) - { - if (!array_key_exists($name, $this->data)) { - return $default; - } - - return $this->data[$name]; - } - - public function getAllData(): array - { - return $this->data; - } - - protected function formatAddress(Location $address): string - { - $formatter = new StringFormatter(); - - return trim($formatter->format($address, '%n %S, %L, %a1 %z, %C')); - } -} diff --git a/src/Provider/MapQuest/MapQuest.php b/src/Provider/MapQuest/MapQuest.php index e20298d78..b146d10e5 100644 --- a/src/Provider/MapQuest/MapQuest.php +++ b/src/Provider/MapQuest/MapQuest.php @@ -25,7 +25,7 @@ use Geocoder\Model\AdminLevel; use Geocoder\Model\Bounds; use Geocoder\Model\Country; -use Geocoder\Query\GeocodeQuery as CommonGeocodeQuery; +use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; use Geocoder\Provider\Provider; use Http\Client\HttpClient; @@ -36,47 +36,32 @@ */ final class MapQuest extends AbstractHttpProvider implements Provider { - const KEY_API_KEY = 'key'; + const DATA_KEY_ADDRESS = 'address'; + const KEY_API_KEY = 'key'; const KEY_LOCATION = 'location'; - const KEY_OUT_FORMAT = 'outFormat'; - const KEY_MAX_RESULTS = 'maxResults'; - const KEY_THUMB_MAPS = 'thumbMaps'; - const KEY_INTL_MODE = 'intlMode'; - const KEY_BOUNDING_BOX = 'boundingBox'; - const KEY_LAT = 'lat'; - const KEY_LNG = 'lng'; - const MODE_5BOX = '5BOX'; - const OPEN_BASE_URL = 'https://open.mapquestapi.com/geocoding/v1/'; - const LICENSED_BASE_URL = 'https://www.mapquestapi.com/geocoding/v1/'; - const GEOCODE_ENDPOINT = 'address'; - const DEFAULT_GEOCODE_PARAMS = [ self::KEY_LOCATION => '', self::KEY_OUT_FORMAT => 'json', self::KEY_API_KEY => '', ]; - const DEFAULT_GEOCODE_OPTIONS = [ self::KEY_MAX_RESULTS => 3, self::KEY_THUMB_MAPS => false, ]; - const REVERSE_ENDPOINT = 'reverse'; - const ADMIN_LEVEL_STATE = 1; - const ADMIN_LEVEL_COUNTY = 2; /** @@ -118,7 +103,7 @@ public function __construct(HttpClient $client, string $apiKey, bool $licensed = /** * {@inheritdoc} */ - public function geocodeQuery(CommonGeocodeQuery $query): Collection + public function geocodeQuery(GeocodeQuery $query): Collection { $params = static::DEFAULT_GEOCODE_PARAMS; $params[static::KEY_API_KEY] = $this->apiKey; @@ -128,7 +113,7 @@ public function geocodeQuery(CommonGeocodeQuery $query): Collection $useGetQuery = true; - $address = $this->extractAddressFromQuery($query); + $address = $query->getData(self::DATA_KEY_ADDRESS); if ($address instanceof Location) { $params[static::KEY_LOCATION] = $this->mapAddressToArray($address); $options[static::KEY_INTL_MODE] = static::MODE_5BOX; @@ -165,15 +150,6 @@ public function geocodeQuery(CommonGeocodeQuery $query): Collection } } - private function extractAddressFromQuery(CommonGeocodeQuery $query) - { - if ($query instanceof GetAddressInterface) { - return $query->getAddress(); - } - - return $query->getData(GeocodeQuery::DATA_KEY_ADDRESS); - } - /** * {@inheritdoc} */ diff --git a/src/Provider/MapQuest/Tests/MapQuestTest.php b/src/Provider/MapQuest/Tests/MapQuestTest.php index 0c8bda158..60c18a969 100644 --- a/src/Provider/MapQuest/Tests/MapQuestTest.php +++ b/src/Provider/MapQuest/Tests/MapQuestTest.php @@ -18,7 +18,6 @@ use Geocoder\Model\AddressBuilder; use Geocoder\Model\AdminLevel; use Geocoder\Model\Bounds; -use Geocoder\Provider\MapQuest\GeocodeQuery as MapQuestGeocodeQuery; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; use Geocoder\Provider\MapQuest\MapQuest; @@ -131,7 +130,9 @@ public function testGeocodeWithRealSpecificAddress() ->setCountryCode('US'); $address = $addressBuilder->build(); - $results = $provider->geocodeQuery(MapQuestGeocodeQuery::createFromAddress($address)); + $query = GeocodeQuery::create('foobar'); + $query = $query->withData(MapQuest::DATA_KEY_ADDRESS, $address); + $results = $provider->geocodeQuery($query); $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(1, $results); @@ -273,7 +274,9 @@ public function testGeocodeWithSpecificCity() $addressBuilder->setLocality('Hanover'); $address = $addressBuilder->build(); - $results = $provider->geocodeQuery(MapQuestGeocodeQuery::createFromAddress($address)); + $query = GeocodeQuery::create('foobar'); + $query = $query->withData(MapQuest::DATA_KEY_ADDRESS, $address); + $results = $provider->geocodeQuery($query); $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); $this->assertCount(5, $results); @@ -353,8 +356,9 @@ public function testGeocodeWithSpecificCityAndBounds() $addressBuilder->setLocality('Hanover'); $address = $addressBuilder->build(); - $query = MapQuestGeocodeQuery::createFromAddress($address) - ->withBounds(new Bounds('39', '-77', '41', '-75')); + $query = GeocodeQuery::create('foobar'); + $query = $query->withData(MapQuest::DATA_KEY_ADDRESS, $address); + $query = $query->withBounds(new Bounds('39', '-77', '41', '-75')); $results = $provider->geocodeQuery($query); $this->assertInstanceOf('Geocoder\Model\AddressCollection', $results); diff --git a/src/Provider/MapQuest/composer.json b/src/Provider/MapQuest/composer.json index b321e0f58..11e3d54c5 100644 --- a/src/Provider/MapQuest/composer.json +++ b/src/Provider/MapQuest/composer.json @@ -18,7 +18,7 @@ }, "require-dev": { "phpunit/phpunit": "6.3.*", - "geocoder-php/provider-integration-tests": "^1.0", + "geocoder-php/provider-integration-tests": "^1.1", "php-http/message": "^1.0", "php-http/curl-client": "^1.7", "nyholm/psr7": "^0.2.2" From 4bc7cdd561a344be2607546e99643d78c32fc4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Sun, 8 Jul 2018 22:16:20 +0100 Subject: [PATCH 4/5] Let us keep the method extractAddressFromQuery --- src/Provider/MapQuest/MapQuest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Provider/MapQuest/MapQuest.php b/src/Provider/MapQuest/MapQuest.php index b146d10e5..29158cf5e 100644 --- a/src/Provider/MapQuest/MapQuest.php +++ b/src/Provider/MapQuest/MapQuest.php @@ -113,7 +113,7 @@ public function geocodeQuery(GeocodeQuery $query): Collection $useGetQuery = true; - $address = $query->getData(self::DATA_KEY_ADDRESS); + $address = $this->extractAddressFromQuery($query); if ($address instanceof Location) { $params[static::KEY_LOCATION] = $this->mapAddressToArray($address); $options[static::KEY_INTL_MODE] = static::MODE_5BOX; @@ -176,6 +176,11 @@ public function getName(): string return 'map_quest'; } + private function extractAddressFromQuery(GeocodeQuery $query) + { + return $query->getData(static::DATA_KEY_ADDRESS); + } + private function getUrl($endpoint): string { if ($this->licensed) { From f76224f46060c53d6b86e39788d765c277060960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Sun, 8 Jul 2018 22:49:56 +0100 Subject: [PATCH 5/5] Update Readme.md --- src/Provider/MapQuest/Readme.md | 37 +++++++++++++++------------------ 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/Provider/MapQuest/Readme.md b/src/Provider/MapQuest/Readme.md index 859cd4c20..f66464b8d 100644 --- a/src/Provider/MapQuest/Readme.md +++ b/src/Provider/MapQuest/Readme.md @@ -27,22 +27,28 @@ Quote from [MapQuest Developer: Specifying Locations](https://developer.mapquest > allows for a higher degree of address specification by entering the full address in its individual location parameters. > The 5-Box Input format is beneficial as it bypasses the parsing functionality of the single-line request. -To pass an Address object as a part of the geocode query, we provide the class `Geocoder\Provider\MapQuest\GeocodeQuery`. -An object of class `Geocoder\Provider\MapQuest\GeocodeQuery` can be passed instead of the regular `Geocoder\Query\GeocodeQuery` -as the argument to the `geocodeQuery` method of the provider. If you have an object of a class that implements -`Geocoder\Location` stored in the variable `$address`, this new type of GeocodeQuery can be created with: +If you have an object of a class that implements `Geocoder\Location` stored in the variable `$address`, +this new type of GeocodeQuery can be created with: ``` -$query = \Geocoder\Provider\MapQuest\GeocodeQuery::createFromAddress($address); +$query = GeocodeQuery::create('foobar'); +$query = $query->withData(MapQuest::DATA_KEY_ADDRESS, $address); ``` -This new GeocodeQuery class will also work fine with all the other providers. It will provide them with -a text version of the address when they require a location as a string instead of a `Geocoder\Location` implementation. +If you want the GeocodeQuery to also work fine with all the other providers, +you will need to convert the `$address` object to a text string first. +Say you have stored this text string in the variable `$addressAsString`, the the example will read as follows: +``` +$query = GeocodeQuery::create($addressAsString); +$query = $query->withData(MapQuest::DATA_KEY_ADDRESS, $address); +``` + +Here is a more complete example with use statements, and building of the address object: **Example** ``` use Geocoder\Model\AddressBuilder; -use Geocoder\Provider\MapQuest\GeocodeQuery as MapQuestGeocodeQuery; use Geocoder\Provider\MapQuest\MapQuest; +use Geocoder\Query\GeocodeQuery; $provider = new MapQuest($httpClient, $apiKey); @@ -60,21 +66,12 @@ $addressBuilder ->setCountryCode('US'); $address = $addressBuilder->build(); -$query = MapQuestGeocodeQuery::createFromAddress($address); -$results = $provider->geocodeQuery($query); -``` - +$query = GeocodeQuery::create('dummy data'); +$query = $query->withData(MapQuest::DATA_KEY_ADDRESS, $address); -Alternatively you may use the regular `Geocoder\Query\GeocodeQuery` instead with the address passed as data, like this: +$results = $provider->geocodeQuery($query); ``` -use Geocoder\Model\Address; -use Geocoder\Provider\MapQuest\GeocodeQuery as MapQuestGeocodeQuery; -use Geocoder\Query\GeocodeQuery; -$address = new Address( ... ); -$query = GeocodeQuery::create('location string'); -$query = $query->withData(MapQuestGeocodeQuery::DATA_KEY_ADDRESS, $address); -``` ### Contribute Contributions are very welcome! Send a pull request to the [main repository](https://github.com/geocoder-php/Geocoder) or