diff --git a/src/pyramid.js b/src/pyramid.js index 4ae2abba..36218c1d 100644 --- a/src/pyramid.js +++ b/src/pyramid.js @@ -204,13 +204,18 @@ function _computeImagePyramid ({ metadata }) { (totalPixelMatrixColumns * pixelSpacing[1]).toFixed(4), (totalPixelMatrixRows * pixelSpacing[0]).toFixed(4) ]) + let zoomFactor = baseTotalPixelMatrixColumns / totalPixelMatrixColumns + const roundedZoomFactor = Math.round(zoomFactor) /* * Compute the resolution at each pyramid level, since the zoom * factor may not be the same between adjacent pyramid levels. + * + * Round is conditional to avoid openlayers resolutions error. + * The resolutions array should be composed of unique values in descending order. */ - const zoomFactor = Math.round( - baseTotalPixelMatrixColumns / totalPixelMatrixColumns - ) + zoomFactor = pyramidResolutions.includes(roundedZoomFactor) + ? zoomFactor.toFixed(3) + : roundedZoomFactor pyramidResolutions.push(zoomFactor) pyramidOrigins.push(offset)