Exemple #1
0
 /**
  * @covers MultiMaps\Point::isValid
  * @covers \MultiMaps\Point::parse
  */
 public function testIsValidParse()
 {
     $this->assertTrue($this->object->isValid());
     $this->object->parse("123456");
     $this->assertFalse($this->object->isValid());
     $this->object->parse("123,456");
     $this->assertTrue($this->object->isValid());
 }
Exemple #2
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;
 }
function parse($line)
{
    list($c, $r, $p) = explode(";", $line);
    $center = Point::parse($c);
    $point = Point::parse($p);
    list($radius_name, $radius_value) = explode(":", $r);
    $radius = trim($radius_value);
    return array(new Circle($center, $radius), $point);
}
Exemple #4
0
 /**
  * Parse coordinates for rectangle
  *
  * @assert ('10,10:20,20') === true
  * @assert ('10,10:20,20:30,30') === false
  * @assert ('10,10:20,20:30') === false
  * @assert ('10,10:20') === false
  * @assert ('10,10:') === false
  * @assert ('10,10') === false
  * @assert ('10') === false
  *
  * @global type $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 (count($array) == 2) {
         $point1 = new Point();
         $point2 = new Point();
         if ($point1->parse($array[0], $service)) {
             if ($point2->parse($array[1], $service)) {
                 $this->coordinates[] = $point1;
                 $this->coordinates[] = $point2;
             } else {
                 $this->errormessages[] = \wfMessage('multimaps-unable-parse-coordinates', $array[1])->escaped();
                 return false;
             }
         } else {
             $this->errormessages[] = \wfMessage('multimaps-unable-parse-coordinates', $array[0])->escaped();
             return false;
         }
     } else {
         if (count($array) == 1) {
             $point = new Point();
             if ($point->parse($array[0], $service)) {
                 $bounds = $point->bounds;
                 if ($bounds) {
                     $this->coordinates[] = $bounds->ne;
                     $this->coordinates[] = $bounds->sw;
                 } else {
                     $this->errormessages[] = \wfMessage('multimaps-square-wrong-number-points', count($array))->escaped();
                     return false;
                 }
             } else {
                 $this->errormessages[] = \wfMessage('multimaps-unable-parse-coordinates', $array[0])->escaped();
                 return false;
             }
         } else {
             $this->errormessages[] = \wfMessage('multimaps-square-wrong-number-points', count($array))->escaped();
             return false;
         }
     }
     return true;
 }
Exemple #5
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 (count($array) == 2) {
         $point = new Point();
         if ($point->parse($array[0], $service)) {
             if (is_numeric($array[1])) {
                 $this->coordinates[] = $point;
                 $this->radiuses[] = (double) $array[1];
             } else {
                 $this->errormessages[] = \wfMessage('multimaps-unable-parse-radius', $array[1])->escaped();
                 return false;
             }
         } else {
             $this->errormessages[] = \wfMessage('multimaps-unable-parse-coordinates', $array[0])->escaped();
             return false;
         }
     } else {
         if (count($array) == 1) {
             $point = new Point();
             if ($point->parse($array[0], $service)) {
                 $bounds = $point->bounds;
                 if ($bounds) {
                     $this->coordinates[] = $bounds->center;
                     $this->radiuses[] = $bounds->diagonal / 2;
                 } else {
                     $this->errormessages[] = \wfMessage('multimaps-circle-radius-not-defined')->escaped();
                     return false;
                 }
             } else {
                 $this->errormessages[] = \wfMessage('multimaps-unable-parse-coordinates', $array[0])->escaped();
                 return false;
             }
         } else {
             $this->errormessages[] = \wfMessage('multimaps-circle-wrong-number-parameters', count($array))->escaped();
             return false;
         }
     }
     return true;
 }
 /**
  * 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);
     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;
 }