Ignore:
Timestamp:
2009-08-31T09:54:41+02:00 (15 years ago)
Author:
guggis
Message:

applied #3360: patch by xeen: Utilsplugin JumpTo URL Creator is broken

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin/src/UtilsPlugin/JumpToAction.java

    r16687 r17399  
    136136            }
    137137
    138             // 10000000 = 10 000 * 1000 = World * (km -> m)
     138            // 10 000 000 = 10 000 * 1000 = World * (km -> m)
    139139            zm.setText(Double.toString(Math.round(10000000 * Math.pow(2, (-1) * zoomLvl))));
    140140        }
     
    146146            double dlat = Double.parseDouble(lat.getText());
    147147            double dlon = Double.parseDouble(lon.getText());
    148             int zoomLvl = getZoom(zoomFactor * Double.parseDouble(zm.getText()));
    149 
     148            double m = Double.parseDouble(zm.getText());
     149            // Inverse function to the one above. 18 is the current maximum zoom
     150            // available on standard renderers, so choose this is in case m
     151            // should be zero
     152            int zoomLvl = 18;
     153            if(m > 0)
     154                zoomLvl = (int)Math.round((-1) * Math.log(m/10000000)/Math.log(2));
     155           
    150156            int decimals = (int) Math.pow(10, (zoomLvl / 3));
    151157            dlat = Math.round(dlat * decimals);
     
    159165    public void actionPerformed(ActionEvent e) {
    160166        showJumpToDialog();
    161     }
    162 
    163     /**
    164      * Converts a given scale into OSM-Style zoom factors
    165      * @param double scale
    166      */
    167     public int getZoom(double scale) {
    168         MapView mv = Main.map.mapView;
    169         double sizex = scale * mv.getWidth();
    170         double sizey = scale * mv.getHeight();
    171         ProjectionBounds b = mv.getMaxProjectionBounds();
    172         for (int zoom = 0; zoom <= 32; zoom++, sizex *= 2, sizey *= 2) {               
    173             if (sizex > b.max.east() || sizey > b.max.north())
    174                 return zoom;
    175         }
    176         return 32;
    177167    }
    178168
Note: See TracChangeset for help on using the changeset viewer.