From 0d0ed6c130bd1ba7eb08488087937b1727b0995f Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Wed, 14 Jun 2017 15:33:16 +0200 Subject: [PATCH] Only adjust resolution when center within projection extent --- src/ol/reproj.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ol/reproj.js b/src/ol/reproj.js index 10da24c84d..7ea785dcf7 100644 --- a/src/ol/reproj.js +++ b/src/ol/reproj.js @@ -40,12 +40,14 @@ ol.reproj.calculateSourceResolution = function(sourceProj, targetProj, // coordinates may be slightly different. We need to reverse-compensate this // in order to achieve optimal results. - var compensationFactor = - ol.proj.getPointResolution(sourceProj, sourceResolution, sourceCenter) / - sourceResolution; - - if (isFinite(compensationFactor) && compensationFactor > 0) { - sourceResolution /= compensationFactor; + var sourceExtent = sourceProj.getExtent(); + if (!sourceExtent || ol.extent.containsCoordinate(sourceExtent, sourceCenter)) { + var compensationFactor = + ol.proj.getPointResolution(sourceProj, sourceResolution, sourceCenter) / + sourceResolution; + if (isFinite(compensationFactor) && compensationFactor > 0) { + sourceResolution /= compensationFactor; + } } return sourceResolution;