diff --git a/src/script/plugins/WMSSource.js b/src/script/plugins/WMSSource.js index 021017ee..3ca9ee22 100644 --- a/src/script/plugins/WMSSource.js +++ b/src/script/plugins/WMSSource.js @@ -488,11 +488,15 @@ gxp.plugins.WMSSource = Ext.extend(gxp.plugins.LayerSource, { // compatible projection that equals the map projection. This helps // us in dealing with the different EPSG codes for web mercator. var layerProjection = this.getProjection(original); + if (layerProjection) { + layer.addOptions({projection: layerProjection}); + } var projCode = (layerProjection || projection).getCode(), bbox = original.get("bbox"), maxExtent; + + // determine maxExtent in map projection if (bbox && bbox[projCode]){ - layer.addOptions({projection: layerProjection}); maxExtent = OpenLayers.Bounds.fromArray(bbox[projCode].bbox, layer.reverseAxisOrder()); } else { var llbbox = original.get("llbbox"); diff --git a/tests/script/plugins/WMSSource.html b/tests/script/plugins/WMSSource.html index 405a7162..3d3469a2 100644 --- a/tests/script/plugins/WMSSource.html +++ b/tests/script/plugins/WMSSource.html @@ -93,6 +93,49 @@ }); } + function test_createLayerRecord_102113(t) { + + /** + This test confirms that when a viewer is configured with + EPSG:102113 but the server doesn't advertise the same, the + layer projection will be set to an equivalent projection. + */ + + t.plan(1); + + var viewer = new gxp.Viewer({ + sources: { + local: { + ptype: "gxp_wmssource", + url: "wms_caps.xml" + } + }, + map: { + projection: "EPSG:102113", + center: [0, 0], + zoom: 1, + layers: [{ + source: "local", + name: "usa:states" + }] + } + }); + + + t.delay_call(1, function() { + var source = viewer.layerSources.local, + record = source.createLayerRecord({name: "world:borders"}), + projection = record.getLayer().projection; + + if (projection) { + var code = projection.getCode(); + t.ok(code === 'EPSG:900913' || code === 'EPSG:3857', 'mercator'); + } else { + t.fail('layer has no projection') + } + }); + } + function test_createLayerRecord_restUrl(t) { t.plan(1); diff --git a/tests/script/plugins/wms_caps.xml b/tests/script/plugins/wms_caps.xml index c1ed7065..ac3365d9 100644 --- a/tests/script/plugins/wms_caps.xml +++ b/tests/script/plugins/wms_caps.xml @@ -145,8 +145,6 @@ EPSG:4326 EPSG:900913 EPSG:3857 - EPSG:102113 - EPSG:102100 medford:bikelanes