Index: trunk/extensions/Maps/includes/geocoders/Maps_GeonamesOldGeocoder.php |
— | — | @@ -1,71 +0,0 @@ |
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 | | - * @licence GNU GPL v3 |
15 | | - * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
16 | | - * |
17 | | - * Thanks go to Joel Natividad for pointing me to the GeoNames services. |
18 | | - */ |
19 | | -final class MapsGeonamesOldGeocoder extends MapsGeocoder { |
20 | | - |
21 | | - /** |
22 | | - * Registeres the geocoder. |
23 | | - * |
24 | | - * No LSB in pre-5.3 PHP *sigh*. |
25 | | - * This is to be refactored as soon as php >=5.3 becomes acceptable. |
26 | | - * |
27 | | - * @since 0.7 |
28 | | - */ |
29 | | - public static function register() { |
30 | | - global $egMapsGeoNamesUser; |
31 | | - |
32 | | - MapsGeocoders::registerGeocoder( $egMapsGeoNamesUser === '' ? 'geonames' : 'geonamesold', __CLASS__ ); |
33 | | - |
34 | | - return true; |
35 | | - } |
36 | | - |
37 | | - /** |
38 | | - * @see MapsGeocoder::getRequestUrl |
39 | | - * |
40 | | - * @since 0.7 |
41 | | - * |
42 | | - * @param string $address |
43 | | - * |
44 | | - * @return string |
45 | | - */ |
46 | | - protected function getRequestUrl( $address ) { |
47 | | - return 'http://ws.geonames.org/search?q=' . urlencode( $address ) . '&maxRows=1&style=SHORT'; |
48 | | - } |
49 | | - |
50 | | - /** |
51 | | - * @see MapsGeocoder::parseResponse |
52 | | - * |
53 | | - * @since 0.7 |
54 | | - * |
55 | | - * @param string $address |
56 | | - * |
57 | | - * @return array |
58 | | - */ |
59 | | - protected function parseResponse( $response ) { |
60 | | - $lon = self::getXmlElementValue( $response, 'lng' ); |
61 | | - $lat = self::getXmlElementValue( $response, 'lat' ); |
62 | | - |
63 | | - // In case one of the values is not found, return false. |
64 | | - if ( !$lon || !$lat ) return false; |
65 | | - |
66 | | - return array( |
67 | | - 'lat' => $lat, |
68 | | - 'lon' => $lon |
69 | | - ); |
70 | | - } |
71 | | - |
72 | | -} |
\ No newline at end of file |