Skip to content
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

Merged
merged 1 commit into from
May 18, 2016
Merged

support 'tms' tile scheme #2565

merged 1 commit into from
May 18, 2016

Conversation

indus
Copy link
Contributor

@indus indus commented May 12, 2016

Issue: #1616

Specs: https://www.mapbox.com/mapbox-gl-style-spec/#sources

Tiled sources (vector and raster) must specify their details in terms of the TileJSON specification

Reference: https://github.com/mapbox/tilejson-spec/blob/master/2.1.0/schema.json#L28

(a new clean attempt for #2480)

@indus indus mentioned this pull request May 12, 2016
@mourner
Copy link
Member

mourner commented May 18, 2016

What do you think about supporting {-y} token instead of a dedicated scheme option? This would probably be better because usage of TMS scheme would be encompassed in the source url rather than requiring options.

@indus
Copy link
Contributor Author

indus commented May 18, 2016

@mourner I suggested that in #2409;
But I´m not sure if it is a better or just a quick&dirty solution; I think it is favorable to bring the API in line with the specs (https://github.com/mapbox/tilejson-spec/blob/master/2.1.0/README.md) - or the other way round ;-)

@mourner
Copy link
Member

mourner commented May 18, 2016

Oh, you're totally right — I wasn't aware it's in the TileJSON specs. Looks good to me then!

@mourner mourner merged commit 1fe021b into mapbox:master May 18, 2016
This was referenced May 18, 2016
@mourner
Copy link
Member

mourner commented May 18, 2016

@indus completely forgot to ask — can you PR a simple unit test for this change?

@indus
Copy link
Contributor Author

indus commented May 19, 2016

@lucaswoj Thanks for doing the hard work!

@bartvde
Copy link
Contributor

bartvde commented Dec 13, 2017

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
https://www.mapbox.com/mapbox-gl-js/style-spec/#sources-vector

@indus
Copy link
Contributor Author

indus commented Dec 13, 2017

Did you really came across Vector Tiles with TMS scheme?
I would guess it is just that there is only a need to support the canonical XYZ scheme:
https://github.com/mapbox/vector-tile-spec/blob/master/2.1/README.md#3-projection-and-bounds

But you are right it says in the specs:

Vector Tiles MAY be used to represent data with any projection and tile extent scheme.

(of course it says nothing about the support for it ;-)

@bartvde
Copy link
Contributor

bartvde commented Dec 13, 2017

@systemed
Copy link

Did you really came across Vector Tiles with TMS scheme?

TMS is the scheme used in mbtiles, so it's not that unthinkable...

@eugeneYWang
Copy link

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.

@mollymerp
Copy link
Contributor

@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);

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?

Copy link
Contributor Author

@indus indus Dec 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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! :) 👍

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

Successfully merging this pull request may close these issues.

7 participants