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); }
/** * @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; }