simplify scale calculation
update tests to reflect more accurate calculation
This commit is contained in:
@@ -247,9 +247,8 @@ class ImageWMS extends ImageSource {
|
|||||||
const mpu = this.getProjection()
|
const mpu = this.getProjection()
|
||||||
? this.getProjection().getMetersPerUnit()
|
? this.getProjection().getMetersPerUnit()
|
||||||
: 1;
|
: 1;
|
||||||
const dpi = 25.4 / 0.28;
|
const pixelSize = 0.00028;
|
||||||
const inchesPerMeter = 39.37;
|
baseParams['SCALE'] = (resolution * mpu) / pixelSize;
|
||||||
baseParams['SCALE'] = resolution * mpu * inchesPerMeter * dpi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assign(baseParams, params);
|
assign(baseParams, params);
|
||||||
|
|||||||
@@ -263,9 +263,8 @@ class TileWMS extends TileImage {
|
|||||||
const mpu = this.getProjection()
|
const mpu = this.getProjection()
|
||||||
? this.getProjection().getMetersPerUnit()
|
? this.getProjection().getMetersPerUnit()
|
||||||
: 1;
|
: 1;
|
||||||
const dpi = 25.4 / 0.28;
|
const pixelSize = 0.00028;
|
||||||
const inchesPerMeter = 39.37;
|
baseParams['SCALE'] = (resolution * mpu) / pixelSize;
|
||||||
baseParams['SCALE'] = resolution * mpu * inchesPerMeter * dpi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assign(baseParams, params);
|
assign(baseParams, params);
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ describe('ol.source.ImageWMS', function () {
|
|||||||
expect(queryData.get('REQUEST')).to.be('GetLegendGraphic');
|
expect(queryData.get('REQUEST')).to.be('GetLegendGraphic');
|
||||||
expect(queryData.get('SERVICE')).to.be('WMS');
|
expect(queryData.get('SERVICE')).to.be('WMS');
|
||||||
expect(queryData.get('VERSION')).to.be('1.3.0');
|
expect(queryData.get('VERSION')).to.be('1.3.0');
|
||||||
expect(queryData.get('SCALE')).to.be('357.14214285714274');
|
expect(queryData.get('SCALE')).to.be('357.14285714285717');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not include SCALE if no resolution was provided', function () {
|
it('does not include SCALE if no resolution was provided', function () {
|
||||||
@@ -405,7 +405,7 @@ describe('ol.source.ImageWMS', function () {
|
|||||||
expect(queryData.get('REQUEST')).to.be('GetLegendGraphic');
|
expect(queryData.get('REQUEST')).to.be('GetLegendGraphic');
|
||||||
expect(queryData.get('SERVICE')).to.be('WMS');
|
expect(queryData.get('SERVICE')).to.be('WMS');
|
||||||
expect(queryData.get('VERSION')).to.be('1.3.0');
|
expect(queryData.get('VERSION')).to.be('1.3.0');
|
||||||
expect(queryData.get('SCALE')).to.be('357.14214285714274');
|
expect(queryData.get('SCALE')).to.be('357.14285714285717');
|
||||||
expect(queryData.get('STYLE')).to.be('STYLE_VALUE');
|
expect(queryData.get('STYLE')).to.be('STYLE_VALUE');
|
||||||
expect(queryData.get('FEATURETYPE')).to.be('FEATURETYPE_VALUE');
|
expect(queryData.get('FEATURETYPE')).to.be('FEATURETYPE_VALUE');
|
||||||
expect(queryData.get('RULE')).to.be('RULE_VALUE');
|
expect(queryData.get('RULE')).to.be('RULE_VALUE');
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ describe('ol.source.TileWMS', function () {
|
|||||||
expect(queryData.get('REQUEST')).to.be('GetLegendGraphic');
|
expect(queryData.get('REQUEST')).to.be('GetLegendGraphic');
|
||||||
expect(queryData.get('SERVICE')).to.be('WMS');
|
expect(queryData.get('SERVICE')).to.be('WMS');
|
||||||
expect(queryData.get('VERSION')).to.be('1.3.0');
|
expect(queryData.get('VERSION')).to.be('1.3.0');
|
||||||
expect(queryData.get('SCALE')).to.be('357.14214285714274');
|
expect(queryData.get('SCALE')).to.be('357.14285714285717');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not include SCALE if no resolution was provided', function () {
|
it('does not include SCALE if no resolution was provided', function () {
|
||||||
@@ -365,7 +365,7 @@ describe('ol.source.TileWMS', function () {
|
|||||||
expect(queryData.get('REQUEST')).to.be('GetLegendGraphic');
|
expect(queryData.get('REQUEST')).to.be('GetLegendGraphic');
|
||||||
expect(queryData.get('SERVICE')).to.be('WMS');
|
expect(queryData.get('SERVICE')).to.be('WMS');
|
||||||
expect(queryData.get('VERSION')).to.be('1.3.0');
|
expect(queryData.get('VERSION')).to.be('1.3.0');
|
||||||
expect(queryData.get('SCALE')).to.be('357.14214285714274');
|
expect(queryData.get('SCALE')).to.be('357.14285714285717');
|
||||||
expect(queryData.get('STYLE')).to.be('STYLE_VALUE');
|
expect(queryData.get('STYLE')).to.be('STYLE_VALUE');
|
||||||
expect(queryData.get('FEATURETYPE')).to.be('FEATURETYPE_VALUE');
|
expect(queryData.get('FEATURETYPE')).to.be('FEATURETYPE_VALUE');
|
||||||
expect(queryData.get('RULE')).to.be('RULE_VALUE');
|
expect(queryData.get('RULE')).to.be('RULE_VALUE');
|
||||||
|
|||||||
Reference in New Issue
Block a user