Changeset 3858

Show
Ignore:
Timestamp:
11/02/11 23:20:25 (7 months ago)
Author:
theuer
Message:

svgFactor fix, more sensible formula, but only if integerSvg: true, otherwise svgFactor is not needed and defaults to 1.0, improves performance; r=jeichar (closes #648)

Location:
print/trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • print/trunk

    • Property svn:ignore
      •  

        old new  
        33build 
        44target 
         5.project 
         6.classpath 
         7.git 
         8deploy.sh 
         9build_and_deploy.sh 
         10lib 
         11build.sh 
         12bin 
         13.settings 
         14 
  • print/trunk/docs/configuration.txt

    r3856 r3858  
    1212    - 190 
    1313    {...} 
     14 
     15  ?maxSvgWidth: 2048 # set the maximum dimensions to 2048 points, this is useful when using MapServer and a maximum dimension is there 
     16  ?maxSvgHeight: 2048 
     17  ?integerSvg: false # the library in MapServer <= 5.6 does not support floating point values in the SVG coordinate space, set this to true if using a WMS that does not support floating point values in SVG coordinates 
     18 
    1419  ?outputFormats: 
    1520    - pdf 
  • print/trunk/src/main/java/org/mapfish/print/Transformer.java

    r3789 r3858  
    3535 */ 
    3636public class Transformer implements Cloneable { 
    37         private static final String GOOGLE_WKT = "PROJCS[\"Google Mercator\"," 
    38                 + "GEOGCS[\"WGS 84\"," 
    39                 + "DATUM[\"World Geodetic System 1984\"," 
    40                 + "SPHEROID[\"WGS 84\", 6378137.0, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]]," 
    41                 + "AUTHORITY[\"EPSG\",\"6326\"]]," 
    42                 + "PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]]," 
    43                 + "UNIT[\"degree\", 0.017453292519943295]," 
    44                 + "AXIS[\"Geodetic latitude\", NORTH]," 
    45                 + "AXIS[\"Geodetic longitude\", EAST]," 
    46                 + "AUTHORITY[\"EPSG\",\"4326\"]]," 
    47                 + "PROJECTION[\"Mercator_1SP\"]," 
    48                 + "PARAMETER[\"semi_minor\", 6378137.0]," 
    49                 + "PARAMETER[\"latitude_of_origin\", 0.0]," 
    50                 + "PARAMETER[\"central_meridian\", 0.0]," 
    51                 + "PARAMETER[\"scale_factor\", 1.0]," 
    52                 + "PARAMETER[\"false_easting\", 0.0]," 
    53                 + "PARAMETER[\"false_northing\", 0.0]," 
    54                 + "UNIT[\"m\", 1.0]," + "AXIS[\"Easting\", EAST]," 
    55                 + "AXIS[\"Northing\", NORTH]," 
    56                 + "AUTHORITY[\"EPSG\",\"900913\"]]"; 
    57  
    58          
    59          
    60     private int svgFactor; 
     37    private static final String GOOGLE_WKT = "PROJCS[\"Google Mercator\"," 
     38            + "GEOGCS[\"WGS 84\"," 
     39            + "DATUM[\"World Geodetic System 1984\"," 
     40            + "SPHEROID[\"WGS 84\", 6378137.0, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]]," 
     41            + "AUTHORITY[\"EPSG\",\"6326\"]]," 
     42            + "PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]]," 
     43            + "UNIT[\"degree\", 0.017453292519943295]," 
     44            + "AXIS[\"Geodetic latitude\", NORTH]," 
     45            + "AXIS[\"Geodetic longitude\", EAST]," 
     46            + "AUTHORITY[\"EPSG\",\"4326\"]]," 
     47            + "PROJECTION[\"Mercator_1SP\"]," 
     48            + "PARAMETER[\"semi_minor\", 6378137.0]," 
     49            + "PARAMETER[\"latitude_of_origin\", 0.0]," 
     50            + "PARAMETER[\"central_meridian\", 0.0]," 
     51            + "PARAMETER[\"scale_factor\", 1.0]," 
     52            + "PARAMETER[\"false_easting\", 0.0]," 
     53            + "PARAMETER[\"false_northing\", 0.0]," + "UNIT[\"m\", 1.0]," 
     54            + "AXIS[\"Easting\", EAST]," + "AXIS[\"Northing\", NORTH]," 
     55            + "AUTHORITY[\"EPSG\",\"900913\"]]"; 
     56 
     57    private float svgFactor = 1.0f; 
    6158    public float minGeoX; 
    6259    public float minGeoY; 
     
    7774 
    7875    /** 
     76     * @param centerX 
     77     *            geographic center in projection - x 
     78     * @param centerY 
     79     *            geographic center in projection - y 
     80     * @param paperWidth 
     81     *            e.g. map width in pt on the PDF 
     82     * @param paperHeight 
     83     *            e.g. map height in pt on the PDF 
     84     * @param scale 
     85     *            e.g. 10000 if scale is 1:10,000 
     86     * @param dpi 
     87     *            as selected in request 
     88     * @param unitEnum 
     89     *            the distance unit of the map e.g. DistanceUnit.M for meters 
     90     * @param rotation 
     91     *            the rotation of the map per the request 
    7992     * @param geodeticSRS 
    8093     *            if not null then it is a the srs to use with the geodetic 
     
    8396    public Transformer(float centerX, float centerY, float paperWidth, 
    8497            float paperHeight, int scale, int dpi, DistanceUnit unitEnum, 
    85             double rotation, String geodeticSRS) { 
     98            double rotation, String geodeticSRS, RenderingContext context) { 
    8699        this.dpi = dpi; 
    87100        pixelPerGeoUnit = (float) (unitEnum.convertTo(dpi, DistanceUnit.IN) / scale); 
     
    90103        float geoHeight = paperHeight * dpi / 72.0f / pixelPerGeoUnit; 
    91104 
    92         //target at least 600DPI for the SVG precision 
    93         svgFactor = Math.max((600 + dpi - 1) / dpi, 1); 
     105        /** 
     106         * The following code has been changed due to the fact that it seems 
     107         * wrong. However, I'm not sure if my "correction" solves the problem 
     108         * for the better. So, please review. 
     109         *  
     110         * The ('wrong') code below can be reformed: (600 + dpi - 1) / dpi = 1 + 
     111         * 599/dpi and is never smaller than 1, since dpi>1. Also, it does not 
     112         * make sense, as this factor gets smaller with increasing values for 
     113         * dpi. 
     114         */ 
     115        // target at least 600DPI for the SVG precision 
     116        // svgFactor = Math.max((600 + dpi - 1) / dpi, 1); 
     117 
     118        /** 
     119         * svgFactor seems to not matter so much so we set it to 1 (above) needs 
     120         * to get bigger if DPI increases and at standard 72 DPI needs to be 1.0 
     121         */ 
     122        if (context.getConfig().getIntegerSvg()) { // integerSvg: true # in yaml 
     123                                                   // config file 
     124            if (dpi < 600) { // target at least 600 DPI, this is a hack and only 
     125                             // needed for MapServer <= 5.6 where integers 
     126                             // are put into SVG 
     127                svgFactor = 600f / 72.0f; 
     128                /** 
     129                 * = 8.33 so almost 9 as before with svgFactor being (600 + dpi 
     130                 * -1)/dpi = ~9 if dpi = 72 
     131                 */ 
     132            } else { 
     133                svgFactor = dpi / 72.0f; // gets greater than 8.33 
     134            } 
     135        } // else defaults to 1.0 as it should with MapServer >= 6 and CAIRO SVG 
     136          // rendering with floating point values 
    94137 
    95138        this.paperWidth = paperWidth; 
     
    97140        this.scale = scale; 
    98141        this.rotation = rotation; 
    99          
     142 
    100143        if (geodeticSRS != null) { 
    101144            computeGeodeticBBox(geoWidth, geoHeight, centerX, centerY, dpi, 
     
    163206        if (rotation != 0.0) { 
    164207            double height = getStraightBitmapH(); 
    165             width = Math.abs(width * Math.cos(rotation)) + Math.abs(height * Math.sin(rotation)); 
     208            width = Math.abs(width * Math.cos(rotation)) 
     209                    + Math.abs(height * Math.sin(rotation)); 
    166210        } 
    167211        return Math.round(width); 
     
    172216        if (rotation != 0.0) { 
    173217            double width = getStraightBitmapW(); 
    174             height = Math.abs(height * Math.cos(rotation)) + Math.abs(width * Math.sin(rotation)); 
     218            height = Math.abs(height * Math.cos(rotation)) 
     219                    + Math.abs(width * Math.sin(rotation)); 
    175220        } 
    176221        return Math.round(height); 
     
    181226        if (rotation != 0.0) { 
    182227            float height = getGeoH(); 
    183             width = (float) (Math.abs(width * Math.cos(rotation)) + Math.abs(height * Math.sin(rotation))); 
     228            width = (float) (Math.abs(width * Math.cos(rotation)) + Math 
     229                    .abs(height * Math.sin(rotation))); 
    184230        } 
    185231        return width; 
     
    190236        if (rotation != 0.0) { 
    191237            float width = getGeoW(); 
    192             height = (float) (Math.abs(height * Math.cos(rotation)) + Math.abs(width * Math.sin(rotation))); 
     238            height = (float) (Math.abs(height * Math.cos(rotation)) + Math 
     239                    .abs(width * Math.sin(rotation))); 
    193240        } 
    194241        return height; 
     
    199246        if (rotation != 0.0) { 
    200247            float height = getPaperH(); 
    201             width = (float) (Math.abs(width * Math.cos(rotation)) + Math.abs(height * Math.sin(rotation))); 
     248            width = (float) (Math.abs(width * Math.cos(rotation)) + Math 
     249                    .abs(height * Math.sin(rotation))); 
    202250        } 
    203251        return width; 
     
    208256        if (rotation != 0.0) { 
    209257            float width = getPaperW(); 
    210             height = (float) (Math.abs(height * Math.cos(rotation)) + Math.abs(width * Math.sin(rotation))); 
     258            height = (float) (Math.abs(height * Math.cos(rotation)) + Math 
     259                    .abs(width * Math.sin(rotation))); 
    211260        } 
    212261        return height; 
     
    230279 
    231280    public long getRotatedSvgW() { 
    232         return getRotatedBitmapW() * svgFactor; 
     281        return (long) (getRotatedBitmapW() * svgFactor); 
    233282    } 
    234283 
    235284    public long getRotatedSvgH() { 
    236         return getRotatedBitmapH() * svgFactor; 
     285        return (long) (getRotatedBitmapH() * svgFactor); 
    237286    } 
    238287 
     
    271320     */ 
    272321    public AffineTransform getBaseTransform() { 
    273         final AffineTransform result = AffineTransform.getTranslateInstance(paperPosX, paperPosY); 
     322        final AffineTransform result = AffineTransform.getTranslateInstance( 
     323                paperPosX, paperPosY); 
    274324        if (rotation != 0.0F) { 
    275325            result.translate(getPaperW() / 2, getPaperH() / 2); 
     
    281331 
    282332    /** 
    283      * @param reverseRotation True to do the rotation in the other direction 
    284      * @return The affine transformation to go from geographic coordinated to paper coordinates 
     333     * @param reverseRotation 
     334     *            True to do the rotation in the other direction 
     335     * @return The affine transformation to go from geographic coordinated to 
     336     *         paper coordinates 
    285337     */ 
    286338    public AffineTransform getGeoTransform(boolean reverseRotation) { 
    287         final AffineTransform result = AffineTransform.getTranslateInstance(paperPosX, paperPosY); 
     339        final AffineTransform result = AffineTransform.getTranslateInstance( 
     340                paperPosX, paperPosY); 
    288341        if (rotation != 0.0F) { 
    289             result.rotate((reverseRotation ? -1 : 1) * rotation, getPaperW() / 2, getPaperH() / 2); 
     342            result.rotate((reverseRotation ? -1 : 1) * rotation, 
     343                    getPaperW() / 2, getPaperH() / 2); 
    290344        } 
    291345        result.scale(getPaperW() / getGeoW(), getPaperH() / getGeoH()); 
     
    296350    public AffineTransform getSvgTransform() { 
    297351        final AffineTransform result = getBaseTransform(); 
    298         result.scale(getPaperW() / getStraightSvgW(), getPaperH() / getStraightSvgH()); 
     352        result.scale(getPaperW() / getStraightSvgW(), getPaperH() 
     353                / getStraightSvgH()); 
    299354        return result; 
    300355    } 
     
    302357    public AffineTransform getPdfTransform() { 
    303358        final AffineTransform result = getBaseTransform(); 
    304         result.scale(getPaperW() / getStraightBitmapW(), getPaperH() / getStraightBitmapH()); 
     359        result.scale(getPaperW() / getStraightBitmapW(), getPaperH() 
     360                / getStraightBitmapH()); 
    305361        return result; 
    306362    } 
     
    318374        float destH = mainTransformer.getGeoH() / factor; 
    319375 
    320         //fix aspect ratio 
     376        // fix aspect ratio 
    321377        if (destW / destH > getGeoW() / getGeoH()) { 
    322378            destH = getGeoH() * destW / getGeoW(); 
     
    358414    } 
    359415 
    360     public int getSvgFactor() { 
     416    public float getSvgFactor() { 
    361417        return svgFactor; 
    362418    } 
  • print/trunk/src/main/java/org/mapfish/print/config/Config.java

    r3831 r3858  
    6868    private double maxSvgH = Double.MAX_VALUE; 
    6969     
     70    private boolean integerSvg = true; 
     71     
    7072    private List<String> overlayLayers = null; 
    7173     
     
    428430      return overlayLayers; 
    429431    } 
     432 
     433        /** 
     434         * @return the integerSvg true if for example MapServer 5.6 or earlier is used where integers are put into the SVG 
     435         */ 
     436        public boolean getIntegerSvg() { 
     437                return integerSvg; 
     438        } 
     439 
     440        /** 
     441         * @param integerSvg the integerSvg to set 
     442         */ 
     443        public void setIntegerSvg(boolean integerSvg) { 
     444                this.integerSvg = integerSvg; 
     445        } 
    430446} 
  • print/trunk/src/main/java/org/mapfish/print/config/layout/MapBlock.java

    r3828 r3858  
    149149        double rotation = params.optFloat("rotation", 0.0F) * Math.PI / 180.0; 
    150150        return new Transformer(centerX, centerY, width, height, scale, dpi, 
    151                 unitEnum, rotation, srs); 
     151                unitEnum, rotation, srs, context); 
    152152    } 
    153153 
  • print/trunk/src/main/java/org/mapfish/print/map/renderers/SVGTileRenderer.java

    r3826 r3858  
    142142    private TranscoderInput getTranscoderInput(URL url, Transformer transformer, RenderingContext context) { 
    143143        final float zoomFactor = transformer.getSvgFactor() * context.getStyleFactor(); 
     144        //final float zoomFactor = context.getStyleFactor(); 
    144145        if (svgZoomOut != null && zoomFactor != 1.0f) { 
    145146                javax.xml.transform.Transformer xslt = null; 
  • print/trunk/src/main/webapp

    • Property svn:ignore set to
      test.yaml
      test.html
      environment_theme.yaml
      config2.yaml
      configVector.yaml
      smap.yaml
      portal.yaml
      configPremiumGoogle.yaml
      config.yaml.bak
      vector.html
      oe.html
      Copy of configVector.yaml
      configNonPremiumGoogle.yaml