Changeset 13600 in osm for applications


Ignore:
Timestamp:
2009-02-08T17:05:17+01:00 (15 years ago)
Author:
stoecker
Message:

added support for projection

Location:
applications/editors/josm/plugins/wmsplugin/src/wmsplugin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java

    r13497 r13600  
    11package wmsplugin;
     2
     3import static org.openstreetmap.josm.tools.I18n.tr;
    24
    35import java.awt.image.BufferedImage;
     
    1416import java.text.NumberFormat;
    1517import java.util.Locale;
     18import java.util.regex.Matcher;
     19import java.util.regex.Pattern;
    1620
    1721import javax.imageio.ImageIO;
     22import javax.swing.JOptionPane;
    1823
    1924import org.openstreetmap.josm.Main;
     
    2631public class WMSGrabber extends Grabber {
    2732    protected String baseURL;
     33    private static Boolean shownWarning = false;
    2834
    2935    WMSGrabber(String baseURL, Bounds b, Projection proj,
     
    7177            + latLonFormat.format(e) + ","
    7278            + latLonFormat.format(n)
     79            + getProjection(baseURL, false)
    7380            + "&width=" + wi + "&height=" + ht;
    7481        return new URL(str.replace(" ", "%20"));
     82    }
     83
     84    static public String getProjection(String baseURL, Boolean warn)
     85    {
     86        String projname = Main.proj.toCode();
     87        if(projname.equals("EPSG:3785")) // don't use mercator code
     88            projname = "EPSG:4326";
     89        String res = "";
     90        try
     91        {
     92            Matcher m = Pattern.compile(".*srs=([a-z0-9:]+).*").matcher(baseURL.toLowerCase());
     93            if(m.matches())
     94            {
     95                projname = projname.toLowerCase();
     96                if(!projname.equals(m.group(1)) && warn)
     97                {
     98                    JOptionPane.showMessageDialog(Main.parent,
     99                    tr("The projection ''{0}'' in URL and current projection ''{1}'' mismatch.\n"
     100                    + "This may lead to wrong coordinates.\n",
     101                    m.group(1), projname));
     102                }
     103            }
     104            else
     105                res ="&srs="+projname;
     106        }
     107        catch(Exception e)
     108        {
     109        }
     110        return res;
    75111    }
    76112
  • applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java

    r13497 r13600  
    7878        initializeImages();
    7979        this.baseURL = baseURL;
     80        WMSGrabber.getProjection(baseURL, true);
    8081        mv = Main.map.mapView;
    8182        getPPD();
Note: See TracChangeset for help on using the changeset viewer.