예제 #1
0
 /**
  * Registers the geocoder.
  * 
  * No LSB in pre-5.3 PHP *sigh*.
  * This is to be refactored as soon as php >=5.3 becomes acceptable.
  * 
  * @since 1.0
  */
 public static function register()
 {
     global $egMapsGeoNamesUser;
     if ($egMapsGeoNamesUser !== '') {
         \Maps\Geocoders::registerGeocoder('geonames', __CLASS__);
     }
     return true;
 }
예제 #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);
 }
예제 #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;
 }
예제 #4
0
 /**
  * Registers the geocoder.
  * 
  * No LSB in pre-5.3 PHP *sigh*.
  * This is to be refactored as soon as php >=5.3 becomes acceptable.
  * 
  * @since 3.0
  */
 public static function register()
 {
     \Maps\Geocoders::registerGeocoder('geocoderus', __CLASS__);
     return true;
 }
예제 #5
0
 /**
  * Sets the location to an address.
  *
  * @since 0.7.1
  *
  * @param string $address
  * @param boolean $asActualLocation When set to false, the location is not changed, only the address string is.
  *
  * @return boolean Success indicator
  */
 public function setAddress($address, $asActualLocation = true)
 {
     if ($asActualLocation) {
         $coordinates = \Maps\Geocoders::geocode($address);
         if ($coordinates === false) {
             return false;
         }
         $this->setCoordinates($coordinates);
     }
     $this->address = $address;
     return true;
 }
예제 #6
0
 public function getAllowedParams()
 {
     return array('locations' => array(ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true, ApiBase::PARAM_ISMULTI => true), 'service' => array(ApiBase::PARAM_TYPE => \Maps\Geocoders::getAvailableGeocoders()), 'props' => array(ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => array('lat', 'lon', 'alt'), ApiBase::PARAM_DFLT => 'lat|lon'));
 }