r65984 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65983‎ | r65984 | r65985 >
Date:13:09, 6 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.6 - partly implemented distance query
Modified paths:
  • /trunk/extensions/SemanticMaps/GeoCoords/SM_DistanceValue.php (added) (history)
  • /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
@@ -73,11 +73,17 @@
7474 * Parses the value into the coordinates and any meta data provided, such as distance.
7575 */
7676 protected function parseUserValueOrQuery( $value, $asQuery = false ) {
 77+ $comparator = SMW_CMP_EQ;
 78+
7779 if ( $value == '' ) {
7880 $this->addError( wfMsg( 'smw_novalues' ) );
7981 } else {
8082 // TODO: parse the parts here
 83+ SMWDataValue::prepareValue( $value, $comparator );
 84+
8185 //$parts = preg_split( '', $value );
 86+ // preg_match( '/(.*)\((.*)\)/', $user_input, $matches );
 87+
8288 $distance = 5;
8389 $hasDistance = false;
8490
@@ -105,7 +111,7 @@
106112 return new SMAreaValueDescription( $this, $distance );
107113 break;
108114 default :
109 - return new SMGeoCoordsValueDescription( $this );
 115+ return new SMGeoCoordsValueDescription( $this, $comparator );
110116 break;
111117 }
112118 }
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoords.php
@@ -34,4 +34,4 @@
3535 // Hook for initializing the Geographical Proximity query support.
3636 $wgHooks['smwGetSQLConditionForValue'][] = 'SMGeoCoordsValueDescription::getSQLCondition';
3737
38 -// define( 'SM_CMP_NEAR', 101 ); // Define the near comparator for proximity queries.
\ No newline at end of file
 38+define( 'SM_CMP_NEAR', 101 ); // Define the near comparator for proximity queries.
\ No newline at end of file
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValueDescription.php
@@ -27,8 +27,8 @@
2828 *
2929 * @param SMGeoCoordsValue $dataValue
3030 */
31 - public function __construct( SMGeoCoordsValue $dataValue ) {
32 - parent::__construct( $dataValue );
 31+ public function __construct( SMGeoCoordsValue $dataValue, $comparator ) {
 32+ parent::__construct( $dataValue, $comparator );
3333 }
3434
3535 /**
@@ -64,14 +64,18 @@
6565 if ( $dataValue->getTypeID() != '_geo'
6666 || !$dataValue->isValid()
6767 || !$description instanceof SMGeoCoordsValueDescription
 68+ //|| ( $description->getComparator() != SMW_CMP_EQ && $description->getComparator() != SMW_CMP_NEQ )
6869 ) return true;
6970
7071 $coordinates = $dataValue->getCoordinateSet();
71 -
 72+
 73+ $comparator = $description->getComparator() == SMW_CMP_EQ ? '=' : '!=';
 74+ //var_dump($comparator);exit;
 75+
7276 // TODO: The field names are hardcoded in, since SMW offers no support for selection based on multiple fields.
7377 // Ideally SMW's setup should be changed to allow for this. Now the query can break when other extensions
7478 // add their own semantic tables with similar signatures.
75 - $whereSQL .= "{$tablename}.lat = {$coordinates['lat']} && {$tablename}.lon = {$coordinates['lon']}";
 79+ $whereSQL .= "{$tablename}.lat {$comparator} {$coordinates['lat']} && {$tablename}.lon {$comparator} {$coordinates['lon']}";
7680
7781 return true;
7882 }
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_DistanceValue.php
@@ -0,0 +1 @@
 2+<?php
Property changes on: trunk/extensions/SemanticMaps/GeoCoords/SM_DistanceValue.php
___________________________________________________________________
Name: svn:eol-style
13 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r65988FOllow up to r65984jeroendedauw17:12, 6 May 2010

Status & tagging log