r83910 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83909‎ | r83910 | r83911 >
Date:16:09, 14 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
updating geonames geocoder
Modified paths:
  • /branches/Maps0.8/Maps.php (modified) (history)
  • /branches/Maps0.8/Maps_Settings.php (modified) (history)
  • /branches/Maps0.8/includes/geocoders/Maps_GeonamesGeocoder.php (deleted) (history)
  • /branches/Maps0.8/includes/geocoders/Maps_GeonamesOldGeocoder.php (added) (history)
  • /branches/Maps0.8/includes/geocoders/Maps_GoogleGeocoder.php (modified) (history)
  • /branches/Maps0.8/includes/geocoders/Maps_YahooGeocoder.php (modified) (history)

Diff [purge]

Index: branches/Maps0.8/Maps.php
@@ -182,8 +182,11 @@
183183 # Geocoders
184184
185185 # Registration of the GeoNames service geocoder.
186 - $wgHooks['GeocoderFirstCallInit'][] = 'MapsGeonamesGeocoder::register';
 186+ $wgHooks['GeocoderFirstCallInit'][] = 'MapsGeonamesGeocoder::register';
187187
 188+ # Registration of the legacy GeoNames service geocoder.
 189+ $wgHooks['GeocoderFirstCallInit'][] = 'MapsGeonamesOldGeocoder::register';
 190+
188191 # Registration of the Google Geocoding (v2) service geocoder.
189192 $wgHooks['GeocoderFirstCallInit'][] = 'MapsGoogleGeocoder::register';
190193
Index: branches/Maps0.8/Maps_Settings.php
@@ -74,7 +74,12 @@
7575 $egMapsAllowCoordsGeocoding = true;
7676
7777 # 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 = '';
7984
8085
8186
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 @@
1818 /**
1919 * Registeres the geocoder.
2020 *
21 - * No LST in pre-5.3 PHP *sigh*.
 21+ * No LSB in pre-5.3 PHP *sigh*.
2222 * This is to be refactored as soon as php >=5.3 becomes acceptable.
2323 *
2424 * @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
171 + native
Index: branches/Maps0.8/includes/geocoders/Maps_YahooGeocoder.php
@@ -16,7 +16,7 @@
1717 /**
1818 * Registeres the geocoder.
1919 *
20 - * No LST in pre-5.3 PHP *sigh*.
 20+ * No LSB in pre-5.3 PHP *sigh*.
2121 * This is to be refactored as soon as php >=5.3 becomes acceptable.
2222 *
2323 * @since 0.7

Follow-up revisions

RevisionCommit summaryAuthorDate
r83911follow up to r83910jeroendedauw16:15, 14 March 2011
r83912follow up to r83910jeroendedauw16:15, 14 March 2011

Status & tagging log