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

TMS with XYZ source #3923

Closed
probins opened this issue Jul 25, 2015 · 9 comments
Closed

TMS with XYZ source #3923

probins opened this issue Jul 25, 2015 · 9 comments

Comments

@probins
Copy link
Contributor

probins commented Jul 25, 2015

I have a tile source with a standard z/x/y url pattern, but with bottom-left 0/0, i.e. like TMS. This loads fine using a simple TileImage:

      source: new ol.source.TileImage({
        projection: 'EPSG:3035',
        tileGrid: new ol.tilegrid.TileGrid({
          extent: [2409891.715, 1328424.080, 6143417.136, 5330401.505],
          tileSize: [200, 200],
          origin: [2409891.715, 1328424.080],
          resolutions: [4000, 3000, 2000, 1000]
        }),
        tileUrlFunction: function(coordinate) {
          return 'http://map-loader.appspot.com/srtm3035/'+coordinate[0]+
              '/'+ coordinate[1] +'/'+ coordinate[2] +'.png';
        }
      })

The current docs for XYZ state "Layer source for tile data with URLs in a set XYZ format", which this is, so it ought to work with XYZ too, using the url pattern instead of tileUrlFunction. But it doesn't, whether using y or -y (I suspect the bitwise operator in createFromTemplate is causing the problem here). This is not necessarily a problem, as I can always use TileImage, but if XYZ can't handle some zxy sources, this should be documented.

I also think that the rather confusing area of tile origins needs to be better documented in the api docs, for example, that XYZ and WMTS grids are by default top-left, and that you use -y with XYZ for a bottom-left origin.

@ahocevar
Copy link
Member

-y - 1 should work. Also note that you don't need a tileUrlFunction. Just use the {-y} placeholder in the url.

@ahocevar
Copy link
Member

Also you should leave out the origin from the tile grid configuration, or use the top left corner instead of the bottom left one.

@probins
Copy link
Contributor Author

probins commented Jul 27, 2015

but how would -y-1 be defined in the template? AFAICS there's only a regex for y and -y. The xyz-esri-4326-512 example uses both a template and a tileurlfunction, which seems over-complicated - easier to use TileImage directly, I would have thought

@ahocevar
Copy link
Member

Yes, and {-y} in the template causes the -y-1 calculation. The ESRI example uses a tile Url function because there is a z offset.

@probins
Copy link
Contributor Author

probins commented Jul 27, 2015

none of these work. Here a fiddle:

@ahocevar
Copy link
Member

You're right. I just looked at the code and saw that {-y} only works with a standard XYZ tile grid. Any suggestions for documentation improvements?

@probins
Copy link
Contributor Author

probins commented Jul 28, 2015

if you like, we could add this source to the examples as an example of TMS. It was originally a tilecache layer, but I squashed the directories and renamed the files to make it a TMS pattern. I would just change the url to https as appspot now supports http/2 which should speed up loading of tiles

@ahocevar
Copy link
Member

That would be a great addition to the examples collection. Thanks in advance!

@ahocevar
Copy link
Member

Fixed with #3929.

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

No branches or pull requests

2 participants