Index: trunk/extensions/SemanticMaps/GeoCoords/SM_DistanceValue.php |
— | — | @@ -1 +0,0 @@ |
2 | | -<?php |
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php |
— | — | @@ -88,7 +88,7 @@ |
89 | 89 | $distance = count( $parts ) > 0 ? trim( array_shift( $parts ) ) : false; |
90 | 90 | |
91 | 91 | if ( $distance !== false ) { |
92 | | - if ( preg_match( '/^\d+(\.\d+)?\)$/', $distance ) ) { |
| 92 | + if ( preg_match( '/^\d+(\.\d+)?(\s.+)\)$/', $distance ) ) { |
93 | 93 | $distance = substr( $distance, 0, -1 ); |
94 | 94 | } |
95 | 95 | else { |
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_AreaValueDescription.php |
— | — | @@ -28,6 +28,28 @@ |
29 | 29 | public function __construct( SMGeoCoordsValue $dataValue, $radius ) { |
30 | 30 | parent::__construct( $dataValue, SM_CMP_NEAR ); |
31 | 31 | |
| 32 | + // Parse the radius to the actual value and the optional unit. |
| 33 | + $radius = preg_replace('/\s\s+/', ' ', $radius); |
| 34 | + $parts = explode( ' ', $radius ); |
| 35 | + $radius = (float)array_shift( $parts ); |
| 36 | + |
| 37 | + // If there is a unit, find it's ratio and apply it to the radius value. |
| 38 | + if ( count( $parts ) > 0 ) { |
| 39 | + $unit = strtolower( implode( ' ', $parts ) ); |
| 40 | + |
| 41 | + $ratio = array( |
| 42 | + 'km' => 1000, |
| 43 | + 'mile' => 1609.344, |
| 44 | + 'miles' => 1609.344, |
| 45 | + 'nautical mile' => 1852, |
| 46 | + 'nautical miles' => 1852, |
| 47 | + ); |
| 48 | + |
| 49 | + if ( array_key_exists( $unit, $ratio ) ) { |
| 50 | + $radius = $radius * $ratio[$unit]; |
| 51 | + } |
| 52 | + } |
| 53 | + |
32 | 54 | // If the MapsGeoFunctions class is not loaded, we can not create the bounding box, |
33 | 55 | // so don't add any conditions. |
34 | 56 | if ( self::geoFunctionsAreAvailable() ) { |
— | — | @@ -38,7 +60,7 @@ |
39 | 61 | 'lat' => $dbKeys[0], |
40 | 62 | 'lon' => $dbKeys[1] |
41 | 63 | ), |
42 | | - $radius * 1000 |
| 64 | + $radius |
43 | 65 | ); |
44 | 66 | } |
45 | 67 | } |