コード例 #1
0
 /**
  * @see ParserHookTest::processingProvider
  * @since 3.0
  * @return array
  */
 public function processingProvider()
 {
     $argLists = array();
     $coordinateParser = new \ValueParsers\GeoCoordinateParser(new \ValueParsers\ParserOptions());
     foreach ($this->distances as $distance => $expectedDistance) {
         foreach ($this->bearings as $bearing) {
             foreach ($this->locations as $location) {
                 $values = array('distance' => (string) $distance, 'bearing' => (string) $bearing, 'location' => (string) $location);
                 $expected = array('distance' => $expectedDistance, 'bearing' => (double) $bearing, 'location' => new Location($coordinateParser->parse($location)->getValue()));
                 $argLists[] = array($values, $expected);
             }
         }
     }
     return $argLists;
 }
コード例 #2
0
ファイル: LineParser.php プロジェクト: whysasse/kmwiki
 /**
  * @since 3.0
  *
  * @param string[] $coordinateStrings
  *
  * @return LatLongValue[]
  */
 protected function parseCoordinates(array $coordinateStrings)
 {
     $coordinates = array();
     $coordinateParser = new \ValueParsers\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;
 }
コード例 #3
0
ファイル: Geocoders.php プロジェクト: whysasse/kmwiki
 /**
  * This function first determines wether the provided string is a pair or coordinates
  * or an address. If it's the later, an attempt to geocode will be made. The function will
  * return the coordinates or false, in case a geocoding attempt was made but failed. 
  * 
  * @since 0.7
  * 
  * @param string $coordsOrAddress
  * @param string $geoservice
  * @param string|false $mappingService
  * @param boolean $checkForCoords
  *
  * @return LatLongValue|false
  */
 public static function attemptToGeocode($coordsOrAddress, $geoservice = '', $mappingService = false, $checkForCoords = true)
 {
     if ($checkForCoords) {
         $coordinateParser = new \ValueParsers\GeoCoordinateParser(new \ValueParsers\ParserOptions());
         try {
             return $coordinateParser->parse($coordsOrAddress);
         } catch (ParseException $parseException) {
             return self::geocode($coordsOrAddress, $geoservice, $mappingService);
         }
     } else {
         return self::geocode($coordsOrAddress, $geoservice, $mappingService);
     }
 }