Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValueDescription.php |
— | — | @@ -48,13 +48,13 @@ |
49 | 49 | * |
50 | 50 | * @param string $whereSQL The SQL where condition to expand. |
51 | 51 | * @param SMWDescription $description |
52 | | - * @param string $tablename |
53 | | - * @param string $fieldname |
| 52 | + * @param string $tableName |
| 53 | + * @param array $fieldNames |
54 | 54 | * @param DatabaseBase $dbs |
55 | 55 | * |
56 | 56 | * @return true |
57 | 57 | */ |
58 | | - public static function getSQLCondition( &$whereSQL, SMWDescription $description, $tablename, $fieldname, DatabaseBase $dbs ) { |
| 58 | + public static function getSQLCondition( &$whereSQL, SMWDescription $description, $tableName, array $fieldNames, DatabaseBase $dbs ) { |
59 | 59 | $dataValue = $description->getDatavalue(); |
60 | 60 | |
61 | 61 | // Only execute the query when the description's type is geographical coordinates, |
— | — | @@ -69,11 +69,13 @@ |
70 | 70 | |
71 | 71 | $comparator = $description->getComparator() == SMW_CMP_EQ ? '=' : '!='; |
72 | 72 | |
73 | | - // TODO: The field names are hardcoded in, since SMW offers no support for selection based on multiple fields. |
74 | | - // Ideally SMW's setup should be changed to allow for this. Now the query can break when other extensions |
75 | | - // add their own semantic tables with similar signatures. |
76 | | - $whereSQL .= "{$tablename}.lat {$comparator} {$coordinates['lat']} && {$tablename}.lon {$comparator} {$coordinates['lon']}"; |
| 73 | + // 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. |
| 74 | + $conditions = array(); |
| 75 | + $conditions[] = "{$tableName}.{$fieldNames[0]} {$comparator} {$coordinates['lat']}"; |
| 76 | + $conditions[] = "{$tableName}.{$fieldNames[1]} {$comparator} {$coordinates['lon']}"; |
77 | 77 | |
| 78 | + $whereSQL .= implode( ' && ', $conditions ); |
| 79 | + |
78 | 80 | return true; |
79 | 81 | } |
80 | 82 | |
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_AreaValueDescription.php |
— | — | @@ -116,13 +116,13 @@ |
117 | 117 | * |
118 | 118 | * @param string $whereSQL The SQL where condition to expand. |
119 | 119 | * @param SMWDescription $description |
120 | | - * @param string $tablename |
121 | | - * @param string $fieldname |
| 120 | + * @param string $tableName |
| 121 | + * @param array $fieldNames |
122 | 122 | * @param DatabaseBase $dbs |
123 | 123 | * |
124 | 124 | * @return true |
125 | 125 | */ |
126 | | - public static function getSQLCondition( &$whereSQL, SMWDescription $description, $tablename, $fieldname, DatabaseBase $dbs ) { |
| 126 | + public static function getSQLCondition( &$whereSQL, SMWDescription $description, $tableName, array $fieldNames, DatabaseBase $dbs ) { |
127 | 127 | $dataValue = $description->getDatavalue(); |
128 | 128 | |
129 | 129 | // Only execute the query when the description's type is geographical coordinates, |
— | — | @@ -139,11 +139,15 @@ |
140 | 140 | $south = $dbs->addQuotes( $boundingBox['south'] ); |
141 | 141 | $west = $dbs->addQuotes( $boundingBox['west'] ); |
142 | 142 | |
143 | | - // TODO: The field names are hardcoded in, since SMW offers no support for selection based on multiple fields. |
144 | | - // Ideally SMW's setup should be changed to allow for this. Now the query can break when other extensions |
145 | | - // add their own semantic tables with similar signatures. |
146 | | - $whereSQL .= "{$tablename}.lat < $north && {$tablename}.lat > $south && {$tablename}.lon < $east && {$tablename}.lon > $west"; |
147 | | -var_dump($whereSQL);exit; |
| 143 | + // 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. |
| 144 | + $conditions = array(); |
| 145 | + $conditions[] = "{$tableName}.{$fieldNames[0]} < $north"; |
| 146 | + $conditions[] = "{$tableName}.{$fieldNames[0]} > $south"; |
| 147 | + $conditions[] = "{$tableName}.{$fieldNames[1]} < $east"; |
| 148 | + $conditions[] = "{$tableName}.{$fieldNames[1]} > $west"; |
| 149 | + |
| 150 | + $whereSQL .= implode( ' && ', $conditions ); |
| 151 | + |
148 | 152 | return true; |
149 | 153 | } |
150 | 154 | } |
\ No newline at end of file |