/**
  * Sets the geometry location type.
  *
  * @param string $locationType The geometry location type.
  *
  * @throws \Ivory\GoogleMap\Exception\GeocodingException If the location type is not valid.
  */
 public function setLocationType($locationType)
 {
     if (!in_array($locationType, GeocoderLocationType::getGeocoderLocationTypes())) {
         throw GeocodingException::invalidGeocoderLocationType();
     }
     $this->locationType = $locationType;
 }
 /**
  * Sets the geocoder results status.
  *
  * @param string $status The geocoder result status.
  *
  * @throws \Ivory\GoogleMap\Exception\GeocodingException If the status is not valid.
  */
 public function setStatus($status)
 {
     if (!in_array($status, GeocoderStatus::getGeocoderStatus())) {
         throw GeocodingException::invalidGeocoderResponseStatus();
     }
     $this->status = $status;
 }
 /**
  * {@inheritdoc}
  *
  * @throws \Ivory\GoogleMap\Exception\GeocodingException If the request is not valid.
  */
 public function getGeocodedData($request)
 {
     if (is_string($request)) {
         $geocoderRequest = new GeocoderRequest();
         $geocoderRequest->setAddress($request);
     } elseif ($request instanceof GeocoderRequest) {
         $geocoderRequest = $request;
     } else {
         throw GeocodingException::invalidGeocoderProviderRequestArguments();
     }
     if (!$geocoderRequest->isValid()) {
         throw GeocodingException::invalidGeocoderProviderRequest();
     }
     $url = $this->generateUrl($geocoderRequest);
     $response = $this->getAdapter()->getContent($url);
     if ($response === null) {
         throw GeocodingException::invalidServiceResult();
     }
     $normalizedResponse = $this->parse($response);
     return $this->buildGeocoderResponse($normalizedResponse);
 }
예제 #4
0
 /**
  * Adds a type to the geocoder result.
  *
  * @param string $type The type to add.
  *
  * @throws \Ivory\GoogleMap\Exception\GeocodingException If the type is not valid.
  */
 public function addType($type)
 {
     if (!is_string($type)) {
         throw GeocodingException::invalidGeocoderResultType();
     }
     $this->types[] = $type;
 }
 /**
  * Sets the geocoder request sensor.
  *
  * @param boolean $sensor TRUE if the geocoder request has a sensor else FALSE.
  *
  * @throws \Ivory\GoogleMap\Exception\GeocodingRequest If the sensor flag is not valid.
  */
 public function setSensor($sensor)
 {
     if (!is_bool($sensor)) {
         throw GeocodingException::invalidGeocoderRequestSensor();
     }
     $this->sensor = $sensor;
 }