Esempio n. 1
0
 /**
  * Filling property 'coordinates'
  * @global string $egMultiMaps_CoordinatesSeparator
  * @param string $coordinates
  * @param string $service Name of map service
  * @return boolean
  */
 protected function parseCoordinates($coordinates, $service = null)
 {
     global $egMultiMaps_CoordinatesSeparator;
     $array = explode($egMultiMaps_CoordinatesSeparator, $coordinates);
     if ($service == 'leaflet' && count($array) == 1) {
         $value = $array[0];
         $coord = Geocoders::getCoordinates($value, $service, array('polygon' => true));
         if ($coord !== false && is_array($coord['polygon'])) {
             $this->coordinates = $coord['polygon'];
         } else {
             $this->errormessages[] = \wfMessage('multimaps-unable-parse-coordinates', $value)->escaped();
             return false;
         }
     } else {
         foreach ($array as $value) {
             $point = new Point();
             if ($point->parse($value, $service)) {
                 $this->coordinates[] = $point;
             } else {
                 $this->errormessages[] = \wfMessage('multimaps-unable-parse-coordinates', $value)->escaped();
                 return false;
             }
         }
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Parse geographic coordinates
  * @param string $string geographic coordinates
  * @param string $service Name of map service
  * @return boolean
  */
 public function parse($string, $service = null)
 {
     $coord = GeoCoordinate::getLatLonFromString($string);
     if (is_array($coord) === false) {
         $coord = Geocoders::getCoordinates($string, $service);
         if (is_array($coord) === false) {
             $this->latitude = false;
             $this->longitude = false;
             return false;
         }
         if (isset($coord['bounds'])) {
             $this->bounds = $coord['bounds'];
         }
     }
     $this->lat = $coord['lat'];
     $this->lon = $coord['lon'];
     return true;
 }
Esempio n. 3
0
 public function testReturnFalseOnUnknownService()
 {
     $this->assertFalse($this->object->getCoordinates('', ''));
     $this->assertFalse($this->object->getCoordinates('', 'blablabla'));
 }