Index: applications/editors/josm/plugins/wmsplugin/build.xml
===================================================================
--- applications/editors/josm/plugins/wmsplugin/build.xml	(revision 15961)
+++ applications/editors/josm/plugins/wmsplugin/build.xml	(revision 16290)
@@ -29,5 +29,5 @@
                 <attribute name="Plugin-Description" value="Display georeferenced images as background in JOSM (WMS servers, Yahoo, ...)."/>
                 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/WMSPlugin"/>
-                <attribute name="Plugin-Mainversion" value="1646"/>
+                <attribute name="Plugin-Mainversion" value="1722"/>
                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
                 <attribute name="de_Plugin-Link" value="http://wiki.openstreetmap.org/wiki/DE:JOSM/Plugins/WMSPlugin"/>
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Grabber.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Grabber.java	(revision 15961)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Grabber.java	(revision 16290)
@@ -9,6 +9,6 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.Bounds;
-import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.ProjectionBounds;
+import org.openstreetmap.josm.data.coor.EastNorth;
 import org.openstreetmap.josm.data.projection.Projection;
 import org.openstreetmap.josm.gui.MapView;
@@ -16,5 +16,5 @@
 
 abstract public class Grabber implements Runnable {
-    protected Bounds b;
+    protected ProjectionBounds b;
     protected Projection proj;
     protected double pixelPerDegree;
@@ -24,25 +24,7 @@
     protected CacheFiles cache;
 
-    Grabber(Bounds b, GeorefImage image, MapView mv, WMSLayer layer, CacheFiles cache)
+    Grabber(ProjectionBounds b, GeorefImage image, MapView mv, WMSLayer layer, CacheFiles cache)
     {
-        if (b.min != null && b.max != null && WMSPlugin.doOverlap)
-        {
-            double latCent = (b.min.lat() + b.max.lat()) / 2;
-            double lonCent = (b.min.lon() + b.max.lon()) / 2;
-
-            double latSize =  b.max.lat() - b.min.lat();
-            double lonSize =  b.max.lon() - b.min.lon();
-
-            double latCoef = (100.0 + WMSPlugin.overlapLat) / 100.0 / 2.0;
-            double lonCoef = (100.0 + WMSPlugin.overlapLon) / 100.0 / 2.0;
-
-            this.b = new Bounds( new LatLon(latCent - latCoef * latSize,
-                                            lonCent - lonCoef * lonSize),
-                                 new LatLon(latCent + latCoef * latSize,
-                                            lonCent + lonCoef * lonSize));
-        }
-        else
-            this.b = b;
-
+        this.b = b;
         this.proj = Main.main.proj;
         this.pixelPerDegree = layer.pixelPerDegree;
@@ -56,8 +38,8 @@
 
     int width(){
-        return (int) ((b.max.lon() - b.min.lon()) * pixelPerDegree);
+        return (int) ((b.max.north() - b.min.north()) * pixelPerDegree);
     }
     int height(){
-        return (int) ((b.max.lat() - b.min.lat()) * pixelPerDegree);
+        return (int) ((b.max.east() - b.min.east()) * pixelPerDegree);
     }
 
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java	(revision 15961)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java	(revision 16290)
@@ -24,5 +24,9 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.Bounds;
+import org.openstreetmap.josm.data.ProjectionBounds;
+import org.openstreetmap.josm.data.coor.EastNorth;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.projection.Epsg4326;
+import org.openstreetmap.josm.data.projection.Mercator;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.io.CacheFiles;
@@ -35,5 +39,5 @@
     private final boolean urlWithPatterns;
 
-    WMSGrabber(Bounds b, GeorefImage image, MapView mv, WMSLayer layer, CacheFiles cache) {
+    WMSGrabber(ProjectionBounds b, GeorefImage image, MapView mv, WMSLayer layer, CacheFiles cache) {
         super(b, image, mv, layer, cache);
         this.baseURL = layer.baseURL;
@@ -51,11 +55,12 @@
         try {
             url = getURL(
-                b.min.lon(), b.min.lat(),
-                b.max.lon(), b.max.lat(),
+                b.min.east(), b.min.north(),
+                b.max.east(), b.max.north(),
                 width(), height());
 
-            image.min = proj.latlon2eastNorth(b.min);
-            image.max = proj.latlon2eastNorth(b.max);
+            image.min = b.min;
+            image.max = b.max;
 
+System.out.println(url + " " + b + " " + image.min + " " + image.max);
             if(image.isVisible(mv)) { //don't download, if the image isn't visible already
                 image.image = grab(url);
@@ -73,4 +78,25 @@
     protected URL getURL(double w, double s,double e,double n,
             int wi, int ht) throws MalformedURLException {
+        String proj = Main.proj.toCode();
+        if(Main.proj instanceof Mercator) // don't use mercator code directly
+        {
+            LatLon sw = Main.proj.eastNorth2latlon(new EastNorth(s, w));
+            LatLon ne = Main.proj.eastNorth2latlon(new EastNorth(n, e));
+            proj = "EPSG:4326";
+            s = sw.lat();
+            w = sw.lon();
+            n = ne.lat();
+            e = ne.lon();
+        }
+/*        else if(!(Main.proj instanceof Epsg4326))
+        {
+            EastNorth sw = Main.proj.latlon2eastNorth(new LatLon(s, w));
+            EastNorth ne = Main.proj.latlon2eastNorth(new LatLon(n, e));
+            s = sw.north();
+            w = sw.east();
+            n = ne.north();
+            e = ne.east();
+        }
+*/
         String str = baseURL;
         String bbox = latLonFormat.format(w) + ","
@@ -80,8 +106,4 @@
 
         if (urlWithPatterns) {
-            String proj = Main.proj.toCode();
-            if(Main.proj instanceof org.openstreetmap.josm.data.projection.Mercator) // don't use mercator code directly
-                proj = "EPSG:4326";
-
             str = MessageFormat.format(str, proj, bbox, wi, ht);
         } else {
@@ -99,5 +121,5 @@
     {
         String projname = Main.proj.toCode();
-        if(Main.proj instanceof org.openstreetmap.josm.data.projection.Mercator) // don't use mercator code
+        if(Main.proj instanceof Mercator) // don't use mercator code
             projname = "EPSG:4326";
         String res = "";
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java	(revision 15961)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java	(revision 16290)
@@ -26,5 +26,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.DiskAccessAction;
-import org.openstreetmap.josm.data.Bounds;
+import org.openstreetmap.josm.data.ProjectionBounds;
 import org.openstreetmap.josm.data.coor.EastNorth;
 import org.openstreetmap.josm.data.coor.LatLon;
@@ -79,5 +79,5 @@
         WMSGrabber.getProjection(baseURL, true);
         mv = Main.map.mapView;
-        getPPD();
+        pixelPerDegree = getPPD();
 
         executor = Executors.newFixedThreadPool(3);
@@ -92,6 +92,7 @@
     }
 
-    public void getPPD(){
-        pixelPerDegree = mv.getWidth() / (bounds().max.lon() - bounds().min.lon());
+    public double getPPD(){
+        ProjectionBounds bounds = mv.getProjectionBounds();
+        return mv.getWidth() / (bounds.max.east() - bounds.min.east());
     }
 
@@ -128,8 +129,8 @@
     }
 
-    private Bounds XYtoBounds (int x, int y) {
-        return new Bounds(
-            new LatLon(      x * ImageSize / pixelPerDegree,       y * ImageSize / pixelPerDegree),
-            new LatLon((x + 1) * ImageSize / pixelPerDegree, (y + 1) * ImageSize / pixelPerDegree));
+    private ProjectionBounds XYtoBounds (int x, int y) {
+        return new ProjectionBounds(
+            new EastNorth(      x * ImageSize / pixelPerDegree,       y * ImageSize / pixelPerDegree),
+            new EastNorth((x + 1) * ImageSize / pixelPerDegree, (y + 1) * ImageSize / pixelPerDegree));
     }
 
@@ -138,14 +139,8 @@
     }
 
-    protected Bounds bounds(){
-        return new Bounds(
-            mv.getLatLon(0, mv.getHeight()),
-            mv.getLatLon(mv.getWidth(), 0));
-    }
-
     @Override public void paint(Graphics g, final MapView mv) {
         if(baseURL == null) return;
 
-        if( !startstop.isSelected() || (pixelPerDegree / (mv.getWidth() / (bounds().max.lon() - bounds().min.lon())) > minZoom) ){ //don't download when it's too outzoomed
+        if( !startstop.isSelected() || (pixelPerDegree / getPPD() > minZoom) ){ //don't download when it's too outzoomed
             for(int x = 0; x<dax; ++x)
                 for(int y = 0; y<day; ++y)
@@ -161,8 +156,9 @@
 
     protected void downloadAndPaintVisible(Graphics g, final MapView mv){
-        int bminx= (int)Math.floor ((bounds().min.lat() * pixelPerDegree ) / ImageSize );
-        int bminy= (int)Math.floor ((bounds().min.lon() * pixelPerDegree ) / ImageSize );
-        int bmaxx= (int)Math.ceil  ((bounds().max.lat() * pixelPerDegree ) / ImageSize );
-        int bmaxy= (int)Math.ceil  ((bounds().max.lon() * pixelPerDegree ) / ImageSize );
+        ProjectionBounds bounds = mv.getProjectionBounds();
+        int bminx= (int)Math.floor ((bounds.min.east() * pixelPerDegree ) / ImageSize );
+        int bminy= (int)Math.floor ((bounds.min.north() * pixelPerDegree ) / ImageSize );
+        int bmaxx= (int)Math.ceil  ((bounds.max.east() * pixelPerDegree ) / ImageSize );
+        int bmaxy= (int)Math.ceil  ((bounds.max.north() * pixelPerDegree ) / ImageSize );
 
         if((bmaxx - bminx > dax) || (bmaxy - bminy > day)){
@@ -241,5 +237,5 @@
             initializeImages();
             resolution = scale();
-            getPPD();
+            pixelPerDegree = getPPD();
             mv.repaint();
         }
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java	(revision 15961)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java	(revision 16290)
@@ -25,5 +25,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.JosmAction;
-import org.openstreetmap.josm.data.Bounds;
+import org.openstreetmap.josm.data.ProjectionBounds;
 import org.openstreetmap.josm.gui.IconToggleButton;
 import org.openstreetmap.josm.gui.MainMenu;
@@ -43,8 +43,4 @@
     static ArrayList<WMSInfo> wmsList = new ArrayList<WMSInfo>();
     static TreeMap<String,String> wmsListDefault = new TreeMap<String,String>();
-
-    static boolean doOverlap = false;
-    static int overlapLat = 4;
-    static int overlapLon = 14;
 
     // remember state of menu item to restore on changed preferences
@@ -89,18 +85,4 @@
 
         TreeSet<String> keys = new TreeSet<String>(prefs.keySet());
-
-        // Here we load the settings for "overlap" checkbox and spinboxes.
-
-        try {
-            doOverlap = Boolean.valueOf(prefs.get("wmsplugin.url.overlap"));
-        } catch (Exception e) {} // If sth fails, we drop to default settings.
-
-        try {
-            overlapLat = Integer.valueOf(prefs.get("wmsplugin.url.overlapLat"));
-        } catch (Exception e) {} // If sth fails, we drop to default settings.
-
-        try {
-            overlapLon = Integer.valueOf(prefs.get("wmsplugin.url.overlapLon"));
-        } catch (Exception e) {} // If sth fails, we drop to default settings.
 
         // And then the names+urls of WMS servers
@@ -207,15 +189,9 @@
     }
 
-    // baseURL, XYtoBounds(x,y), Main.main.proj, pixelPerDegree, img, mv, this
-    // Grabber gr = WMSPlugin.getGrabber(XYtoBounds(x,y), img, mv, this);
-    public static Grabber getGrabber(Bounds bounds, GeorefImage img, MapView mv, WMSLayer layer){
+    public static Grabber getGrabber(ProjectionBounds bounds, GeorefImage img, MapView mv, WMSLayer layer){
         if(layer.baseURL.startsWith("yahoo://"))
             return new YAHOOGrabber(bounds, img, mv, layer, cache);
         else
             return new WMSGrabber(bounds, img, mv, layer, cache);
-
-        // OSBGrabber should be rewrite for thread support first
-        //if (wmsurl.matches("(?i).*layers=npeoocmap.*") || wmsurl.matches("(?i).*layers=npe.*") )
-        //  return new OSGBGrabber(_b, _proj, _pixelPerDegree,  _images, _mv, _layer);
     }
 
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java	(revision 15961)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java	(revision 16290)
@@ -33,8 +33,4 @@
     private DefaultTableModel model;
     private HashMap<Integer, WMSInfo> oldValues = new HashMap<Integer, WMSInfo>();
-
-    JCheckBox overlapCheckBox;
-    JSpinner spinLat;
-    JSpinner spinLon;
 
     public void addGui(final PreferenceDialog gui) {
@@ -117,19 +113,4 @@
         p.add(buttonPanel);
         p.add(Box.createHorizontalGlue(), GBC.eol().fill(GBC.HORIZONTAL));
-
-        overlapCheckBox = new JCheckBox(tr("Overlap tiles"), WMSPlugin.doOverlap );
-        JLabel labelLat = new JLabel(tr("% of lat:"));
-        JLabel labelLon = new JLabel(tr("% of lon:"));
-        spinLat = new JSpinner(new SpinnerNumberModel(WMSPlugin.overlapLat, 1, 50, 1));
-        spinLon = new JSpinner(new SpinnerNumberModel(WMSPlugin.overlapLon, 1, 50, 1));
-
-        JPanel overlapPanel = new JPanel(new FlowLayout());
-        overlapPanel.add(overlapCheckBox);
-        overlapPanel.add(labelLat);
-        overlapPanel.add(spinLat);
-        overlapPanel.add(labelLon);
-        overlapPanel.add(spinLon);
-
-        p.add(overlapPanel);
     }
 
@@ -170,12 +151,4 @@
 
         if (change) WMSPlugin.refreshMenu();
-
-        WMSPlugin.doOverlap = overlapCheckBox.getModel().isSelected();
-        WMSPlugin.overlapLat = (Integer) spinLat.getModel().getValue();
-        WMSPlugin.overlapLon = (Integer) spinLon.getModel().getValue();
-
-        Main.pref.put("wmsplugin.url.overlap",    String.valueOf(WMSPlugin.doOverlap));
-        Main.pref.put("wmsplugin.url.overlapLat", String.valueOf(WMSPlugin.overlapLat));
-        Main.pref.put("wmsplugin.url.overlapLon", String.valueOf(WMSPlugin.overlapLon));
 
         return false;
Index: applications/editors/josm/plugins/wmsplugin/src/wmsplugin/YAHOOGrabber.java
===================================================================
--- applications/editors/josm/plugins/wmsplugin/src/wmsplugin/YAHOOGrabber.java	(revision 15961)
+++ applications/editors/josm/plugins/wmsplugin/src/wmsplugin/YAHOOGrabber.java	(revision 16290)
@@ -10,5 +10,5 @@
 import javax.imageio.ImageIO;
 
-import org.openstreetmap.josm.data.Bounds;
+import org.openstreetmap.josm.data.ProjectionBounds;
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.io.CacheFiles;
@@ -18,5 +18,5 @@
     protected String browserCmd;
 
-    YAHOOGrabber(Bounds b, GeorefImage image, MapView mv, WMSLayer layer, CacheFiles cache) {
+    YAHOOGrabber(ProjectionBounds b, GeorefImage image, MapView mv, WMSLayer layer, CacheFiles cache) {
         super(b, image, mv, layer, cache);
         this.baseURL = "file:///" + WMSPlugin.getPrefsPath() + "ymap.html?";
