From 8f02fdd0611cd5a0e51536925cb4f010c66f86b7 Mon Sep 17 00:00:00 2001 From: Just van den Broecke Date: Tue, 8 Apr 2014 16:55:51 +0200 Subject: [PATCH] issue #230 - refined tooltip and WFS projection options, via defaultSrs config options --- src/script/plugins/AddLayers.js | 14 ++++++++++++-- src/script/plugins/WFSSource.js | 30 +++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/script/plugins/AddLayers.js b/src/script/plugins/AddLayers.js index 12483efe..1cc49f22 100644 --- a/src/script/plugins/AddLayers.js +++ b/src/script/plugins/AddLayers.js @@ -774,7 +774,10 @@ gxp.plugins.AddLayers = Ext.extend(gxp.plugins.Tool, { xtype: 'button', iconCls: 'gxp-icon-find', text: this.searchLayersSearchText, - tooltip: 'Search within the Layer text fields, click again to reset search', + tooltip: { + text: 'Search within the Layer text fields. Click again to reset search results.', + width: 360 + }, handler: function () { this.sourceTextSearch(Ext.getDom('txtSearch').value); }, @@ -788,7 +791,10 @@ gxp.plugins.AddLayers = Ext.extend(gxp.plugins.Tool, { xtype: 'button', iconCls: 'gxp-icon-book-open', text: this.sortLayersText, - tooltip: 'Sort the layers alphabetically by title, toggle to sort asc/descending', + tooltip: { + text: 'Sort the layers alphabetically by title. Toggle to sort asc/descending.', + width: 360 + }, handler: function (f, e) { this.sourceSort(); }, @@ -846,6 +852,9 @@ gxp.plugins.AddLayers = Ext.extend(gxp.plugins.Tool, { case 'WFS': config.ptype = 'gxp_wfssource'; config.owsPreviewStrategies = this.owsPreviewStrategies; + if (this.defaultSrs !== undefined) { + config.defaultSrs = this.defaultSrs; + } break; default: config.ptype = 'gxp_wmscsource'; @@ -1000,6 +1009,7 @@ gxp.plugins.AddLayers = Ext.extend(gxp.plugins.Tool, { var store = this.selectedSource.store; if (!text || text == '' || text == this.searchLayersEmptyText || text == store.lastSearchText) { store.clearFilter(false); + store.lastSearchText = null; return; } store.clearFilter(true); diff --git a/src/script/plugins/WFSSource.js b/src/script/plugins/WFSSource.js index 8ccfdebf..62d6d208 100644 --- a/src/script/plugins/WFSSource.js +++ b/src/script/plugins/WFSSource.js @@ -153,9 +153,15 @@ gxp.plugins.WFSSource = Ext.extend(gxp.plugins.LayerSource, { /** api: config[owsPreviewStrategies] * ``Array`` - * String array with the order of strategies to obtain preview images for OWS services, default is ['attributionlogo', 'getlegendgraphic']. + * String array with the order of strategies to obtain preview images for OWS services, default is ['attributionlogo', 'randomcolor']. */ - owsPreviewStrategies: ['attributionlogo'], + owsPreviewStrategies: ['randomcolor'], + + /** api: config[defaultSrs] + * ``String`` + * String specifying the default SRS for a WFS layer if it does not map the map projection, use Layer SRS if null. + */ + defaultSrs: 'EPSG:4326', /** private: method[constructor] */ @@ -444,15 +450,20 @@ gxp.plugins.WFSSource = Ext.extend(gxp.plugins.LayerSource, { } if (original) { - /** * TODO: The WFSCapabilitiesReader should allow for creation * of layers in different SRS. */ - var projection, layerProjection; - projection = layerProjection = this.getMapProjection(); + // Determine layer projection, 4 options: + // 1. Use the same coordinate system as the project (Map) if matching WFS "DefaultCRS". + // 2. if defaultSrs NOT configured: use default value EPSG:4326 + // 3. if defaultSrs configured: then use that SRS + // 4. if defaultSrs explicitly configured to null use record SRS, i.e. WFS "DefaultCRS" + var mapProjection, layerProjection; + + // See if there is a (default) SRS + mapProjection = layerProjection = this.getMapProjection(); var srs = original.get("srs"); - if (srs) { // If stupid code like: "urn:x-ogc:def:crs:EPSG:4326" if (srs.indexOf('urn') >= 0) { @@ -460,15 +471,16 @@ gxp.plugins.WFSSource = Ext.extend(gxp.plugins.LayerSource, { } layerProjection = new OpenLayers.Projection(srs) } - - var projCode = (layerProjection || projection).getCode(); + if (!layerProjection.equals(mapProjection) && this.defaultSrs) { + layerProjection = new OpenLayers.Projection(this.defaultSrs); + } var llBounds = original.get("bounds"); if (!llBounds) { llBounds = new OpenLayers.Bounds(-180, -90, 180, 90); } // Determine maxExtent in map projection - var maxExtent = (projCode != 'EPSG:4326') ? llBounds.transform("EPSG:4326", projection) : llBounds; + var maxExtent = llBounds.transform("EPSG:4326", mapProjection); // Style: first assume default style var styleMap = original.data.layer.styleMap;