# Calculating extent of custom tiles?

Problem

The picture is just an example of my case, but I am left with blank space on the left when I load all the tiles and I get error message in the console:

``````Failed to load resource: the server responded with a status of 404 (Not Found)
http://path/to/the/tile//base/8/6/53.png
etc.
``````

I could guess and limit the extent of the layer, but I would really like to know is there any way to calculate it and also be able to get rid of the error message.

What I know about the tiles?

• Originally they are served as TMS
• They represent png images 256*256
• They are in projection: EPSG:3857
• In OpenLayers2 they were called like TMS layer
• In OpenLayers3 (v.3.8.2) they are called like XYZ layer (that includes `-y`):

``````var baseLayer = new ol.layer.Tile({
source: new ol.source.XYZ({
url: 'http://path/to/the/tiles/base/{z}/{x}/{-y}.png'
})
});
``````

Thoughts and questions

1. How can I calculate extent of the tiles? Or in another words how can I find out zmin zmax xmin ymin xmax ymax or whole range of x/y?
2. What does x/y really represent? Are they coordinates of the left bottom corner or center of the tile?
3. In which direction does x/y increase?
4. How can I figure out x/y of at least one of the tile, for example left bottom one?

(I have modified the question for better understanding of the problem)

• A bit hard to know without knowing where the tiles come from, what projection they are in, etc. Is this some custom wmts, xyz or some such? – John Powell Sep 21 '16 at 6:16
• Hi! Thanks for mentioning that. I have edited my question. – vayacondios2015 Sep 21 '16 at 13:51
• Do you really have a -y inside the brackets? if not, then you are dealing with regular XYZ tiles. See this page for getting the extent of the tiles: wiki.openstreetmap.org/wiki/Slippy_map_tilenames – Devdatta Tengshe Sep 21 '16 at 15:07
• @DevdattaTengshe I am not an expert on this subject, and I am trying to figure out how tiles are set, but I can see that it doesnt work when I have +y, and it works when I have -y. I have also found this: Tile Map Service: an early standard supported by OpenLayers. One difference is the y axis is positive southwards in TMS, and northwards in OpenStreetMap. (reference: en.wikipedia.org/wiki/Tiled_web_map) – vayacondios2015 Sep 21 '16 at 15:24
• gdaltindex will give you the geometries of numerous images http://www.gdal.org/gdaltindex.html. I'm not sure how you would incorporate this into the above but it could be a useful reference point for you at least – ProudGIS Sep 21 '16 at 16:36