jenkins-bot has submitted this change and it was merged.

Change subject: Evaluate globe in coordinates
......................................................................


Evaluate globe in coordinates

When a point comes with a globe. Globe needs to be earth.
Also optimize click handler for result browser.

Bug: T130428
Change-Id: Ic927a138bff130c9044cf02e897f81c1f032a2d6
---
M wikibase/queryService/ui/App.js
M wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
2 files changed, 30 insertions(+), 8 deletions(-)

Approvals:
  Smalyshev: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/wikibase/queryService/ui/App.js b/wikibase/queryService/ui/App.js
index 18d2bfc..8313678 100644
--- a/wikibase/queryService/ui/App.js
+++ b/wikibase/queryService/ui/App.js
@@ -462,6 +462,8 @@
                var self = this;
 
                $.each( this._resultBrowsers, function( key, b ){
+                       b.$element.off( 'click' );
+
                        if( b.object.isDrawable() ){
                                b.$element.css( 'opacity', 1 ).attr( 'href', 
'#' );
                                b.$element.click( function(){
@@ -476,7 +478,6 @@
                                        return false;
                                } );
                        } else {
-                               b.$element.off( 'click' );
                                b.$element.css( 'opacity', 0.5 ).removeAttr( 
'href' );
                        }
                } );
diff --git a/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js 
b/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
index 9df5271..f7acf97 100644
--- a/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
+++ b/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
@@ -7,6 +7,7 @@
        "use strict";
 
        var MAP_DATATYPE = 'http://www.opengis.net/ont/geosparql#wktLiteral';
+       var GLOBE_EARTH = 'Q2';
 
     var TILE_LAYER = {
        wikimedia: {
@@ -88,9 +89,7 @@
                        if( field.datatype === MAP_DATATYPE ){
                                var longLat = self._extractLongLat( field.value 
);
 
-                                       // FIXME: if the coordinates are for 
another globe (e.g. Mars),
-                                       // then the array order is different 
and longLat[0] is NaN.
-                                       if( !longLat[0] || !longLat[1] || 
isNaN( longLat[0] ) ){
+                                       if( longLat === null || !longLat[0] || 
!longLat[1]  ){
                                        return true;
                                }
 
@@ -119,11 +118,30 @@
         * @private
         */
        SELF.prototype._extractLongLat = function( point ) {
-               point = point.replace('Point(', '' );
-               point = point.replace( ')', '' );
+
+               var globe = this._extractGlobe( point );
+               if ( globe !== null && globe !== GLOBE_EARTH ){
+                       return null;
+               }
+
+               point = point.match(/Point\((.*)\)/).pop();
 
                return point.split( ' ' );
        };
+
+       /**
+        * @private
+        */
+       SELF.prototype._extractGlobe = function( point ) {
+               var globe = null;
+
+               if ( ( globe = 
point.match(/<http\:\/\/www\.wikidata\.org\/entity\/(.+)>/i) ) ){
+                       globe = globe.pop();
+               }
+
+               return globe;
+       };
+
 
        /**
         * @private
@@ -185,8 +203,11 @@
         */
        SELF.prototype._checkCoordinate = function ( value ) {
                if( value && value.datatype === MAP_DATATYPE ) {
-                       this._drawable = true;
-                       return false;
+                       var globe = this._extractGlobe( value.value );
+                       if ( globe === null || globe === GLOBE_EARTH ){
+                               this._drawable = true;
+                               return false;
+                       }
                }
                return true;
        };

-- 
To view, visit https://gerrit.wikimedia.org/r/278720
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic927a138bff130c9044cf02e897f81c1f032a2d6
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Jonas Kress (WMDE) <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to