r86914 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86913‎ | r86914 | r86915 >
Date:22:32, 25 April 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r86913
Modified paths:
  • /trunk/extensions/SemanticMaps/SemanticMaps.php (modified) (history)
  • /trunk/extensions/SemanticMaps/includes/SM_AreaValueDescription.php (modified) (history)
  • /trunk/extensions/SemanticMaps/includes/SM_GeoCoordsHooks.php (modified) (history)
  • /trunk/extensions/SemanticMaps/includes/SM_GeoCoordsValueDescription.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/includes/SM_GeoCoordsValueDescription.php
@@ -50,8 +50,6 @@
5151 * @return true
5252 */
5353 public function getSQLCondition( $tableName, array $fieldNames, $dbs ) {
54 - global $smgUseSpatialExtensions;
55 -
5654 $dataValue = $this->getDatavalue();
5755
5856 // Only execute the query when the description's type is geographical coordinates,
@@ -74,15 +72,10 @@
7573 $lon = $dbs->addQuotes( $coordinates['lon'] );
7674
7775 $conditions = array();
 76+
 77+ $conditions[] = "{$tableName}.$fieldNames[0] $comparator $lat";
 78+ $conditions[] = "{$tableName}.$fieldNames[1] $comparator $lon";
7879
79 - if ( $smgUseSpatialExtensions ) {
80 - // TODO
81 - }
82 - else {
83 - $conditions[] = "{$tableName}.$fieldNames[0] $comparator $lat";
84 - $conditions[] = "{$tableName}.$fieldNames[1] $comparator $lon";
85 - }
86 -
8780 return implode( ' && ', $conditions );
8881 }
8982 else {
Index: trunk/extensions/SemanticMaps/includes/SM_GeoCoordsHooks.php
@@ -78,26 +78,6 @@
7979 }
8080
8181 /**
82 - * Defines the signature for geographical fields needed for the smw_coords table.
83 - *
84 - * @since 0.8
85 - *
86 - * @param array $fieldTypes The field types defined by SMW, passed by reference.
87 - *
88 - * @return true
89 - */
90 - public static function initGeoCoordsFieldTypes( array $fieldTypes ) {
91 - global $smgUseSpatialExtensions;
92 -
93 - // Only add the table when the SQL store is not a postgres database, and it has not been added by SMW itself.
94 - if ( $smgUseSpatialExtensions && !array_key_exists( 'c', $fieldTypes ) ) {
95 - $fieldTypes['c'] = 'Point NOT NULL';
96 - }
97 -
98 - return true;
99 - }
100 -
101 - /**
10282 * Defines the layout for the smw_coords table which is used to store value of the GeoCoords type.
10383 *
10484 * @since 0.8
@@ -105,11 +85,9 @@
10686 * @param array $propertyTables The property tables defined by SMW, passed by reference.
10787 */
10888 public static function initGeoCoordsTable( array $propertyTables ) {
109 - global $smgUseSpatialExtensions;
110 -
11189 // No spatial extensions support for postgres yet, so just store as 2 float fields.
112 - $signature = $smgUseSpatialExtensions ? array( 'point' => 'c' ) : array( 'lat' => 'f', 'lon' => 'f' );
113 - $indexes = $smgUseSpatialExtensions ? array( array( 'point', 'SPATIAL INDEX' ) ) : array_keys( $signature );
 90+ $signature = array( 'lat' => 'f', 'lon' => 'f' );
 91+ $indexes = array_keys( $signature );
11492
11593 $propertyTables['smw_coords'] = new SMWSQLStore2Table(
11694 'sm_coords',
Index: trunk/extensions/SemanticMaps/includes/SM_AreaValueDescription.php
@@ -117,8 +117,6 @@
118118 * @return string or false
119119 */
120120 public function getSQLCondition( $tableName, array $fieldNames, $dbs ) {
121 - global $smgUseSpatialExtensions;
122 -
123121 $dataValue = $this->getDatavalue();
124122
125123 // Only execute the query when the description's type is geographical coordinates,
@@ -137,25 +135,19 @@
138136
139137 $isEq = $this->getComparator() == SMW_CMP_EQ;
140138
141 - if ( $smgUseSpatialExtensions ) {
142 - // TODO
143 - $sql = '';
144 - }
145 - else {
146 - $conditions = array();
147 -
148 - $smallerThen = $isEq ? '<' : '>=';
149 - $biggerThen = $isEq ? '>' : '<=';
150 - $joinCond = $isEq ? '&&' : '||';
151 -
152 - $conditions[] = "{$tableName}.$fieldNames[0] $smallerThen $north";
153 - $conditions[] = "{$tableName}.$fieldNames[0] $biggerThen $south";
154 - $conditions[] = "{$tableName}.$fieldNames[1] $smallerThen $east";
155 - $conditions[] = "{$tableName}.$fieldNames[1] $biggerThen $west";
 139+ $conditions = array();
156140
157 - $sql = implode( " $joinCond ", $conditions );
158 - }
159 -
 141+ $smallerThen = $isEq ? '<' : '>=';
 142+ $biggerThen = $isEq ? '>' : '<=';
 143+ $joinCond = $isEq ? '&&' : '||';
 144+
 145+ $conditions[] = "{$tableName}.$fieldNames[0] $smallerThen $north";
 146+ $conditions[] = "{$tableName}.$fieldNames[0] $biggerThen $south";
 147+ $conditions[] = "{$tableName}.$fieldNames[1] $smallerThen $east";
 148+ $conditions[] = "{$tableName}.$fieldNames[1] $biggerThen $west";
 149+
 150+ $sql = implode( " $joinCond ", $conditions );
 151+
160152 return $sql;
161153 }
162154
Index: trunk/extensions/SemanticMaps/SemanticMaps.php
@@ -104,9 +104,6 @@
105105 // Hook for initializing the Geographical Coordinate type.
106106 $wgHooks['smwInitDatatypes'][] = 'SMGeoCoordsHooks::initGeoCoordsType';
107107
108 -// Hook for initializing the field types needed by Geographical Coordinates.
109 -$wgHooks['SMWCustomSQLStoreFieldType'][] = 'SMGeoCoordsHooks::initGeoCoordsFieldTypes';
110 -
111108 // Hook for defining a table to store geographical coordinates in.
112109 $wgHooks['SMWPropertyTables'][] = 'SMGeoCoordsHooks::initGeoCoordsTable';
113110

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86913rem obsolete settingjeroendedauw22:28, 25 April 2011

Status & tagging log