Skip to content

Fix out-of-range tile indices for tms#14

Open
m314 wants to merge 3 commits intoghybs:masterfrom
m314:master
Open

Fix out-of-range tile indices for tms#14
m314 wants to merge 3 commits intoghybs:masterfrom
m314:master

Conversation

@m314
Copy link
Copy Markdown

@m314 m314 commented Nov 15, 2018

Closes #13.

@ghybs
Copy link
Copy Markdown
Owner

ghybs commented Nov 23, 2018

Hi,

Thank you so much for this PR! 👍
Sorry for the delay in reviewing it...

Thinking further about it, I do not know how computation intensive are the calls to map.getPixelWorldBounds and this._pxBoundsToTileRange, but it looks like a waste calling them for every tile with getTileUrl, whereas in Leaflet GridLayer they are called only once per view update.

As you pinpointed it from the beginning, we actually need to call them when the zoom changes, i.e. in the case of this plugin, when it tries requesting tiles from a lower zoom to replace a missing tile.

Therefore it seems to me that we would basically need instead to compute them once for each zoom, and possibly cache their result in a dictionary {[zoom]: maxY}.
I suspect the result is dependent only on the zoom value (to be checked).

@ecsdavidt
Copy link
Copy Markdown

I missed this issue/pr, the options.tms bug threw me for a loop for a bit, and I came up with my own approach, though it wouldn't surprise me if it's naïve in ways I don't understand. If the tile range is fixed by zoom level, then the calculation is simple:

    if (this.options.tms) {
        var zDifference = this._getZoomForUrl() - coords.z;
        tmsY = ((this._globalTileRange.max.y + 1) / Math.pow(2, zDifference)) - 1 - coords.y;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

y value out of tileset range for tms

3 participants