Last modified: 2013-03-03 23:20:51 UTC
Quoting from http://semantic-mediawiki.org/w/index.php?title=Thread:Semantic-mediawiki.org:Community_portal/Query_on_specific_value_of_Geographical_coordinate_type_property_returns_nothing&lqt_method=thread_history When I add the query {{#ask: [[Has coordinates::62° 38' 12" N, 11° 0' 24" Ø]] | ?Has coordinates | ?Name }} in a page, the debugging feature shows that the database call is: SELECT /* SMW::getQueryResult 194.19.124.36 */ DISTINCT t2.smw_id AS id,t2.smw_title AS t,t2.smw_namespace AS ns,t2.smw_iw AS iw,t2.smw_subobject AS so,t2.smw_sortkey AS sortkey FROM `wsmw_object_ids` AS t2 INNER JOIN `wsmw_di_coords` AS t0 ON t2.smw_id=t0.s_id WHERE ((t0.o_serialized = '62.636666666667' && t0.o_lat = '11.006666666667') AND t0.p_id='65') ORDER BY t2.smw_sortkey ASC LIMIT 51. As you can see, there are seemingly two things that are off here. First of all, it seems to look up the latitude in the field "o_serialized" and the longitude in the "o_lat" field.
Solution found. The following line numbers are from Semantic Maps version 2.0.1.2: In includes/SM_GeoCoordsValueDescription.php, change lines 63 and 64 from: $conditions[] = "{$tableName}.$fieldNames[0] $comparator $lat"; $conditions[] = "{$tableName}.$fieldNames[1] $comparator $lon"; to: $conditions[] = "{$tableName}.$fieldNames[1] $comparator $lat"; $conditions[] = "{$tableName}.$fieldNames[2] $comparator $lon"; This fixes the issue when querying for a match on a specific set of coordinates, like in the example in the opening post. It doesn't, however, fix the issue when doing a "within distance/proximity" query. To fix this, change lines 143 to 146 in includes/SM_AreaValueDescription.php from: $conditions[] = "{$tableName}.$fieldNames[0] $smallerThen $north"; $conditions[] = "{$tableName}.$fieldNames[0] $biggerThen $south"; $conditions[] = "{$tableName}.$fieldNames[1] $smallerThen $east"; $conditions[] = "{$tableName}.$fieldNames[1] $biggerThen $west"; to: $conditions[] = "{$tableName}.$fieldNames[1] $smallerThen $north"; $conditions[] = "{$tableName}.$fieldNames[1] $biggerThen $south"; $conditions[] = "{$tableName}.$fieldNames[2] $smallerThen $east"; $conditions[] = "{$tableName}.$fieldNames[2] $biggerThen $west";
For **** sake... That is some very bad abstraction going on in this code :) Looks like you are right - thanks for finding the issue and suggesting a fix!
https://gerrit.wikimedia.org/r/#/c/51844/
Oh damn, I just realized I did not give you credits in the commit message. Sorry for that!
No worries, man. :) I just needed the feature and thought I'd share what I found. No credits needed. ;)
Guess this also works https://gerrit.wikimedia.org/r/#/c/51845/1/RELEASE-NOTES
Thanks. :) Could this be a duplicate of bug 42388, by the way?
Probably