Ticket #562: printProtocol_WMSPostLayer.patch

File printProtocol_WMSPostLayer.patch, 2.7 kB (added by gislars, 2 years ago)
  • client/mfbase/mapfish/core/PrintProtocol.js

     
    451451    }, 
    452452 
    453453    /** 
     454     * Method: convertWMSPostLayer 
     455     * 
     456     * Builds the layer configuration from an {<OpenLayers.Layer.WMS.Post>} layer. 
     457     * The structure expected from the print module is: 
     458     * (start code) 
     459     * { 
     460     *   type: 'WMS' 
     461     *   baseURL: {String} 
     462     *   layers: [{String}] 
     463     *   styles: [{String}] 
     464     *   format: {String} 
     465     *   opacity: {Float} 
     466     *   singleTile: {boolean} 
     467     *   customParams: { 
     468     *     {String}: {String} 
     469     *   } 
     470     * } 
     471     * (end) 
     472     * 
     473     * Parameters: 
     474     * olLayer - {<OpenLayers.Layer.WMS.Post>} The OL layer. 
     475     * 
     476     * Returns: 
     477     * {Object} The config for this layer 
     478     */ 
     479    convertWMSPostLayer: function(olLayer) { 
     480        var layer = OpenLayers.Util.extend(this.convertLayer(olLayer), 
     481        { 
     482            type: 'WMS', 
     483            layers: mapfish.Util.fixArray(olLayer.params.LAYERS), 
     484            format: olLayer.params.FORMAT || olLayer.DEFAULT_PARAMS.format, 
     485            styles: mapfish.Util.fixArray(olLayer.params.STYLES || 
     486                                          olLayer.DEFAULT_PARAMS.styles) 
     487        }); 
     488        for (var paramName in olLayer.params) { 
     489            var paramNameLow = paramName.toLowerCase(); 
     490            if (olLayer.DEFAULT_PARAMS[paramNameLow] == null && 
     491                paramNameLow != 'layers' && 
     492                paramNameLow != 'width' && 
     493                paramNameLow != 'height' && 
     494                paramNameLow != 'srs') { 
     495                layer.customParams[paramName] = olLayer.params[paramName]; 
     496            } 
     497        } 
     498        return layer; 
     499    }, 
     500 
     501    /** 
    454502     * Method: convertMapServerLayer 
    455503     * 
    456504     * Builds the layer configuration from an {<OpenLayers.Layer.MapServer>} layer. 
     
    771819mapfish.PrintProtocol.SUPPORTED_TYPES = { 
    772820    'OpenLayers.Layer': mapfish.PrintProtocol.IGNORED, 
    773821    'OpenLayers.Layer.WMS': mapfish.PrintProtocol.prototype.convertWMSLayer, 
     822    'OpenLayers.Layer.WMS.Post': mapfish.PrintProtocol.prototype.convertWMSPostLayer, 
    774823    'mapfish.Layer.SwitchableWMS': mapfish.PrintProtocol.prototype.convertSwitchableWMSLayer, 
    775824    'OpenLayers.Layer.WMS.Untiled': mapfish.PrintProtocol.prototype.convertWMSLayer, 
    776825    'OpenLayers.Layer.TileCache': mapfish.PrintProtocol.prototype.convertTileCacheLayer, 
     
    783832    'OpenLayers.Layer.MapServer.Untiled': mapfish.PrintProtocol.prototype.convertMapServerLayer, 
    784833    'OpenLayers.Layer.Image': mapfish.PrintProtocol.prototype.convertImageLayer 
    785834}; 
    786