Exemple #1
0
 /**
  * Creates and returns a new instance of a Location from an address.
  *
  * @since 1.0
  *
  * @param string $address
  * @deprecated
  *
  * @return Location
  * @throws MWException
  */
 public static function newFromAddress($address)
 {
     $address = Geocoders::attemptToGeocode($address);
     if ($address === false) {
         throw new MWException('Could not geocode address');
     }
     return new static($address);
 }
Exemple #2
0
 private function stringToLatLongValue($location)
 {
     if ($this->supportGeocoding && Geocoders::canGeocode()) {
         $location = Geocoders::attemptToGeocode($location);
         if ($location === false) {
             throw new ParseException('Failed to parse or geocode');
         }
         assert($location instanceof LatLongValue);
         return $location;
     }
     $parser = new GeoCoordinateParser(new \ValueParsers\ParserOptions());
     return $parser->parse($location);
 }
Exemple #3
0
 /**
  * @since 3.0
  *
  * @param string[] $coordinateStrings
  *
  * @return LatLongValue[]
  */
 protected function parseCoordinates(array $coordinateStrings)
 {
     $coordinates = array();
     $coordinateParser = new GeoCoordinateParser(new \ValueParsers\ParserOptions());
     $supportsGeocoding = $this->supportGeocoding && \Maps\Geocoders::canGeocode();
     foreach ($coordinateStrings as $coordinateString) {
         if ($supportsGeocoding) {
             $coordinate = \Maps\Geocoders::attemptToGeocode($coordinateString);
             if ($coordinate === false) {
                 // TODO
             } else {
                 $coordinates[] = $coordinate;
             }
         } else {
             $coordinates[] = $coordinateParser->parse($coordinateString);
         }
     }
     return $coordinates;
 }