Changeset 3592 for framework

Show
Ignore:
Timestamp:
07/21/10 11:03:18 (22 months ago)
Author:
aabt
Message:

Add ability to configure print widgets/protocol with geodetic param(boolean, default to false), to fix wrong calculation of print extent for geodedic projection. r=jeichar (closes #571)

Location:
framework/client/trunk/mfbase/mapfish
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • framework/client/trunk/mfbase/mapfish/core/PrintProtocol.js

    r3522 r3592  
    7979 
    8080    /** 
     81     * APIProperty: geodetic 
     82     * {Boolean} True if the projection is geodetic, for a correct scale 
     83     * calculation. 
     84     */ 
     85    geodetic: false, 
     86 
     87    /** 
    8188     * Constructor: OpenLayers.Layer 
    8289     * 
     
    8996     * params - {Object} additional params to send in the Ajax calls 
    9097     */ 
    91     initialize: function(map, config, overrides, dpi, params) { 
     98    initialize: function(map, config, overrides, dpi, params, geodetic) { 
    9299        this.config = config; 
    93100        this.spec = {pages: []}; 
    94101        overrides = this.fixOverrides(overrides, map); 
     102        this.geodetic = (geodetic != undefined) ? geodetic : this.geodetic; 
    95103        this.addMapParams(overrides, map, dpi); 
    96104        this.addOverviewMapParams(overrides, map, dpi); 
     
    278286        spec.units = map.baseLayer.units; 
    279287        spec.srs = map.baseLayer.projection.getCode(); 
     288        spec.geodetic = this.geodetic; 
    280289        var layers = spec.layers = []; 
    281290        this.fillLayers(layers, map.layers, overrides, dpi); 
  • framework/client/trunk/mfbase/mapfish/widgets/print/Base.js

    r3084 r3592  
    9898 
    9999    /** 
     100     * APIProperty: geodetic 
     101     * {Boolean} True if the projection is geodetic, for a correct scale 
     102     * calculation. 
     103     */ 
     104    geodetic: false, 
     105 
     106    /** 
    100107     * Method: initPrint 
    101108     * loads the configuration 
     
    155162 
    156163        var printCommand = new mapfish.PrintProtocol(this.map, this.config, 
    157                 this.overrides, this.getCurDpi(), this.serviceParams); 
     164                this.overrides, this.getCurDpi(), this.serviceParams, this.geodetic); 
    158165        if (this.layerTree) { 
    159166            this.addLegends(printCommand.spec); 
  • framework/client/trunk/mfbase/mapfish/widgets/print/BaseWidget.js

    r3084 r3592  
    2525 * @requires OpenLayers/Layer/Vector.js 
    2626 * @requires OpenLayers/Feature/Vector.js 
     27 * @requires OpenLayers/Geometry/Polygon.js 
     28 * @requires OpenLayers/Util.js 
     29 * @requires OpenLayers/Projection.js 
    2730 * @requires OpenLayers/Geometry/Polygon.js 
    2831 */ 
     
    414417        var unitsRatio = OpenLayers.INCHES_PER_UNIT[this.map.baseLayer.units]; 
    415418 
    416         var size = layout.map; 
    417         var w = size.width / 72.0 / unitsRatio * scale / 2.0; 
    418         var h = size.height / 72.0 / unitsRatio * scale / 2.0; 
     419        var w = layout.map.width / 72.0 / unitsRatio * scale / 2.0; 
     420        var h = layout.map.height / 72.0 / unitsRatio * scale / 2.0; 
     421 
     422        var proj = this.map.getProjectionObject(); 
     423        if (this.geodetic && (proj.projCode != 'EPGS:4326')) { 
     424            var wgs84 = new OpenLayers.Projection('EPSG:4326'); 
     425            var wgs84center = center.clone().transform(proj, wgs84); 
     426 
     427            var dest = OpenLayers.Util.destinationVincenty; 
     428            var wp1 = dest(wgs84center, 90, w); 
     429            var wp2 = dest(wgs84center, 270, w); 
     430            var hp1 = dest(wgs84center, 0, h); 
     431            var hp2 = dest(wgs84center, 180, h); 
     432 
     433            var p = OpenLayers.Geometry.Point; 
     434            var bounds = new OpenLayers.Geometry.Polygon([ 
     435                new OpenLayers.Geometry.LinearRing([ 
     436                    new p(wp1.lon, wp1.lat), new p(hp2.lon, hp2.lat), 
     437                    new p(wp2.lon, wp2.lat), new p(hp1.lon, hp1.lat) 
     438                ]) 
     439            ]).getBounds(); 
     440 
     441            return bounds.transform(wgs84, proj); 
     442        } 
    419443 
    420444        return new OpenLayers.Bounds( 
    421                 center.lon - w, 
    422                 center.lat - h, 
    423                 center.lon + w, 
    424                 center.lat + h); 
     445            center.lon - w, 
     446            center.lat - h, 
     447            center.lon + w, 
     448            center.lat + h 
     449        ); 
    425450    }, 
    426451