Index: trunk/extensions/SemanticMediaWiki/RELEASE-NOTES |
— | — | @@ -14,14 +14,17 @@ |
15 | 15 | * Added alpha version of native SMW Ask API with moudles ask and askargs. |
16 | 16 | * Added setting to choose which optional special properties are enabled ($smwgPageSpecialProperties). |
17 | 17 | * Added creation date special property (disabled by default) (bug 32165). |
| 18 | +* Added support for altitudes in geographic coordinates (bug 32698). |
| 19 | +* Dropped compatibility with MediaWiki 1.15.x (and earlier). |
| 20 | +* Dropped compatibility with old-style (SMW < 1.6) query printers. |
18 | 21 | * Fixed separator and filename parameters for the DSV format. |
19 | 22 | * Fixed display of properties of type URL (bug 30912). |
20 | 23 | * Fixed hide query functionality on Special:Ask (bug 30768). |
21 | 24 | * Fixed display of internal SMW helper constants in certain queries (bug 30969). |
22 | 25 | * Fixed some issues with the category result format (including bug 30761). |
23 | 26 | * Fixed email validation issue (bug 32295). |
24 | | -* Dropped compatibility with MediaWiki 1.15.x (and earlier). |
25 | | -* Dropped compatibility with old-style (SMW < 1.6) query printers. |
| 27 | +* Fixed incorrect handling of sort and order parameters on Special:Ask (bug 32706). |
| 28 | +* Fixed several more issues not listed here. |
26 | 29 | |
27 | 30 | == SMW 1.6.1 == |
28 | 31 | |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -2499,8 +2499,8 @@ |
2500 | 2500 | |
2501 | 2501 | self::$prop_tables['smw_coords'] = new SMWSQLStore2Table( |
2502 | 2502 | 'sm_coords', |
2503 | | - array( 'lat' => 'f', 'lon' => 'f' ), |
2504 | | - array( 'lat', 'lon' ) |
| 2503 | + array( 'lat' => 'f', 'lon' => 'f', 'alt' => 'f' ), |
| 2504 | + array( 'lat', 'lon', 'alt' ) |
2505 | 2505 | ); |
2506 | 2506 | |
2507 | 2507 | wfRunHooks( 'SMWPropertyTables', array( &self::$prop_tables ) ); |
Index: trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_GeoCoord.php |
— | — | @@ -13,16 +13,67 @@ |
14 | 14 | */ |
15 | 15 | class SMWDIGeoCoord extends SMWDataItem { |
16 | 16 | |
17 | | - protected $coordinateSet; |
| 17 | + /** |
| 18 | + * The locations latitude. |
| 19 | + * |
| 20 | + * @since 1.6 |
| 21 | + * @var float |
| 22 | + */ |
| 23 | + protected $latitude; |
| 24 | + |
| 25 | + /** |
| 26 | + * The locations longitude. |
| 27 | + * |
| 28 | + * @since 1.6 |
| 29 | + * @var float |
| 30 | + */ |
| 31 | + protected $longitude; |
| 32 | + |
| 33 | + /** |
| 34 | + * The locations altitude. |
| 35 | + * |
| 36 | + * @since 1.7 |
| 37 | + * @var float|null |
| 38 | + */ |
| 39 | + protected $altitude = null; |
18 | 40 | |
19 | 41 | /** |
20 | 42 | * Constructor. |
| 43 | + * Takes a latitude and longitude, and optionally an altitude. These can be provided in 2 forms: |
| 44 | + * * An associative array with lat, lon and alt keys |
| 45 | + * * Lat, lon and alt arguments |
21 | 46 | * |
22 | | - * @param $coords array Array with lat and long keys pointing to float values. |
23 | | - * @param $typeid string |
| 47 | + * The second way to provide the arguments, as well as the altitude argument, where introduced in SMW 1.7. |
24 | 48 | */ |
25 | | - public function __construct( array $coords ) { |
26 | | - $this->coordinateSet = $coords; |
| 49 | + public function __construct() { |
| 50 | + $args = func_get_args(); |
| 51 | + |
| 52 | + $count = count( $args ); |
| 53 | + |
| 54 | + if ( $count === 1 && is_array( $args[0] ) ) { |
| 55 | + if ( array_key_exists( 'lat', $args[0] ) && array_key_exists( 'lon', $args[0] ) ) { |
| 56 | + $this->latitude = (float)$args[0]['lat']; |
| 57 | + $this->longitude = (float)$args[0]['lon']; |
| 58 | + |
| 59 | + if ( array_key_exists( 'alt', $args[0] ) ) { |
| 60 | + $this->altitude = (float)$args[0]['alt']; |
| 61 | + } |
| 62 | + } |
| 63 | + else { |
| 64 | + throw new SMWDataItemException( 'Invalid coordinate data passed to the SMWDIGeoCoord constructor' ); |
| 65 | + } |
| 66 | + } |
| 67 | + elseif ( $count === 2 || $count === 3 ) { |
| 68 | + $this->latitude = (float)$args[0]; |
| 69 | + $this->longitude = (float)$args[1]; |
| 70 | + |
| 71 | + if ( $count === 3 ) { |
| 72 | + $this->altitude = (float)$args[2]; |
| 73 | + } |
| 74 | + } |
| 75 | + else { |
| 76 | + throw new SMWDataItemException( 'Invalid coordinate data passed to the SMWDIGeoCoord constructor' ); |
| 77 | + } |
27 | 78 | } |
28 | 79 | |
29 | 80 | /** |
— | — | @@ -34,7 +85,7 @@ |
35 | 86 | } |
36 | 87 | |
37 | 88 | /** |
38 | | - * Returns the coordinate set as an array with lat and long keys |
| 89 | + * Returns the coordinate set as an array with lat and long (and alt) keys |
39 | 90 | * pointing to float values. |
40 | 91 | * |
41 | 92 | * @since 1.6 |
— | — | @@ -42,7 +93,13 @@ |
43 | 94 | * @return array |
44 | 95 | */ |
45 | 96 | public function getCoordinateSet() { |
46 | | - return $this->coordinateSet; |
| 97 | + $coords = array( 'lat' => $this->latitude, 'lon' => $this->longitude ); |
| 98 | + |
| 99 | + if ( !is_null( $this->altitude ) ) { |
| 100 | + $coords['alt'] = $this->altitude; |
| 101 | + } |
| 102 | + |
| 103 | + return $coords; |
47 | 104 | } |
48 | 105 | |
49 | 106 | /** |
— | — | @@ -50,7 +107,8 @@ |
51 | 108 | * @see SMWDataItem::getSortKey() |
52 | 109 | */ |
53 | 110 | public function getSortKey() { |
54 | | - return $this->coordinateSet['lat']; // TODO |
| 111 | + // Maybe also add longitude here? Or is there a more meaningfull value we can return? |
| 112 | + return $this->latitude; |
55 | 113 | } |
56 | 114 | |
57 | 115 | /** |
— | — | @@ -58,7 +116,7 @@ |
59 | 117 | * @see SMWDataItem::getSerialization() |
60 | 118 | */ |
61 | 119 | public function getSerialization() { |
62 | | - return $this->coordinateSet['lat'] . ',' . $this->coordinateSet['lon']; |
| 120 | + return implode( ',', $this->getCoordinateSet() ); |
63 | 121 | } |
64 | 122 | |
65 | 123 | /** |
— | — | @@ -75,12 +133,19 @@ |
76 | 134 | */ |
77 | 135 | public static function doUnserialize( $serialization ) { |
78 | 136 | $parts = explode( ',', $serialization ); |
79 | | - |
80 | | - if ( count( $parts ) != 2 ) { |
| 137 | + $count = count( $parts ); |
| 138 | + |
| 139 | + if ( $count !== 2 && $count !== 3 ) { |
81 | 140 | throw new SMWDataItemException( 'Unserialization of coordinates failed' ); |
82 | 141 | } |
| 142 | + |
| 143 | + $coords = array( 'lat' => (float)$parts[0], 'lon' => (float)$parts[1] ); |
| 144 | + |
| 145 | + if ( $count === 3 ) { |
| 146 | + $coords['alt'] = (float)$parts[2]; |
| 147 | + } |
83 | 148 | |
84 | | - return new self( array( 'lat' => (float)$parts[0], 'lon' => (float)$parts[1], ) ); |
| 149 | + return new self( $coords ); |
85 | 150 | } |
86 | 151 | |
87 | 152 | /** |
— | — | @@ -91,7 +156,7 @@ |
92 | 157 | * @return float |
93 | 158 | */ |
94 | 159 | public function getLatitude() { |
95 | | - return $this->coordinateSet['lat']; |
| 160 | + return $this->latitude; |
96 | 161 | } |
97 | 162 | |
98 | 163 | /** |
— | — | @@ -102,7 +167,18 @@ |
103 | 168 | * @return float |
104 | 169 | */ |
105 | 170 | public function getLongitude() { |
106 | | - return $this->coordinateSet['lon']; |
| 171 | + return $this->longitude; |
107 | 172 | } |
| 173 | + |
| 174 | + /** |
| 175 | + * Returns the altitude if set, null otherwise. |
| 176 | + * |
| 177 | + * @since 1.7 |
| 178 | + * |
| 179 | + * @return float|null |
| 180 | + */ |
| 181 | + public function getAltitude() { |
| 182 | + return $this->altitude; |
| 183 | + } |
108 | 184 | |
109 | 185 | } |