Even & Klokan, 1/ Thanks for your comments and link. The light has dawned, and I've now understood the differences in tile naming between TMS and XYZ tilsets.
I edited the overlays.html created by gdal2tiles.py to use both OpenLayers.Layer.TMS and OpenLayers.Layer.XYZ. Rather than create a 'proper' XYZ tileset, I created a function xyz_getTileURL to allow OpenLayers.Layer.XYZ to read from a TMS tileset. As it might be of interest for others struggling to understand this stuff, I attach it below. Or look at the source on: http://pgg999.freehostingcloud.com/tiles4_srtm/openlayers.xyz.html xyz_getTileURL is just a modification of the existing osm_getTileURL & overlay_getTileURL, with Klokan's formula y = (2^z - 1) - y used to convert the TMS Y to the XYZ Y 2/ I noted that overlays.html calls: http://www.openlayers.org/api/2.7/OpenLayers.js This doesn't seem to support Openlayers.Layer.XYZ Maybe a future version of gdaltiles.py could instead reference a newer version of Openlayers. e.g. http://www.openlayers.org/api/2.11/OpenLayers.js Cheers, Peter // create XYZ Overlay layer // This is an exercise for me to use Openlayers.Layer.XYZ, and write my own getURL function. // (The TMS tileset was created by gdal2tiles.py. // So need to convert from the TMS URL to XYZ URL with xyz_getTileURL) // Using a ZXY tileset then "getURL: xyz_getTileURL" is not needed and // the URL would be simply "http://pgg999.freehostingcloud.com/tiles4_srtm/${z}/${x}/${y}.png" var tiles4_srtm = new OpenLayers.Layer.XYZ("OpenLayers.Layer.XYZ", "http://pgg999.freehostingcloud.com/tiles4_srtm/", { type: 'png', getURL: xyz_getTileURL, alpha: true, isBaseLayer: false }); //This function allows a TMS tileset to be used with OpenLayers.Layer.XYZ function xyz_getTileURL(bounds) { var res = this.map.getResolution(); var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w)); var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h)); var z = this.map.getZoom(); var limit = Math.pow(2, z); if (mapBounds.intersectsBounds( bounds ) && z >= mapMinZoom && z <= mapMaxZoom ) { x = ((x % limit) + limit) % limit; y = Math.pow(2,z) - y - 1; return this.url + z + "/" + x + "/" + y + "." + this.type; } else { return "http://www.maptiler.org/img/none.png"; } } -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/gdal2tiles-tiles-in-wrong-hemisphere-and-or-Openlayers-problem-tp6983306p6989780.html Sent from the GDAL - Dev mailing list archive at Nabble.com. _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
