示例#1
0
 /**
  * @param string $source
  * @param City $destination
  * @return mixed
  */
 public function map($source, $destination)
 {
     $destination->setName($source);
     $translations = array('fr' => $source);
     if (!$destination->getName()) {
         $translations = array('en' => $source);
     }
     $this->translateProperty($destination, 'name', $translations);
     if ($destination->getLatitude() == null || $destination->getLongitude() == null) {
         $tabCoord = $this->google->getGoogleXmlCoords($source, 'fr');
         if (isset($tabCoord[0]) && !empty($tabCoord[0]) && isset($tabCoord[1]) && !empty($tabCoord[1])) {
             $destination->setLatitude($tabCoord[0]);
             $destination->setLongitude($tabCoord[1]);
         }
     }
     return $destination;
 }
示例#2
0
文件: Hotel.php 项目: blab2015/seh
 /**
  * Get linkedCity
  *
  * @return City
  */
 public function getLinkedCityForSearchResults()
 {
     /** @var City $toReturn */
     $toReturn = null;
     /** @var City $linkedCity */
     foreach ($this->linkedCities as $linkedCity) {
         if ($linkedCity->getName() == $this->city->getName()) {
             if ($linkedCity->getLatitude() && $linkedCity->getLongitude() && $this->latitude && $this->longitude) {
                 $linkedCity->setDistance(GeolocManager::calculateDistance($linkedCity->getLatitude(), $linkedCity->getLongitude(), $this->latitude, $this->longitude));
             }
             return $linkedCity;
         }
         $distance = 0;
         if ($linkedCity->getLatitude() && $linkedCity->getLongitude() && $this->latitude && $this->longitude) {
             $distance = GeolocManager::calculateDistance($linkedCity->getLatitude(), $linkedCity->getLongitude(), $this->latitude, $this->longitude);
         }
         if ($distance > 0 and (!$toReturn or $distance < $toReturn->getDistance())) {
             $linkedCity->setDistance($distance);
             $toReturn = $linkedCity;
         }
     }
     return $toReturn;
 }