Ignore:
Timestamp:
2011-06-29T17:16:03+02:00 (13 years ago)
Author:
stoecker
Message:

improve projection handling for WMS

File:
1 edited

Legend:

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

    r4183 r4184  
    7878        try
    7979        {
    80             Matcher m = Pattern.compile(".*srs=([a-z0-9:]+).*").matcher(baseURL.toUpperCase());
     80            Matcher m = Pattern.compile(".*SRS=([a-z0-9:]+).*", Pattern.CASE_INSENSITIVE).matcher(baseURL.toUpperCase());
    8181            if(m.matches())
    8282            {
     
    112112
    113113        if (urlWithPatterns) {
    114             str = str.replaceAll("\\{proj\\}", myProj)
     114            str = str.replaceAll("\\{proj(\\([^})]+\\))?\\}", myProj)
    115115            .replaceAll("\\{bbox\\}", bbox)
    116116            .replaceAll("\\{w\\}", latLonFormat.format(w))
     
    138138        try
    139139        {
    140             Matcher m = Pattern.compile(".*srs=([a-z0-9:]+).*").matcher(baseURL.toUpperCase());
     140            Matcher m = Pattern.compile(".*\\{PROJ\\(([^)}]+)\\)\\}.*").matcher(baseURL.toUpperCase());
    141141            if(m.matches())
    142142            {
    143                 serverProjections.add(m.group(1));
    144                 if(m.group(1).equals("EPSG:4326"))
     143                boolean hasepsg = false;
     144                for(String p : m.group(1).split(","))
     145                {
     146                    serverProjections.add(p);
     147                    if(p.equals("EPSG:4326"))
     148                        hasepsg = true;
     149                }
     150                if(hasepsg && !serverProjections.contains(new Mercator().toCode()))
    145151                    serverProjections.add(new Mercator().toCode());
    146152            }
    147             /* TODO: here should be an "else" code checking server capabilities */
     153            else
     154            {
     155                m = Pattern.compile(".*SRS=([a-z0-9:]+).*", Pattern.CASE_INSENSITIVE).matcher(baseURL.toUpperCase());
     156                if(m.matches())
     157                {
     158                    serverProjections.add(m.group(1));
     159                    if(m.group(1).equals("EPSG:4326"))
     160                        serverProjections.add(new Mercator().toCode());
     161                }
     162                /* TODO: here should be an "else" code checking server capabilities */
     163            }
    148164        }
    149165        catch(Exception e)
Note: See TracChangeset for help on using the changeset viewer.