r64945 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64944‎ | r64945 | r64946 >
Date:20:19, 11 April 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added docs
Modified paths:
  • /trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoords.php (modified) (history)
  • /trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php (modified) (history)
  • /trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValueDescription.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php
@@ -6,8 +6,8 @@
77 * @ingroup SMWDataValues
88 * @ingroup SemanticMaps
99 *
 10+ * @author Jeroen De Dauw
1011 * @author Markus Krötzsch
11 - * @author Jeroen De Dauw
1212 */
1313
1414 if ( !defined( 'MEDIAWIKI' ) ) {
@@ -17,8 +17,8 @@
1818 /**
1919 * Implementation of datavalues that are geographic coordinates.
2020 *
 21+ * @author Jeroen De Dauw
2122 * @author Markus Krötzsch
22 - * @author Jeroen De Dauw
2323 *
2424 * @ingroup SemanticMaps
2525 */
@@ -37,7 +37,14 @@
3838 return true;
3939 }
4040
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 ) {
4249 /*
4350 $propertyTables['smw_coords'] = new SMWSQLStore2Table(
4451 'sm_coords',
@@ -61,7 +68,7 @@
6269 if ( $this->m_caption === false ) {
6370 // TODO: parse coodinates to some notation, depending on a new setting
6471 $this->m_caption = $value;
65 - }
 72+ }
6673 } else {
6774 $this->addError( wfMsgExt( 'maps_unrecognized_coords', array( 'parsemag' ), $value, 1 ) );
6875 }
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoords.php
@@ -35,12 +35,15 @@
3636 /**
3737 * Custom SQL query extension for matching geographic coordinates.
3838 *
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
4144 *
42 - * TODO: Add support for a per-coordinate set distance parameter.
 45+ * @return true
4346 */
44 - public static function getGeoProximitySQLCondition( &$whereSQL, SMGeoCoordsValueDescription $description, $tablename, $fieldname, $dbs ) {
 47+ public static function getGeoProximitySQLCondition( &$whereSQL, SMGeoCoordsValueDescription $description, $tablename, $fieldname, Database $dbs ) {
4548 // If the MapsGeoFunctions class is not loaded, we can not create the bounding box, so don't add any conditions.
4649 if ( !self::geoFunctionsAreAvailable() ) {
4750 return true;
@@ -57,8 +60,10 @@
5861
5962 $dbKeys = $dataValue->getDBkeys();
6063
 64+ // TODO: get user provided distance
 65+ // $dataValue->getDistance()
6166 global $smgGeoCoordDistance;
62 - $distance = $smgGeoCoordDistance; // TODO: get user provided distance
 67+ $distance = $smgGeoCoordDistance;
6368
6469 $boundingBox = self::getBoundingBox(
6570 array(
@@ -78,7 +83,15 @@
7984 return true;
8085 }
8186
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 ) {
8396 $north = MapsGeoFunctions::findDestination( $centerCoordinates, 0, $circleRadius );
8497 $east = MapsGeoFunctions::findDestination( $centerCoordinates, 90, $circleRadius );
8598 $south = MapsGeoFunctions::findDestination( $centerCoordinates, 180, $circleRadius );
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValueDescription.php
@@ -56,4 +56,8 @@
5757 return $this;
5858 }
5959 }
 60+
 61+ public function getDistance() {
 62+ return $this->m_distance;
 63+ }
6064 }
\ No newline at end of file

Status & tagging log