예제 #1
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);
 }
예제 #2
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;
 }