Index: branches/Maps0.8/Maps.php |
— | — | @@ -182,8 +182,11 @@ |
183 | 183 | # Geocoders |
184 | 184 | |
185 | 185 | # Registration of the GeoNames service geocoder. |
186 | | - $wgHooks['GeocoderFirstCallInit'][] = 'MapsGeonamesGeocoder::register'; |
| 186 | + $wgHooks['GeocoderFirstCallInit'][] = 'MapsGeonamesGeocoder::register'; |
187 | 187 | |
| 188 | + # Registration of the legacy GeoNames service geocoder. |
| 189 | + $wgHooks['GeocoderFirstCallInit'][] = 'MapsGeonamesOldGeocoder::register'; |
| 190 | + |
188 | 191 | # Registration of the Google Geocoding (v2) service geocoder. |
189 | 192 | $wgHooks['GeocoderFirstCallInit'][] = 'MapsGoogleGeocoder::register'; |
190 | 193 | |
Index: branches/Maps0.8/Maps_Settings.php |
— | — | @@ -74,7 +74,12 @@ |
75 | 75 | $egMapsAllowCoordsGeocoding = true; |
76 | 76 | |
77 | 77 | # Boolean. Sets if geocoded addresses should be stored in a cache. |
78 | | - $egMapsEnableGeoCache = true; |
| 78 | + $egMapsEnableGeoCache = true; |
| 79 | + |
| 80 | + # String. GeoNames API user/application name. |
| 81 | + # Obtain an account here: http://www.geonames.org/login |
| 82 | + # Do not forget to activate your account for API usage! |
| 83 | + $egMapsGeoNamesUser = ''; |
79 | 84 | |
80 | 85 | |
81 | 86 | |
Index: branches/Maps0.8/includes/geocoders/Maps_GeonamesGeocoder.php |
— | — | @@ -1,65 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Class for geocoding requests with the GeoNames webservice. |
6 | | - * |
7 | | - * GeoNames Web Services Documentation: http://www.geonames.org/export/geonames-search.html |
8 | | - * |
9 | | - * @file Maps_GeonamesGeocoder.php |
10 | | - * @ingroup Maps |
11 | | - * @ingroup Geocoders |
12 | | - * |
13 | | - * @author Jeroen De Dauw |
14 | | - * Thanks go to Joel Natividad for pointing me to the GeoNames services. |
15 | | - */ |
16 | | -final class MapsGeonamesGeocoder extends MapsGeocoder { |
17 | | - |
18 | | - /** |
19 | | - * Registeres the geocoder. |
20 | | - * |
21 | | - * No LST in pre-5.3 PHP *sigh*. |
22 | | - * This is to be refactored as soon as php >=5.3 becomes acceptable. |
23 | | - * |
24 | | - * @since 0.7 |
25 | | - */ |
26 | | - public static function register() { |
27 | | - MapsGeocoders::registerGeocoder( 'geonames', __CLASS__ ); |
28 | | - return true; |
29 | | - } |
30 | | - |
31 | | - /** |
32 | | - * @see MapsGeocoder::getRequestUrl |
33 | | - * |
34 | | - * @since 0.7 |
35 | | - * |
36 | | - * @param string $address |
37 | | - * |
38 | | - * @return string |
39 | | - */ |
40 | | - protected function getRequestUrl( $address ) { |
41 | | - return 'http://ws.geonames.org/search?q=' . urlencode( $address ) . '&maxRows=1&style=SHORT'; |
42 | | - } |
43 | | - |
44 | | - /** |
45 | | - * @see MapsGeocoder::parseResponse |
46 | | - * |
47 | | - * @since 0.7 |
48 | | - * |
49 | | - * @param string $address |
50 | | - * |
51 | | - * @return array |
52 | | - */ |
53 | | - protected function parseResponse( $response ) { |
54 | | - $lon = self::getXmlElementValue( $response, 'lng' ); |
55 | | - $lat = self::getXmlElementValue( $response, 'lat' ); |
56 | | - |
57 | | - // In case one of the values is not found, return false. |
58 | | - if ( !$lon || !$lat ) return false; |
59 | | - |
60 | | - return array( |
61 | | - 'lat' => $lat, |
62 | | - 'lon' => $lon |
63 | | - ); |
64 | | - } |
65 | | - |
66 | | -} |
\ No newline at end of file |
Index: branches/Maps0.8/includes/geocoders/Maps_GoogleGeocoder.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | /** |
19 | 19 | * Registeres the geocoder. |
20 | 20 | * |
21 | | - * No LST in pre-5.3 PHP *sigh*. |
| 21 | + * No LSB in pre-5.3 PHP *sigh*. |
22 | 22 | * This is to be refactored as soon as php >=5.3 becomes acceptable. |
23 | 23 | * |
24 | 24 | * @since 0.7 |
Index: branches/Maps0.8/includes/geocoders/Maps_GeonamesOldGeocoder.php |
— | — | @@ -0,0 +1,69 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class for geocoding requests with the GeoNames webservice. |
| 6 | + * @deprecated |
| 7 | + * |
| 8 | + * GeoNames Web Services Documentation: http://www.geonames.org/export/geonames-search.html |
| 9 | + * |
| 10 | + * @file Maps_GeonamesGeocoder.php |
| 11 | + * @ingroup Maps |
| 12 | + * @ingroup Geocoders |
| 13 | + * |
| 14 | + * @author Jeroen De Dauw |
| 15 | + * Thanks go to Joel Natividad for pointing me to the GeoNames services. |
| 16 | + */ |
| 17 | +final class MapsGeonamesOldGeocoder extends MapsGeocoder { |
| 18 | + |
| 19 | + /** |
| 20 | + * Registeres the geocoder. |
| 21 | + * |
| 22 | + * No LSB in pre-5.3 PHP *sigh*. |
| 23 | + * This is to be refactored as soon as php >=5.3 becomes acceptable. |
| 24 | + * |
| 25 | + * @since 0.7 |
| 26 | + */ |
| 27 | + public static function register() { |
| 28 | + global $egMapsGeoNamesUser; |
| 29 | + |
| 30 | + MapsGeocoders::registerGeocoder( $egMapsGeoNamesUser == '' ? 'geonames' : 'geonamesold', __CLASS__ ); |
| 31 | + |
| 32 | + return true; |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * @see MapsGeocoder::getRequestUrl |
| 37 | + * |
| 38 | + * @since 0.7 |
| 39 | + * |
| 40 | + * @param string $address |
| 41 | + * |
| 42 | + * @return string |
| 43 | + */ |
| 44 | + protected function getRequestUrl( $address ) { |
| 45 | + return 'http://ws.geonames.org/search?q=' . urlencode( $address ) . '&maxRows=1&style=SHORT'; |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @see MapsGeocoder::parseResponse |
| 50 | + * |
| 51 | + * @since 0.7 |
| 52 | + * |
| 53 | + * @param string $address |
| 54 | + * |
| 55 | + * @return array |
| 56 | + */ |
| 57 | + protected function parseResponse( $response ) { |
| 58 | + $lon = self::getXmlElementValue( $response, 'lng' ); |
| 59 | + $lat = self::getXmlElementValue( $response, 'lat' ); |
| 60 | + |
| 61 | + // In case one of the values is not found, return false. |
| 62 | + if ( !$lon || !$lat ) return false; |
| 63 | + |
| 64 | + return array( |
| 65 | + 'lat' => $lat, |
| 66 | + 'lon' => $lon |
| 67 | + ); |
| 68 | + } |
| 69 | + |
| 70 | +} |
\ No newline at end of file |
Property changes on: branches/Maps0.8/includes/geocoders/Maps_GeonamesOldGeocoder.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 71 | + native |
Index: branches/Maps0.8/includes/geocoders/Maps_YahooGeocoder.php |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | /** |
18 | 18 | * Registeres the geocoder. |
19 | 19 | * |
20 | | - * No LST in pre-5.3 PHP *sigh*. |
| 20 | + * No LSB in pre-5.3 PHP *sigh*. |
21 | 21 | * This is to be refactored as soon as php >=5.3 becomes acceptable. |
22 | 22 | * |
23 | 23 | * @since 0.7 |