r65783 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65782‎ | r65783 | r65784 >
Date:04:52, 2 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Cleared out issues with #finddestination function
Modified paths:
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/ParserFunctions/GeoFunctions/Maps_GeoFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/ParserFunctions/GeoFunctions/Maps_GeoFunctions.php
@@ -191,7 +191,7 @@
192192 array( 'location', 'bearing', 'distance' )
193193 );
194194 $doCalculation = $parameters !== false;
195 -
 195+
196196 if ( $doCalculation ) {
197197 $canGeocode = MapsMapper::geocoderIsAvailable();
198198
@@ -202,9 +202,7 @@
203203 }
204204
205205 if ( $location ) {
206 - // var_dump($location);
207206 $destination = self::findDestination( $location, $parameters['bearing'], $parameters['distance'] );
208 - // var_dump($destination);exit;
209207 $output = MapsCoordinateParser::formatCoordinates( $destination, $parameters['format'], $parameters['directional'] );
210208 } else {
211209 global $egValidatorFatalLevel;
@@ -278,17 +276,18 @@
279277 * @param float $distance The distance to travel in km.
280278 *
281279 * @return array The desitination coordinates, as non-directional floats in an array with lat and lon keys.
282 - *
283 - * FIXME: something here is going wrong - need to debug
284280 */
285281 public static function findDestination( array $startingCoordinates, $bearing, $distance ) {
286282 $startingCoordinates['lat'] = (float)$startingCoordinates['lat'];
287283 $startingCoordinates['lon'] = (float)$startingCoordinates['lon'];
 284+
288285 $angularDistance = $distance / Maps_EARTH_RADIUS;
 286+
289287 $lat = asin(
290288 sin( $startingCoordinates['lat'] ) * cos( $angularDistance ) +
291289 cos( $startingCoordinates['lat'] ) * sin( $angularDistance ) * cos( $bearing )
292290 );
 291+
293292 return array(
294293 'lat' => $lat,
295294 'lon' => $startingCoordinates['lon'] + atan2(
Index: trunk/extensions/Maps/Maps.php
@@ -33,7 +33,7 @@
3434 echo '<b>Warning:</b> You need to have <a href="http://www.mediawiki.org/wiki/Extension:Validator">Validator</a> installed in order to use <a href="http://www.mediawiki.org/wiki/Extension:Maps">Maps</a>.';
3535 }
3636 else {
37 - define( 'Maps_VERSION', '0.6 a18' );
 37+ define( 'Maps_VERSION', '0.6 a19' );
3838
3939 // The different coordinate notations.
4040 define( 'Maps_COORDS_FLOAT', 'float' );

Status & tagging log