Skip to content

support 'tms' tile scheme - #2565

Merged
mourner merged 1 commit into
mapbox:masterfrom
indus:tms-scheme
May 18, 2016
Merged

mourner merged 1 commit into
mapbox:masterfrom
indus:tms-scheme

Conversation

@indus

@indus indus commented May 12, 2016 •

Copy link
Copy Markdown
Contributor

@indus indus mentioned this pull request May 12, 2016
@mourner

mourner commented May 18, 2016

Copy link
Copy Markdown
Member

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

indus commented May 18, 2016

Copy link
Copy Markdown
Contributor Author

@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

mourner commented May 18, 2016

Copy link
Copy Markdown
Member

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

mourner commented May 18, 2016

Copy link
Copy Markdown
Member

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

@indus

indus commented May 19, 2016

Copy link
Copy Markdown
Contributor Author

@lucaswoj Thanks for doing the hard work!

@bartvde

bartvde commented Dec 13, 2017

Copy link
Copy Markdown
Contributor

@indus

indus commented Dec 13, 2017

Copy link
Copy Markdown
Contributor Author

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

bartvde commented Dec 13, 2017

Copy link
Copy Markdown
Contributor

@systemed

Copy link
Copy Markdown

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
Copy Markdown

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 mollymerp mentioned this pull request Jun 21, 2018
1 task done
@mollymerp

Copy link
Copy Markdown
Contributor

@eugeneYWang I just opened a PR adding this to the docs #6847

Comment thread js/source/tile_coord.js
.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);

Copy link
Copy Markdown

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?

@indus indus Dec 29, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown

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