Merge pull request #7305 from oterral/teo_info
Fix #7304: Re-calculate the resolution when the WMS source is reprojected
This commit is contained in:
@@ -6,7 +6,7 @@ goog.require('ol.proj');
|
||||
|
||||
describe('ol.source.ImageWMS', function() {
|
||||
|
||||
var extent, pixelRatio, options, projection, resolution;
|
||||
var extent, pixelRatio, options, optionsReproj, projection, resolution;
|
||||
beforeEach(function() {
|
||||
extent = [10, 20, 30, 40];
|
||||
pixelRatio = 1;
|
||||
@@ -19,6 +19,14 @@ describe('ol.source.ImageWMS', function() {
|
||||
ratio: 1,
|
||||
url: 'http://example.com/wms'
|
||||
};
|
||||
optionsReproj = {
|
||||
params: {
|
||||
'LAYERS': 'layer'
|
||||
},
|
||||
ratio: 1,
|
||||
url: 'http://example.com/wms',
|
||||
projection: 'EPSG:3857'
|
||||
};
|
||||
});
|
||||
|
||||
describe('#getImage', function() {
|
||||
@@ -223,7 +231,7 @@ describe('ol.source.ImageWMS', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#getGetFeatureInfo', function() {
|
||||
describe('#getGetFeatureInfoUrl', function() {
|
||||
|
||||
it('returns the expected GetFeatureInfo URL', function() {
|
||||
var source = new ol.source.ImageWMS(options);
|
||||
@@ -253,6 +261,34 @@ describe('ol.source.ImageWMS', function() {
|
||||
expect(uri.hash.replace('#', '')).to.be.empty();
|
||||
});
|
||||
|
||||
it('returns the expected GetFeatureInfo URL when source\'s projection is different from the parameter', function() {
|
||||
var source = new ol.source.ImageWMS(optionsReproj);
|
||||
var url = source.getGetFeatureInfoUrl(
|
||||
[20, 30], resolution, projection,
|
||||
{INFO_FORMAT: 'text/plain'});
|
||||
var uri = new URL(url);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/wms');
|
||||
var queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('1577259.402312431,2854419.4299513334,2875520.229418512,4152680.2570574144');
|
||||
expect(queryData.get('CRS')).to.be('EPSG:3857');
|
||||
expect(queryData.get('FORMAT')).to.be('image/png');
|
||||
expect(queryData.get('HEIGHT')).to.be('101');
|
||||
expect(queryData.get('I')).to.be('50');
|
||||
expect(queryData.get('J')).to.be('50');
|
||||
expect(queryData.get('LAYERS')).to.be('layer');
|
||||
expect(queryData.get('QUERY_LAYERS')).to.be('layer');
|
||||
expect(queryData.get('REQUEST')).to.be('GetFeatureInfo');
|
||||
expect(queryData.get('SERVICE')).to.be('WMS');
|
||||
expect(queryData.get('SRS')).to.be(null);
|
||||
expect(queryData.get('STYLES')).to.be('');
|
||||
expect(queryData.get('TRANSPARENT')).to.be('true');
|
||||
expect(queryData.get('VERSION')).to.be('1.3.0');
|
||||
expect(queryData.get('WIDTH')).to.be('101');
|
||||
expect(uri.hash.replace('#', '')).to.be.empty();
|
||||
});
|
||||
|
||||
it('sets the QUERY_LAYERS param as expected', function() {
|
||||
var source = new ol.source.ImageWMS(options);
|
||||
var url = source.getGetFeatureInfoUrl(
|
||||
|
||||
@@ -9,7 +9,7 @@ goog.require('ol.tilegrid.TileGrid');
|
||||
|
||||
describe('ol.source.TileWMS', function() {
|
||||
|
||||
var options;
|
||||
var options, optionsReproj;
|
||||
beforeEach(function() {
|
||||
options = {
|
||||
params: {
|
||||
@@ -17,6 +17,13 @@ describe('ol.source.TileWMS', function() {
|
||||
},
|
||||
url: 'http://example.com/wms'
|
||||
};
|
||||
optionsReproj = {
|
||||
params: {
|
||||
'LAYERS': 'layer'
|
||||
},
|
||||
url: 'http://example.com/wms',
|
||||
projection: 'EPSG:4326'
|
||||
};
|
||||
});
|
||||
|
||||
describe('constructor', function() {
|
||||
@@ -193,7 +200,7 @@ describe('ol.source.TileWMS', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#getGetFeatureInfo', function() {
|
||||
describe('#getGetFeatureInfoUrl', function() {
|
||||
|
||||
it('returns the expected GetFeatureInfo URL', function() {
|
||||
var source = new ol.source.TileWMS(options);
|
||||
@@ -229,6 +236,36 @@ describe('ol.source.TileWMS', function() {
|
||||
expect(uri.hash.replace('#', '')).to.be.empty();
|
||||
});
|
||||
|
||||
it('returns the expected GetFeatureInfo URL when source\'s projection is different from the parameter', function() {
|
||||
var source = new ol.source.TileWMS(optionsReproj);
|
||||
source.pixelRatio_ = 1;
|
||||
var url = source.getGetFeatureInfoUrl(
|
||||
[-7000000, -12000000],
|
||||
19567.87924100512, ol.proj.get('EPSG:3857'),
|
||||
{INFO_FORMAT: 'text/plain'});
|
||||
var uri = new URL(url);
|
||||
expect(uri.protocol).to.be('http:');
|
||||
expect(uri.hostname).to.be('example.com');
|
||||
expect(uri.pathname).to.be('/wms');
|
||||
var queryData = uri.searchParams;
|
||||
expect(queryData.get('BBOX')).to.be('-79.17133464081945,-90,-66.51326044311186,-45');
|
||||
expect(queryData.get('CRS')).to.be('EPSG:4326');
|
||||
expect(queryData.get('FORMAT')).to.be('image/png');
|
||||
expect(queryData.get('HEIGHT')).to.be('256');
|
||||
expect(queryData.get('I')).to.be('517');
|
||||
expect(queryData.get('J')).to.be('117');
|
||||
expect(queryData.get('LAYERS')).to.be('layer');
|
||||
expect(queryData.get('QUERY_LAYERS')).to.be('layer');
|
||||
expect(queryData.get('REQUEST')).to.be('GetFeatureInfo');
|
||||
expect(queryData.get('SERVICE')).to.be('WMS');
|
||||
expect(queryData.get('SRS')).to.be(null);
|
||||
expect(queryData.get('STYLES')).to.be('');
|
||||
expect(queryData.get('TRANSPARENT')).to.be('true');
|
||||
expect(queryData.get('VERSION')).to.be('1.3.0');
|
||||
expect(queryData.get('WIDTH')).to.be('256');
|
||||
expect(uri.hash.replace('#', '')).to.be.empty();
|
||||
});
|
||||
|
||||
it('sets the QUERY_LAYERS param as expected', function() {
|
||||
var source = new ol.source.TileWMS(options);
|
||||
source.pixelRatio_ = 1;
|
||||
|
||||
Reference in New Issue
Block a user