-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support 'tms' tile scheme #2565
Conversation
What do you think about supporting |
@mourner I suggested that in #2409; |
Oh, you're totally right — I wasn't aware it's in the TileJSON specs. Looks good to me then! |
@indus completely forgot to ask — can you PR a simple unit test for this change? |
@lucaswoj Thanks for doing the hard work! |
please note that the style spec only mentions scheme for raster sources, not for vector sources. Is this an omission in the style spec? https://www.mapbox.com/mapbox-gl-js/style-spec/#sources-raster |
Did you really came across Vector Tiles with TMS scheme? But you are right it says in the specs:
(of course it says nothing about the support for it ;-) |
I saw it in this post for instance: https://gis.stackexchange.com/questions/238301/mapbox-vector-tiles-from-geoserver-2-11-in-mapbox-gl-js |
TMS is the scheme used in mbtiles, so it's not that unthinkable... |
Thanks for supporting TMS as OGC config vector tiles format, and make it configurable in Mapbox-gl-js. Do you think about elaborating it in official documentation? A lot of developers are relying on the documentation. For example, since this support is not elaborated, the type library of Mapbox-gl-js in angular lacks TMS support in vector tiles. |
@eugeneYWang I just opened a PR adding this to the docs #6847 |
return urls[(this.x + this.y) % urls.length] | ||
.replace('{prefix}', (this.x % 16).toString(16) + (this.y % 16).toString(16)) | ||
.replace('{z}', Math.min(this.z, sourceMaxZoom || this.z)) | ||
.replace('{x}', this.x) | ||
.replace('{y}', this.y); | ||
.replace('{y}', scheme === 'tms' ? (Math.pow(2, this.z) - this.y - 1) : this.y); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I'm using mbtiles, but i find the tool i used to translate google xyz to tms schema does not use Math.pow(2, this.z) - this.y - 1
, but Math.pow(2, this.z - 1) - this.y - 1
. I konw that tms's original is (-180, -90), and xyz's original is (-180, 90), so it is easy to understand Math.pow(2, this.z - 1) - this.y - 1
.
Can somebody tell me how does Math.pow(2, this.z) - this.y - 1
works and which is right method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide a link to the tool you are using?
With quick websearch I only found the transformation in use:
https://gist.github.com/tmcw/4954720
http://bl.ocks.org/lennepkade/b6fe9e4862668b2d19fe26f6c2d7cbef
https://alastaira.wordpress.com/2011/07/06/converting-tms-tile-coordinates-to-googlebingosm-tile-coordinates/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've red the 3rd blog and learned that i misunderstood the map tile method. So we transfer the world to a square using Web Mercator system, and we can get the total tile number which can be described as (1 << zoom - 1).
Now I guess it is the coordinate system i'm using cause the problem. In fact, i transformed a map to mbtiles which is projected to EPSG:4326
(WGS84) . But as we know mbtiles spec using tms and mercator projection. That might need to be supported by a projection-customized mapbox-gl.
Thanks for your help! :) 👍
Issue: #1616
Specs: https://www.mapbox.com/mapbox-gl-style-spec/#sources
Reference: https://github.com/mapbox/tilejson-spec/blob/master/2.1.0/schema.json#L28
(a new clean attempt for #2480)