예제 #1
0
 /**
  * Geocode address and retries if first attempt or value in session
  * is not geocoded
  *
  * @param Model\Constraint|Model\Location $address
  * @param bool $forceGeocoding
  * @return Model\Constraint|Model\Location
  */
 public function geocodeAddress($address, $forceGeocoding = FALSE)
 {
     $geocodedAddress = $this->coordinatesCache->getCoordinateByAddress($address);
     if ($forceGeocoding || !$geocodedAddress->isGeocoded()) {
         $fieldsHit = array();
         $geocodedAddress = $this->processAddress($address, $fieldsHit);
         $this->coordinatesCache->addCoordinateForAddress($geocodedAddress, $fieldsHit);
     }
     // In case the address without geocoded location was stored in
     // session or the geocoding did not work a second try is done
     if (!$forceGeocoding && !$geocodedAddress->isGeocoded()) {
         $geocodedAddress = $this->geocodeAddress($geocodedAddress, TRUE);
     }
     return $geocodedAddress;
 }