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

PrintProvider: TMS requires encoding of tileOrigin #83

Open
justb4 opened this issue Oct 6, 2013 · 4 comments
Open

PrintProvider: TMS requires encoding of tileOrigin #83

justb4 opened this issue Oct 6, 2013 · 4 comments

Comments

@justb4
Copy link
Contributor

justb4 commented Oct 6, 2013

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:
mapfish/mapfish-print#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.

@bartvde
Copy link
Member

bartvde commented Oct 7, 2013

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

@justb4
Copy link
Contributor Author

justb4 commented Oct 7, 2013

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

@bartvde
Copy link
Member

bartvde commented Oct 7, 2013

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

@jbjonesjr
Copy link

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.

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

3 participants