geoext1 icon indicating copy to clipboard operation
geoext1 copied to clipboard

PrintProvider: TMS requires encoding of tileOrigin

Open justb4 opened this issue 11 years ago • 4 comments

Recent versions of MapFish Print (at least from june 2013 onward) take the TMS tileOrigin into account when rendering print output on "create". The current GeoExt encoder in PrintProvider.js does not take this into account. I have fixed this by extending the TileCache base encoder (called by the TMS encoder) as follows:

        "TileCache": function (layer) {
            var enc = this.encoders.layers.HTTPRequest.call(this, layer);
            // Heron fix JvdB 6 oct 2013
            // Add tileOrigin otherwise MapFish Print will be confused.
            // https://github.com/mapfish/mapfish-print/issues/68
            var maxExtent = layer.maxExtent.toArray();
            var tileOriginX = layer.tileOrigin ? layer.tileOrigin.lon : maxExtent[0];
            var tileOriginY = layer.tileOrigin ? layer.tileOrigin.lat : maxExtent[1];
            return Ext.apply(enc, {
                type: 'TileCache',
                layer: layer.layername,
                maxExtent: maxExtent,
                tileOrigin: {x: tileOriginX, y: tileOriginY},
                tileSize: [layer.tileSize.w, layer.tileSize.h],
                extension: layer.extension,
                resolutions: layer.serverResolutions || layer.resolutions
            });
        },

So "tileOrigin" is determined from the TMS tileOrigin if provided or the Map/Layer maxExtent LL coords. Yes the tileOrigin should be encoded as an Object with either x,y or lon,lat. Possibly needs refinement. According to the TMS spec (wiki) tileOrigin may be independently defined from maxExtent.

This came out from a longstanding MapFish Print issue: https://github.com/mapfish/mapfish-print/issues/68

See code at bottom of: https://code.google.com/p/geoext-viewer/source/browse/trunk/heron/lib/override-geoext.js but I can provide a pull if neccessary.

justb4 avatar Oct 06 '13 20:10 justb4

@justb4 please turn this into a PR, can you also make sure it doesn't break anything for older version of MapFish print?

bartvde avatar Oct 07 '13 07:10 bartvde

Ok, will be end of the week, now busy with talks etc.

justb4 avatar Oct 07 '13 07:10 justb4

no problem, no rush. Good luck with the talks!

bartvde avatar Oct 07 '13 07:10 bartvde

As the author of the mapfish-print tile origin patches, I can verify that specifying the tile origin from the layer in this manner is ok ( I have a local fork that does just this).

I also fashioned mapfish's implementation off of OpenLayers tile origin strategy, so everything should be compatible.

jbjonesjr avatar Oct 07 '13 22:10 jbjonesjr