Changeset 3829

Show
Ignore:
Timestamp:
07/01/11 11:35:51 (11 months ago)
Author:
sbrunner
Message:

fix Add Mapserver map_angle to Wms Map? r=jesse,alex (closes #624)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • print/trunk/src/main/java/org/mapfish/print/map/readers/WMSMapReader.java

    r3789 r3829  
    3030import org.pvalsecc.misc.StringUtils; 
    3131import org.pvalsecc.misc.URIUtils; 
     32import org.apache.log4j.Logger; 
    3233 
    3334import java.io.UnsupportedEncodingException; 
     
    4445 */ 
    4546public class WMSMapReader extends TileableMapReader { 
     47    public static final Logger LOGGER = Logger.getLogger(WMSMapReader.class); 
    4648    private final String format; 
    4749    protected final List<String> layers = new ArrayList<String>(); 
     
    6971    public void render(Transformer transformer, ParallelMapTileLoader parallelMapTileLoader, String srs, boolean first) { 
    7072        PJsonObject customParams = params.optJSONObject("customParams"); 
    71         if (customParams != null) { 
    72             // native WMS rotation - only works in singleTile mode 
    73             if (customParams.optString("angle") != null) { 
     73         
     74        // store the rotation to not change for other layers 
     75        double oldAngle = transformer.getRotation(); 
     76 
     77        // native WMS rotation - only works in singleTile mode 
     78        if (customParams != null && customParams.optString("angle") != null) { // For GeoServer 
     79            transformer.setRotation(0); 
     80        } 
     81        if (params.optBool("useNativeAngle", false)) { 
     82            String angle = String.valueOf(-Math.toDegrees(transformer.getRotation())); 
     83            try { 
     84                if (customParams != null) { 
     85                    customParams.getInternalObj().put("angle", angle); // For GeoServer 
     86                    customParams.getInternalObj().put("map_angle", angle); // For MapServer 
     87                } 
     88                else { 
     89                    Map customMap = new HashMap(); 
     90                    customMap.put("angle", angle); // For GeoServer 
     91                    customMap.put("map_angle", angle); // For MapServer 
     92                    params.getInternalObj().put("customParams", customMap); 
     93                } 
    7494                transformer.setRotation(0); 
    7595            } 
    76         } 
    77  
     96            catch (org.json.JSONException e) { 
     97                LOGGER.error("Unable to set angle: " + e.getClass().getName() + " - " + e.getMessage()); 
     98            } 
     99        } 
    78100        super.render(transformer, parallelMapTileLoader, srs, first); 
     101        // restore the rotation for other layers 
     102        transformer.setRotation(oldAngle); 
    79103    } 
    80104