[MediaWiki-commits] [Gerrit] wikidata...gui[master]: Use wellknown to parse geo:wktLiteral values

2017-06-26 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/361230 )

Change subject: Use wellknown to parse geo:wktLiteral values
..


Use wellknown to parse geo:wktLiteral values

_extractLongLat is changed to _extractGeoJson and uses wellknown to
parse the WKT literal instead of extracting point coordinates via
regular expression. This gives us support for other kinds of values, for
instance linestrings or polygons; such values are not present on
Wikidata, but may be obtained via a federated SPARQL query against a
GeoSPARQL endpoint, e. g. LinkedGeoData.org.

_createMarkerGroups is updated to store the returned GeoJSON in a
GeoJSON layer, using the pointToLayer option to change the Leaflet
default pin to a simple point marker. The popup is bound to any kind of
feature, including non-point features.

The tests for _extractLongLat are updated to account for the rename and
the changed return type, and a test for a simple non-point geometry is
added.

Change-Id: I9c069eff00ac816fa345aa1b8ab874032730a725
---
M .jshintrc
M embed.html
M index.html
M package.json
M wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
M wikibase/tests/index.html
M wikibase/tests/queryService/ui/resultBrowser/CoordinateResultBrowser.test.js
7 files changed, 50 insertions(+), 39 deletions(-)

Approvals:
  Jonas Kress (WMDE): Looks good to me, approved
  jenkins-bot: Verified
  Thiemo Mättig (WMDE): Looks good to me, but someone else must approve



diff --git a/.jshintrc b/.jshintrc
index a0dee2e..47e5be3 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -44,6 +44,7 @@
"Cookies": false,
"vis": false,
"moment": false,
-   "dimple": false
+   "dimple": false,
+   "wellknown": false
}
 }
diff --git a/embed.html b/embed.html
index d35da5f..c890efe 100644
--- a/embed.html
+++ b/embed.html
@@ -118,6 +118,7 @@



+   



diff --git a/index.html b/index.html
index c783175..6db001c 100644
--- a/index.html
+++ b/index.html
@@ -261,6 +261,7 @@



+   



diff --git a/package.json b/package.json
index 605992a..d01be6e 100644
--- a/package.json
+++ b/package.json
@@ -36,7 +36,8 @@
 "moment": "^2.18.1",
 "select2": "^4.0.3",
 "underscore": "^1.8.3",
-"vis": "^4.19.1"
+"vis": "^4.19.1",
+"wellknown": "^0.5.0"
   },
   "devDependencies": {
 "grunt": "0.4.5",
diff --git a/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js 
b/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
index 2d645ec..c3ebaf8 100644
--- a/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
+++ b/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
@@ -3,7 +3,7 @@
 wikibase.queryService.ui = wikibase.queryService.ui || {};
 wikibase.queryService.ui.resultBrowser = 
wikibase.queryService.ui.resultBrowser || {};
 
-wikibase.queryService.ui.resultBrowser.CoordinateResultBrowser = ( function( 
$, L, d3, _, window ) {
+wikibase.queryService.ui.resultBrowser.CoordinateResultBrowser = ( function( 
$, L, d3, _, wellknown, window ) {
'use strict';
 
var MAP_DATATYPE = 'http://www.opengis.net/ont/geosparql#wktLiteral';
@@ -223,27 +223,29 @@
 
this._iterateResult( function( field, key, row ) {
if ( field && field.datatype === MAP_DATATYPE ) {
-   var longLat = self._extractLongLat( field.value 
);
-   if ( longLat === null || !longLat[0] || 
!longLat[1] ) {
-   return true;
+   var geoJson = self._extractGeoJson( field.value 
);
+   if ( !geoJson ) {
+   return;
}
 
-   var popup = L.popup(),
-   lon = longLat[0],
-   lat = longLat[1];
-
var layer = self._getMarkerGroupsLayer( row );
-   var marker = L.circleMarker( [ lat, lon ], 
self._getMarkerStyle( layer ) )
-   .bindPopup( popup );
-
-   marker.on( 'click', function() {
-   var info = self._getItemDescription( 
row );
-   popup.setContent( info[0] );
-   } );
-
if ( !markers[ layer ] ) {
markers[ layer ] = [];
}
+   var marker = L.geoJson( geoJson, {
+   style: self._getMarkerStyle( layer ),
+ 

[MediaWiki-commits] [Gerrit] wikidata...gui[master]: Use wellknown to parse geo:wktLiteral values

2017-06-24 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/361230 )

Change subject: Use wellknown to parse geo:wktLiteral values
..

Use wellknown to parse geo:wktLiteral values

This gives us support for other kinds of values than points, for
instance linestrings; such values are not present on Wikidata, but may
be obtained via a federated SPARQL query against a GeoSPARQL endpoint.

Change-Id: I9c069eff00ac816fa345aa1b8ab874032730a725
---
M embed.html
M index.html
M package.json
M wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
4 files changed, 48 insertions(+), 73 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/30/361230/1

diff --git a/embed.html b/embed.html
index d35da5f..c890efe 100644
--- a/embed.html
+++ b/embed.html
@@ -118,6 +118,7 @@



+   



diff --git a/index.html b/index.html
index c783175..6db001c 100644
--- a/index.html
+++ b/index.html
@@ -261,6 +261,7 @@



+   



diff --git a/package.json b/package.json
index 605992a..d01be6e 100644
--- a/package.json
+++ b/package.json
@@ -36,7 +36,8 @@
 "moment": "^2.18.1",
 "select2": "^4.0.3",
 "underscore": "^1.8.3",
-"vis": "^4.19.1"
+"vis": "^4.19.1",
+"wellknown": "^0.5.0"
   },
   "devDependencies": {
 "grunt": "0.4.5",
diff --git a/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js 
b/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
index e753556..0fe9b91 100644
--- a/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
+++ b/wikibase/queryService/ui/resultBrowser/CoordinateResultBrowser.js
@@ -3,7 +3,7 @@
 wikibase.queryService.ui = wikibase.queryService.ui || {};
 wikibase.queryService.ui.resultBrowser = 
wikibase.queryService.ui.resultBrowser || {};
 
-wikibase.queryService.ui.resultBrowser.CoordinateResultBrowser = ( function( 
$, L, d3, _, window ) {
+wikibase.queryService.ui.resultBrowser.CoordinateResultBrowser = ( function( 
$, L, d3, _, wellknown, window ) {
'use strict';
 
var MAP_DATATYPE = 'http://www.opengis.net/ont/geosparql#wktLiteral';
@@ -108,7 +108,6 @@
 
this._setTileLayer();
this._createControls();
-   this._createMarkerZoomResize();
 
$element.html( container );
};
@@ -153,37 +152,6 @@
/**
 * @private
 */
-   SELF.prototype._createMarkerZoomResize = function() {
-   var self = this;
-
-   if ( this._markerGroups[LAYER_DEFAULT_GROUP].getLayers().length 
> 1000 ) {
-   return; // disable when to many markers (bad 
performance)
-   }
-
-   var resize = function() {
-   self._markerGroups[LAYER_DEFAULT_GROUP].setStyle( {
-   radius: self._getMarkerRadius()
-   } );
-   };
-
-   this._map.on( 'zoomend', resize );
-   };
-
-   /**
-* @private
-*/
-   SELF.prototype._getMarkerRadius = function() {
-   if ( !this._map ) {
-   return 3;
-   }
-
-   var currentZoom = this._map.getZoom();
-   return ( currentZoom * ( 1 / 2 ) );
-   };
-
-   /**
-* @private
-*/
SELF.prototype._getLayerControl = function() {
var self = this,
layerControls = {},
@@ -213,27 +181,29 @@
 
this._iterateResult( function( field, key, row ) {
if ( field && field.datatype === MAP_DATATYPE ) {
-   var longLat = self._extractLongLat( field.value 
);
-   if ( longLat === null || !longLat[0] || 
!longLat[1] ) {
-   return true;
+   var geoJson = self._extractGeoJson( field.value 
);
+   if ( !geoJson ) {
+   return;
}
 
-   var popup = L.popup(),
-   lon = longLat[0],
-   lat = longLat[1];
-
var layer = self._getMarkerGroupsLayer( row );
-   var marker = L.circleMarker( [ lat, lon ], 
self._getMarkerStyle( layer ) )
-   .bindPopup( popup );
-
-   marker.on( 'click', function() {
-   var info = self._getItemDescription( 
row );
-   popup.setContent( info[0] );
-   } );
-
if ( !markers[ layer