Fix #7304: Re-calculate the resolution when the WMS source is reprojected

This commit is contained in:
Kogis IWI
2017-10-03 17:21:36 +02:00
parent 2e16d04bbe
commit 232f56e229
4 changed files with 99 additions and 12 deletions

View File

@@ -10,6 +10,7 @@ goog.require('ol.events.EventType');
goog.require('ol.extent');
goog.require('ol.obj');
goog.require('ol.proj');
goog.require('ol.reproj');
goog.require('ol.source.Image');
goog.require('ol.source.WMSServerType');
goog.require('ol.string');
@@ -136,6 +137,13 @@ ol.source.ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolut
if (this.url_ === undefined) {
return undefined;
}
var projectionObj = ol.proj.get(projection);
var sourceProjectionObj = this.getProjection();
if (sourceProjectionObj && sourceProjectionObj !== projectionObj) {
resolution = ol.reproj.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, resolution);
coordinate = ol.proj.transform(coordinate, projectionObj, sourceProjectionObj);
}
var extent = ol.extent.getForViewAndSize(
coordinate, resolution, 0,
@@ -158,7 +166,7 @@ ol.source.ImageWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolut
return this.getRequestUrl_(
extent, ol.source.ImageWMS.GETFEATUREINFO_IMAGE_SIZE_,
1, ol.proj.get(projection), baseParams);
1, sourceProjectionObj || projectionObj, baseParams);
};

View File

@@ -10,6 +10,7 @@ goog.require('ol.extent');
goog.require('ol.obj');
goog.require('ol.math');
goog.require('ol.proj');
goog.require('ol.reproj');
goog.require('ol.size');
goog.require('ol.source.TileImage');
goog.require('ol.source.WMSServerType');
@@ -117,14 +118,14 @@ ol.inherits(ol.source.TileWMS, ol.source.TileImage);
*/
ol.source.TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resolution, projection, params) {
var projectionObj = ol.proj.get(projection);
var sourceProjectionObj = this.getProjection();
var tileGrid = this.getTileGrid();
if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projectionObj);
}
var tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, resolution);
var tileCoord = tileGrid.getTileCoordForCoordAndResolution(coordinate, resolution);
if (tileGrid.getResolutions().length <= tileCoord[0]) {
return undefined;
@@ -132,14 +133,19 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resoluti
var tileResolution = tileGrid.getResolution(tileCoord[0]);
var tileExtent = tileGrid.getTileCoordExtent(tileCoord, this.tmpExtent_);
var tileSize = ol.size.toSize(
tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
var tileSize = ol.size.toSize(tileGrid.getTileSize(tileCoord[0]), this.tmpSize);
var gutter = this.gutter_;
if (gutter !== 0) {
tileSize = ol.size.buffer(tileSize, gutter, this.tmpSize);
tileExtent = ol.extent.buffer(tileExtent,
tileResolution * gutter, tileExtent);
tileExtent = ol.extent.buffer(tileExtent, tileResolution * gutter, tileExtent);
}
if (sourceProjectionObj && sourceProjectionObj !== projectionObj) {
tileResolution = ol.reproj.calculateSourceResolution(sourceProjectionObj, projectionObj, coordinate, tileResolution);
tileExtent = ol.proj.transformExtent(tileExtent, projectionObj, sourceProjectionObj);
coordinate = ol.proj.transform(coordinate, projectionObj, sourceProjectionObj);
}
var baseParams = {
@@ -159,7 +165,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl = function(coordinate, resoluti
baseParams[this.v13_ ? 'J' : 'Y'] = y;
return this.getRequestUrl_(tileCoord, tileSize, tileExtent,
1, projectionObj, baseParams);
1, sourceProjectionObj || projectionObj, baseParams);
};