Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php |
— | — | @@ -6,8 +6,8 @@ |
7 | 7 | * @ingroup SMWDataValues |
8 | 8 | * @ingroup SemanticMaps |
9 | 9 | * |
| 10 | + * @author Jeroen De Dauw |
10 | 11 | * @author Markus Krötzsch |
11 | | - * @author Jeroen De Dauw |
12 | 12 | */ |
13 | 13 | |
14 | 14 | if ( !defined( 'MEDIAWIKI' ) ) { |
— | — | @@ -17,8 +17,8 @@ |
18 | 18 | /** |
19 | 19 | * Implementation of datavalues that are geographic coordinates. |
20 | 20 | * |
| 21 | + * @author Jeroen De Dauw |
21 | 22 | * @author Markus Krötzsch |
22 | | - * @author Jeroen De Dauw |
23 | 23 | * |
24 | 24 | * @ingroup SemanticMaps |
25 | 25 | */ |
— | — | @@ -37,7 +37,14 @@ |
38 | 38 | return true; |
39 | 39 | } |
40 | 40 | |
41 | | - public static function initGeoCoordsTable( $propertyTables ) { |
| 41 | + /** |
| 42 | + * Defines the layout for the smw_coords table which is used to store value of the GeoCoords type. |
| 43 | + * |
| 44 | + * @param array $propertyTables The property tables defined by SMW, passed by reference. |
| 45 | + * |
| 46 | + * FIXME |
| 47 | + */ |
| 48 | + public static function initGeoCoordsTable( array $propertyTables ) { |
42 | 49 | /* |
43 | 50 | $propertyTables['smw_coords'] = new SMWSQLStore2Table( |
44 | 51 | 'sm_coords', |
— | — | @@ -61,7 +68,7 @@ |
62 | 69 | if ( $this->m_caption === false ) { |
63 | 70 | // TODO: parse coodinates to some notation, depending on a new setting |
64 | 71 | $this->m_caption = $value; |
65 | | - } |
| 72 | + } |
66 | 73 | } else { |
67 | 74 | $this->addError( wfMsgExt( 'maps_unrecognized_coords', array( 'parsemag' ), $value, 1 ) ); |
68 | 75 | } |
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoords.php |
— | — | @@ -35,12 +35,15 @@ |
36 | 36 | /** |
37 | 37 | * Custom SQL query extension for matching geographic coordinates. |
38 | 38 | * |
39 | | - * TODO: Change the way coords are stored in the db from a string field to 2 float fields. |
40 | | - * The geographic coordinate value object should provide functions to access the lat and lon data directly. |
| 39 | + * @param string $whereSQL The SQL where condition to expand. |
| 40 | + * @param SMGeoCoordsValueDescription $description The description of center coordinate. |
| 41 | + * @param string $tablename |
| 42 | + * @param string $fieldname |
| 43 | + * @param Database $dbs |
41 | 44 | * |
42 | | - * TODO: Add support for a per-coordinate set distance parameter. |
| 45 | + * @return true |
43 | 46 | */ |
44 | | - public static function getGeoProximitySQLCondition( &$whereSQL, SMGeoCoordsValueDescription $description, $tablename, $fieldname, $dbs ) { |
| 47 | + public static function getGeoProximitySQLCondition( &$whereSQL, SMGeoCoordsValueDescription $description, $tablename, $fieldname, Database $dbs ) { |
45 | 48 | // If the MapsGeoFunctions class is not loaded, we can not create the bounding box, so don't add any conditions. |
46 | 49 | if ( !self::geoFunctionsAreAvailable() ) { |
47 | 50 | return true; |
— | — | @@ -57,8 +60,10 @@ |
58 | 61 | |
59 | 62 | $dbKeys = $dataValue->getDBkeys(); |
60 | 63 | |
| 64 | + // TODO: get user provided distance |
| 65 | + // $dataValue->getDistance() |
61 | 66 | global $smgGeoCoordDistance; |
62 | | - $distance = $smgGeoCoordDistance; // TODO: get user provided distance |
| 67 | + $distance = $smgGeoCoordDistance; |
63 | 68 | |
64 | 69 | $boundingBox = self::getBoundingBox( |
65 | 70 | array( |
— | — | @@ -78,7 +83,15 @@ |
79 | 84 | return true; |
80 | 85 | } |
81 | 86 | |
82 | | - private static function getBoundingBox( $centerCoordinates, $circleRadius ) { |
| 87 | + /** |
| 88 | + * Returns the lat and lon limits of a bounding box around a circle defined by the provided parameters. |
| 89 | + * |
| 90 | + * @param array $centerCoordinates Array containing non-directional float coordinates with lat and lon keys. |
| 91 | + * @param float $circleRadius The radidus of the circle to create a bounding box for, in km. |
| 92 | + * |
| 93 | + * @return An associative array containing the limits with keys north, east, south and west. |
| 94 | + */ |
| 95 | + private static function getBoundingBox( array $centerCoordinates, $circleRadius ) { |
83 | 96 | $north = MapsGeoFunctions::findDestination( $centerCoordinates, 0, $circleRadius ); |
84 | 97 | $east = MapsGeoFunctions::findDestination( $centerCoordinates, 90, $circleRadius ); |
85 | 98 | $south = MapsGeoFunctions::findDestination( $centerCoordinates, 180, $circleRadius ); |
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValueDescription.php |
— | — | @@ -56,4 +56,8 @@ |
57 | 57 | return $this; |
58 | 58 | } |
59 | 59 | } |
| 60 | + |
| 61 | + public function getDistance() { |
| 62 | + return $this->m_distance; |
| 63 | + } |
60 | 64 | } |
\ No newline at end of file |