Last modified: 2013-03-03 23:20:51 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T46933, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 44933 - Geo coords stored incorrectly
Geo coords stored incorrectly
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
master
All All
: Unprioritized normal with 1 vote (vote)
: ---
Assigned To: Jeroen De Dauw
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-02-13 07:17 UTC by Jeroen De Dauw
Modified: 2013-03-03 23:20 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jeroen De Dauw 2013-02-13 07:17:43 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.
Comment 1 kvolden 2013-03-02 12:10:31 UTC
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";
Comment 2 Jeroen De Dauw 2013-03-02 17:49:09 UTC
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!
Comment 3 Jeroen De Dauw 2013-03-02 17:52:57 UTC
https://gerrit.wikimedia.org/r/#/c/51844/
Comment 4 Jeroen De Dauw 2013-03-02 17:53:38 UTC
Oh damn, I just realized I did not give you credits in the commit message. Sorry for that!
Comment 5 kvolden 2013-03-02 17:54:58 UTC
No worries, man. :) I just needed the feature and thought I'd share what I found. No credits needed. ;)
Comment 6 Jeroen De Dauw 2013-03-02 17:57:37 UTC
Guess this also works https://gerrit.wikimedia.org/r/#/c/51845/1/RELEASE-NOTES
Comment 7 kvolden 2013-03-03 12:24:31 UTC
Thanks. :) Could this be a duplicate of bug 42388, by the way?
Comment 8 Jeroen De Dauw 2013-03-03 23:20:51 UTC
Probably

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links