Skip to content

Commit

Permalink
issue planetfederal#230 - refined tooltip and WFS projection options,…
Browse files Browse the repository at this point in the history
… via defaultSrs config options
  • Loading branch information
justb4 committed Apr 8, 2014
1 parent f77421d commit 8f02fdd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
14 changes: 12 additions & 2 deletions src/script/plugins/AddLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand All @@ -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();
},
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
30 changes: 21 additions & 9 deletions src/script/plugins/WFSSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
*/
Expand Down Expand Up @@ -444,31 +450,37 @@ 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) {
srs = 'EPSG' + srs.split('EPSG')[1];
}
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;
Expand Down

0 comments on commit 8f02fdd

Please sign in to comment.