Skip to content

Commit

Permalink
Merge pull request #177 from opengeo/projection
Browse files Browse the repository at this point in the history
Properly set equivalent projection when possible in WMSSource
  • Loading branch information
tschaub committed Jul 3, 2013
2 parents 6b19b5c + 84f2d49 commit 24224dd
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/script/plugins/WMSSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
43 changes: 43 additions & 0 deletions tests/script/plugins/WMSSource.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions tests/script/plugins/wms_caps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@
<SRS>EPSG:4326</SRS>
<SRS>EPSG:900913</SRS>
<SRS>EPSG:3857</SRS>
<SRS>EPSG:102113</SRS>
<SRS>EPSG:102100</SRS>
<LatLonBoundingBox minx="-180.0" miny="-157.323" maxx="180.0" maxy="90.0"/>
<Layer queryable="1">
<Name>medford:bikelanes</Name>
Expand Down

0 comments on commit 24224dd

Please sign in to comment.