/** * Generates geocoding URL according to the request. * * @param \Ivory\GoogleMap\Services\Geocoding\GeocoderRequest $geocoderRequest The geocoder request. * * @return string The generated URL. */ protected function generateUrl(GeocoderRequest $geocoderRequest) { $httpQuery = array(); if ($geocoderRequest->hasAddress()) { $httpQuery['address'] = $geocoderRequest->getAddress(); } else { $httpQuery['latlng'] = sprintf('%s,%s', $geocoderRequest->getCoordinate()->getLatitude(), $geocoderRequest->getCoordinate()->getLongitude()); } if ($geocoderRequest->hasBound()) { $httpQuery['bound'] = sprintf('%s,%s|%s,%s', $geocoderRequest->getBound()->getSouthWest()->getLatitude(), $geocoderRequest->getBound()->getSouthWest()->getLongitude(), $geocoderRequest->getBound()->getNorthEast()->getLatitude(), $geocoderRequest->getBound()->getNorthEast()->getLongitude()); } if ($geocoderRequest->hasRegion()) { $httpQuery['region'] = $geocoderRequest->getRegion(); } if ($geocoderRequest->hasLanguage()) { $httpQuery['language'] = $geocoderRequest->getLanguage(); } $httpQuery['sensor'] = $geocoderRequest->hasSensor() ? 'true' : 'false'; $url = sprintf('%s/%s?%s', $this->getUrl(), $this->getFormat(), http_build_query($httpQuery)); return $this->signUrl($url); }
public function testAddressWithValidValue() { $this->geocoderRequest->setAddress('foo'); $this->assertTrue($this->geocoderRequest->hasAddress()); $this->assertSame('foo', $this->geocoderRequest->getAddress()); }