Skip to content

Commit 24224dd

Browse files
committed
Merge pull request #177 from opengeo/projection
Properly set equivalent projection when possible in WMSSource
2 parents 6b19b5c + 84f2d49 commit 24224dd

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

src/script/plugins/WMSSource.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,15 @@ gxp.plugins.WMSSource = Ext.extend(gxp.plugins.LayerSource, {
488488
// compatible projection that equals the map projection. This helps
489489
// us in dealing with the different EPSG codes for web mercator.
490490
var layerProjection = this.getProjection(original);
491+
if (layerProjection) {
492+
layer.addOptions({projection: layerProjection});
493+
}
491494

492495
var projCode = (layerProjection || projection).getCode(),
493496
bbox = original.get("bbox"), maxExtent;
497+
498+
// determine maxExtent in map projection
494499
if (bbox && bbox[projCode]){
495-
layer.addOptions({projection: layerProjection});
496500
maxExtent = OpenLayers.Bounds.fromArray(bbox[projCode].bbox, layer.reverseAxisOrder());
497501
} else {
498502
var llbbox = original.get("llbbox");

tests/script/plugins/WMSSource.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,49 @@
9393
});
9494
}
9595

96+
function test_createLayerRecord_102113(t) {
97+
98+
/**
99+
This test confirms that when a viewer is configured with
100+
EPSG:102113 but the server doesn't advertise the same, the
101+
layer projection will be set to an equivalent projection.
102+
*/
103+
104+
t.plan(1);
105+
106+
var viewer = new gxp.Viewer({
107+
sources: {
108+
local: {
109+
ptype: "gxp_wmssource",
110+
url: "wms_caps.xml"
111+
}
112+
},
113+
map: {
114+
projection: "EPSG:102113",
115+
center: [0, 0],
116+
zoom: 1,
117+
layers: [{
118+
source: "local",
119+
name: "usa:states"
120+
}]
121+
}
122+
});
123+
124+
125+
t.delay_call(1, function() {
126+
var source = viewer.layerSources.local,
127+
record = source.createLayerRecord({name: "world:borders"}),
128+
projection = record.getLayer().projection;
129+
130+
if (projection) {
131+
var code = projection.getCode();
132+
t.ok(code === 'EPSG:900913' || code === 'EPSG:3857', 'mercator');
133+
} else {
134+
t.fail('layer has no projection')
135+
}
136+
});
137+
}
138+
96139
function test_createLayerRecord_restUrl(t) {
97140
t.plan(1);
98141

tests/script/plugins/wms_caps.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@
145145
<SRS>EPSG:4326</SRS>
146146
<SRS>EPSG:900913</SRS>
147147
<SRS>EPSG:3857</SRS>
148-
<SRS>EPSG:102113</SRS>
149-
<SRS>EPSG:102100</SRS>
150148
<LatLonBoundingBox minx="-180.0" miny="-157.323" maxx="180.0" maxy="90.0"/>
151149
<Layer queryable="1">
152150
<Name>medford:bikelanes</Name>

0 commit comments

Comments
 (0)