Changeset 4857 in josm


Ignore:
Timestamp:
23.01.2012 00:31:51 (4 months ago)
Author:
bastiK
Message:

fixed #7073 - Sicily WMS url error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java

    r4745 r4857  
    8686            int wi, int ht) throws MalformedURLException { 
    8787        String myProj = Main.getProjection().toCode(); 
    88         if((Main.getProjection() instanceof Mercator) && !info.getServerProjections().contains(myProj)) { 
     88        if (!info.getServerProjections().contains(myProj) && (Main.getProjection() instanceof Mercator)) { 
    8989            LatLon sw = Main.getProjection().eastNorth2latlon(new EastNorth(w, s)); 
    9090            LatLon ne = Main.getProjection().eastNorth2latlon(new EastNorth(e, n)); 
     
    9595            e = ne.lon(); 
    9696        } 
    97  
     97        if (myProj.equals("EPSG:4326") && !info.getServerProjections().contains(myProj) && info.getServerProjections().contains("CRS:84")) { 
     98            myProj = "CRS:84"; 
     99        } 
     100 
     101        // Bounding box coordinats have to be switched for WMS 1.3.0 EPSG:4326. 
     102        // 
     103        // Background: 
     104        // 
     105        // bbox=x_min,y_min,x_max,y_max 
     106        // 
     107        //      SRS=... is WMS 1.1.1 
     108        //      CRS=... is WMS 1.3.0 
     109        // 
     110        // The difference: 
     111        //      For SRS x is east-west and y is north-south 
     112        //      For CRS x and y are as specified by the EPSG 
     113        //          E.g. [1] lists lat as first coordinate axis and lot as second, so it is switched for EPSG:4326. 
     114        //          For most other EPSG code there seems to be no difference. 
     115        // [1] http://www.epsg-registry.org/report.htm?type=selection&entity=urn:ogc:def:crs:EPSG::4326&reportDetail=short&style=urn:uuid:report-style:default-with-code&style_name=OGP%20Default%20With%20Code&title=EPSG:4326 
     116        boolean switchLatLon = false; 
     117        if (baseURL.toLowerCase().contains("crs=epsg:4326")) { 
     118            switchLatLon = true; 
     119        } else if (baseURL.toLowerCase().contains("crs=") && myProj.equals("EPSG:4326")) { 
     120            switchLatLon = true; 
     121        } 
     122        String bbox; 
     123        if (switchLatLon) { 
     124            bbox = String.format("%s,%s,%s,%s", latLonFormat.format(s), latLonFormat.format(w), latLonFormat.format(n), latLonFormat.format(e)); 
     125        } else { 
     126            bbox = String.format("%s,%s,%s,%s", latLonFormat.format(w), latLonFormat.format(s), latLonFormat.format(e), latLonFormat.format(n)); 
     127        } 
    98128        return new URL(baseURL.replaceAll("\\{proj(\\([^})]+\\))?\\}", myProj) 
    99                 .replaceAll("\\{bbox\\}", latLonFormat.format(w) + "," 
    100                         + latLonFormat.format(s) + "," 
    101                         + latLonFormat.format(e) + "," 
    102                         + latLonFormat.format(n)) 
    103                         .replaceAll("\\{w\\}", latLonFormat.format(w)) 
    104                         .replaceAll("\\{s\\}", latLonFormat.format(s)) 
    105                         .replaceAll("\\{e\\}", latLonFormat.format(e)) 
    106                         .replaceAll("\\{n\\}", latLonFormat.format(n)) 
    107                         .replaceAll("\\{width\\}", String.valueOf(wi)) 
    108                         .replaceAll("\\{height\\}", String.valueOf(ht)) 
    109                         .replace(" ", "%20")); 
     129                .replaceAll("\\{bbox\\}", bbox) 
     130                .replaceAll("\\{w\\}", latLonFormat.format(w)) 
     131                .replaceAll("\\{s\\}", latLonFormat.format(s)) 
     132                .replaceAll("\\{e\\}", latLonFormat.format(e)) 
     133                .replaceAll("\\{n\\}", latLonFormat.format(n)) 
     134                .replaceAll("\\{width\\}", String.valueOf(wi)) 
     135                .replaceAll("\\{height\\}", String.valueOf(ht)) 
     136                .replace(" ", "%20")); 
    110137    } 
    111138 
Note: See TracChangeset for help on using the changeset viewer.