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