Changeset 17399 in osm for applications/editors/josm/plugins/utilsplugin/src
- Timestamp:
- 2009-08-31T09:54:41+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin/src/UtilsPlugin/JumpToAction.java
r16687 r17399 136 136 } 137 137 138 // 10 000000 = 10 000 * 1000 = World * (km -> m)138 // 10 000 000 = 10 000 * 1000 = World * (km -> m) 139 139 zm.setText(Double.toString(Math.round(10000000 * Math.pow(2, (-1) * zoomLvl)))); 140 140 } … … 146 146 double dlat = Double.parseDouble(lat.getText()); 147 147 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 150 156 int decimals = (int) Math.pow(10, (zoomLvl / 3)); 151 157 dlat = Math.round(dlat * decimals); … … 159 165 public void actionPerformed(ActionEvent e) { 160 166 showJumpToDialog(); 161 }162 163 /**164 * Converts a given scale into OSM-Style zoom factors165 * @param double scale166 */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;177 167 } 178 168
Note:
See TracChangeset
for help on using the changeset viewer.