Skip to content

Commit

Permalink
Avoid repeated resolutions caused by rounded zoom factors
Browse files Browse the repository at this point in the history
  • Loading branch information
igoroctaviano committed Oct 31, 2023
1 parent bda0cfe commit c01a6d4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/pyramid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c01a6d4

Please sign in to comment.