r66397 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66396‎ | r66397 | r66398 >
Date:21:12, 13 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.6 - small fixed for distance query
Modified paths:
  • /trunk/extensions/SemanticMaps/GeoCoords/SM_AreaValueDescription.php (modified) (history)
  • /trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php
@@ -88,7 +88,7 @@
8989 $distance = count( $parts ) > 0 ? trim( array_shift( $parts ) ) : false;
9090
9191 if ( $distance !== false ) {
92 - if ( preg_match( '/^\d+(\.\d+)?(\s.+)?\)$/', $distance ) ) {
 92+ if ( preg_match( '/^!?\d+(\.\d+)?(\s.+)?\)$/', $distance ) ) {
9393 $distance = substr( $distance, 0, -1 );
9494 }
9595 else {
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_AreaValueDescription.php
@@ -28,7 +28,7 @@
2929 protected $mBounds = false;
3030
3131 public function __construct( SMGeoCoordsValue $dataValue, $comparator, $radius ) {
32 - parent::__construct( $dataValue );
 32+ parent::__construct( $dataValue, $comparator );
3333
3434 // Parse the radius to the actual value and the optional unit.
3535 $radius = preg_replace('/\s\s+/', ' ', $radius);
@@ -156,7 +156,7 @@
157157 ) {
158158 return false;
159159 }
160 -
 160+
161161 $boundingBox = $this->getBounds();
162162
163163 $north = $dbs->addQuotes( $boundingBox['north'] );
@@ -166,8 +166,9 @@
167167
168168 $isEq = $this->getComparator() == SMW_CMP_EQ;
169169
170 - $smallerThen = $isEq ? '<' : '>';
171 - $biggerThen = $isEq ? '>' : '<';
 170+ $smallerThen = $isEq ? '<' : '>=';
 171+ $biggerThen = $isEq ? '>' : '<=';
 172+ $joinCond = $isEq ? '&&' : '||';
172173
173174 // TODO: Would be safer to have a solid way of determining what's the lat and lon field, instead of assuming it's in this order.
174175 $conditions = array();
@@ -176,6 +177,6 @@
177178 $conditions[] = "{$tableName}.lon $smallerThen $east";
178179 $conditions[] = "{$tableName}.lon $biggerThen $west";
179180
180 - return implode( ' && ', $conditions );
 181+ return implode( " $joinCond ", $conditions );
181182 }
182183 }
\ No newline at end of file

Status & tagging log