Index: trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_BasePointMap.php |
— | — | @@ -92,10 +92,9 @@ |
93 | 93 | foreach ( $this->coordinates as $coordinates ) { |
94 | 94 | $args = explode( '~', $coordinates ); |
95 | 95 | |
96 | | - $args[0] = str_replace( '″', '"', $args[0] ); |
97 | | - $args[0] = str_replace( '′', "'", $args[0] ); |
| 96 | + $markerData = MapsCoordinateParser::parseCoordinates( $args[0] ); |
98 | 97 | |
99 | | - $markerData = MapsUtils::getLatLon( $args[0] ); |
| 98 | + if ( !$markerData ) continue; |
100 | 99 | |
101 | 100 | if ( count( $args ) > 1 ) { |
102 | 101 | // Parse and add the point specific title if it's present. |
— | — | @@ -178,7 +177,6 @@ |
179 | 178 | |
180 | 179 | // If the centre is not false, it will be a valid coordinate, which can be used to set the latitude and longitutde. |
181 | 180 | if ( $this->centre ) { |
182 | | - $this->centre = MapsUtils::getLatLon( $this->centre ); |
183 | 181 | $this->centre_lat = Xml::escapeJsString( $this->centre['lat'] ); |
184 | 182 | $this->centre_lon = Xml::escapeJsString( $this->centre['lon'] ); |
185 | 183 | } |
Index: trunk/extensions/Maps/ParserFunctions/DisplayMap/Maps_BaseMap.php |
— | — | @@ -77,7 +77,6 @@ |
78 | 78 | |
79 | 79 | // If the centre is not false, it will be a valid coordinate, which can be used to set the latitude and longitutde. |
80 | 80 | if ( $this->coordinates ) { |
81 | | - $this->coordinates = MapsUtils::getLatLon( $this->coordinates ); |
82 | 81 | $this->centre_lat = Xml::escapeJsString( $this->coordinates['lat'] ); |
83 | 82 | $this->centre_lon = Xml::escapeJsString( $this->coordinates['lon'] ); |
84 | 83 | } |
Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php |
— | — | @@ -232,7 +232,7 @@ |
233 | 233 | $args[0] = trim( $args[0] ); |
234 | 234 | |
235 | 235 | if ( strlen( $args[0] ) > 0 ) { |
236 | | - $coords = MapsGeocoder::attemptToGeocode( $args[0], $geoservice, $service, $isDefault ); |
| 236 | + $coords = MapsGeocoder::attemptToGeocodeToString( $args[0], $geoservice, $service, $isDefault ); |
237 | 237 | |
238 | 238 | if ( $coords ) { |
239 | 239 | $args[0] = $coords; |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | function efMapsSetup() { |
76 | 76 | global $wgExtensionCredits, $wgLang, $wgAutoloadClasses, $IP; |
77 | 77 | global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsDefaultGeoService; |
78 | | - global $egMapsAvailableGeoServices, $egMapsDir, $egMapsAvailableFeatures, $egMapsJsExt; |
| 78 | + global $egMapsAvailableGeoServices, $egMapsDir, $egMapsAvailableFeatures, $egMapsUseMinJs, $egMapsJsExt; |
79 | 79 | |
80 | 80 | // Remove all hooked in services that should not be available. |
81 | 81 | foreach ( $egMapsServices as $service => $data ) { |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -279,7 +279,9 @@ |
280 | 280 | </div></form></div> |
281 | 281 | EOT; |
282 | 282 | |
283 | | - $output .= "<script type='$wgJsMimeType'>" . implode( "\n", $onloadFunctions ) . '</script>'; |
| 283 | + if ( count($onloadFunctions) > 0 ) { |
| 284 | + $output .= "<script type='$wgJsMimeType'>" . implode( "\n", $onloadFunctions ) . '</script>'; |
| 285 | + } |
284 | 286 | } |
285 | 287 | |
286 | 288 | /** |
Index: trunk/extensions/Maps/Maps_Utils.php |
— | — | @@ -19,116 +19,8 @@ |
20 | 20 | // TODO: merge with parding done in the geo coord type located in SM. |
21 | 21 | |
22 | 22 | class MapsUtils { |
23 | | - |
24 | | - /* |
25 | | - * Returns an array containing the latitude (lat) and longitude (lon) |
26 | | - * of the provided coordinate string. |
27 | | - * |
28 | | - * @param string $coordinates |
29 | | - */ |
30 | | - public static function getLatLon( $coordinates ) { |
31 | | - $containsComma = strpos( $coordinates, ',' ) !== false; |
32 | | - $coordinates = $containsComma ? preg_split ( '/,/', $coordinates ) : explode ( ' ', $coordinates ); |
33 | 23 | |
34 | | - if ( count ( $coordinates ) == 2 ) { |
35 | | - return array ( |
36 | | - 'lat' => MapsUtils::convertCoord ( $coordinates [0] ), |
37 | | - 'lon' => MapsUtils::convertCoord ( $coordinates [1] ) |
38 | | - ); |
39 | | - } else { |
40 | | - return array ( 'lat' => null, 'lon' => null ); |
41 | | - } |
42 | | - } |
43 | | - |
44 | 24 | /** |
45 | | - * |
46 | | - * @param $deg_coord |
47 | | - * @return unknown_type |
48 | | - */ |
49 | | - private static function convertCoord( $deg_coord = '' ) { |
50 | | - if ( preg_match ( '/°/', $deg_coord ) ) { |
51 | | - if ( preg_match ( '/"/', $deg_coord ) ) { |
52 | | - return MapsUtils::DMSToDecimal ( $deg_coord ); |
53 | | - } else { |
54 | | - return MapsUtils::decDegree2Decimal ( $deg_coord ); |
55 | | - } |
56 | | - } |
57 | | - return $deg_coord; |
58 | | - } |
59 | | - |
60 | | - /** |
61 | | - * |
62 | | - * |
63 | | - * @param $deg_coord |
64 | | - * @return unknown_type |
65 | | - */ |
66 | | - private static function DMSToDecimal( $dmsCoordinates = '' ) { |
67 | | - $degreePosition = strpos( $dmsCoordinates, '°' ); |
68 | | - $minutePosition = strpos( $dmsCoordinates, '.' ); |
69 | | - $secondPosition = strpos( $dmsCoordinates, '"' ); |
70 | | - |
71 | | - $minuteLength = $minutePosition - $degreePosition - 1; |
72 | | - $secondLength = $secondPosition - $minutePosition - 1; |
73 | | - |
74 | | - $direction = substr ( strrev ( $dmsCoordinates ), 0, 1 ); |
75 | | - |
76 | | - $degrees = substr ( $dmsCoordinates, 0, $dpos ); |
77 | | - $minutes = substr ( $dmsCoordinates, $dpos + 1, $mlen ); |
78 | | - $seconds = substr ( $dmsCoordinates, $mpos + 1, $slen ); |
79 | | - |
80 | | - $seconds = ( $seconds / 60 ); |
81 | | - $minutes = ( $minutes + $seconds ); |
82 | | - $minutes = ( $minutes / 60 ); |
83 | | - $decimal = ( $degrees + $minutes ); |
84 | | - |
85 | | - // South latitudes and West longitudes need to return a negative result |
86 | | - if ( $direction == "S" || $direction == "W" ) { |
87 | | - $decimal *= - 1; |
88 | | - } |
89 | | - return $decimal; |
90 | | - } |
91 | | - |
92 | | - /** |
93 | | - * |
94 | | - * @param $deg_coord |
95 | | - * @return unknown_type |
96 | | - */ |
97 | | - private static function decDegree2Decimal( $deg_coord = "" ) { |
98 | | - $direction = substr ( strrev ( $deg_coord ), 0, 1 ); |
99 | | - $decimal = floatval ( $deg_coord ); |
100 | | - if ( ( $direction == "S" ) or ( $direction == "W" ) ) { |
101 | | - $decimal *= - 1; |
102 | | - } |
103 | | - return $decimal; |
104 | | - } |
105 | | - |
106 | | - /** |
107 | | - * |
108 | | - * @param $decimal |
109 | | - * @return unknown_type |
110 | | - */ |
111 | | - public static function latDecimal2Degree( $decimal ) { |
112 | | - if ( $decimal < 0 ) { |
113 | | - return abs ( $decimal ) . "° S"; |
114 | | - } else { |
115 | | - return $decimal . "° N"; |
116 | | - } |
117 | | - } |
118 | | - |
119 | | - /** |
120 | | - * |
121 | | - * @param $decimal |
122 | | - * @return unknown_type |
123 | | - */ |
124 | | - public static function lonDecimal2Degree( $decimal ) { |
125 | | - if ( $decimal < 0 ) { |
126 | | - return abs ( $decimal ) . "° W"; |
127 | | - } else { |
128 | | - return $decimal . "° E"; |
129 | | - } |
130 | | - } |
131 | | - |
132 | | - /** |
133 | 25 | * Convert from WGS84 to spherical mercator. |
134 | 26 | */ |
135 | 27 | public static function forwardMercator( array $lonlat ) { |
Index: trunk/extensions/Maps/Geocoders/Maps_Geocoder.php |
— | — | @@ -40,29 +40,26 @@ |
41 | 41 | * @param string $geoservice |
42 | 42 | * @param string $service |
43 | 43 | * @param boolean $checkForCoords |
44 | | - * @param coordinate type $targetFormat The notation to which they should be formatted. Defaults to floats. |
45 | | - * @param boolean $directional Indicates if the target notation should be directional. Defaults to false. |
46 | 44 | * |
47 | | - * @return string or boolean |
| 45 | + * @return array or false |
48 | 46 | */ |
49 | | - public static function attemptToGeocode( $coordsOrAddress, $geoservice, $service, $checkForCoords = true, $targetFormat = Maps_COORDS_FLOAT, $directional = false ) { |
| 47 | + public static function attemptToGeocode( $coordsOrAddress, $geoservice, $service, $checkForCoords = true ) { |
50 | 48 | if ( $checkForCoords ) { |
51 | 49 | if ( MapsCoordinateParser::areCoordinates( $coordsOrAddress ) ) { |
52 | | - $parsedCoordinates = MapsCoordinateParser::parseCoordinates( $coordsOrAddress ); |
53 | | - return MapsCoordinateParser::formatCoordinates( $parsedCoordinates, $targetFormat, $directional ); |
| 50 | + return MapsCoordinateParser::parseCoordinates( $coordsOrAddress ); |
54 | 51 | } else { |
55 | | - return self::geocodeToString( $coordsOrAddress, $geoservice, $service, $targetFormat, $directional ); |
| 52 | + return self::geocode( $coordsOrAddress, $geoservice, $service ); |
56 | 53 | } |
57 | 54 | } else { |
58 | | - return self::geocodeToString( $coordsOrAddress, $geoservice, $service, $targetFormat, $directional ); |
| 55 | + return self::geocode( $coordsOrAddress, $geoservice, $service ); |
59 | 56 | } |
60 | | - } |
| 57 | + } |
61 | 58 | |
62 | 59 | /** |
63 | 60 | * Geocodes an address with the provided geocoding service and returns the result |
64 | 61 | * as a string with the optionally provided format, or false when the geocoding failed. |
65 | 62 | * |
66 | | - * @param string $address |
| 63 | + * @param string $coordsOrAddress |
67 | 64 | * @param string $service |
68 | 65 | * @param string $mappingService |
69 | 66 | * @param coordinate type $targetFormat The notation to which they should be formatted. Defaults to floats. |
— | — | @@ -70,9 +67,9 @@ |
71 | 68 | * |
72 | 69 | * @return formatted coordinate string or false |
73 | 70 | */ |
74 | | - public static function geocodeToString( $address, $service = '', $mappingService = '', $targetFormat = Maps_COORDS_FLOAT, $directional = false ) { |
75 | | - $geovalues = MapsGeocoder::geocode( $address, $service, $mappingService ); |
76 | | - return $geovalues ? MapsCoordinateParser::formatCoordinates( $geovalues, $targetFormat, $directional ) : false; |
| 71 | + public static function attemptToGeocodeToString( $coordsOrAddress, $service = '', $mappingService = '', $checkForCoords = true, $targetFormat = Maps_COORDS_FLOAT, $directional = false ) { |
| 72 | + $geoValues = self::attemptToGeocode( $coordsOrAddress, $service, $mappingService, $checkForCoords ); |
| 73 | + return $geoValues ? MapsCoordinateParser::formatCoordinates( $geoValues, $targetFormat, $directional ) : false; |
77 | 74 | } |
78 | 75 | |
79 | 76 | /** |