Changeset 25274 in osm for applications/editors/josm/plugins/ext_tools/src
- Timestamp:
- 2011-02-12T17:40:58+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ext_tools/src/ext_tools/ExtTool.java
r23327 r25274 28 28 import org.openstreetmap.josm.gui.JMultilineLabel; 29 29 import org.openstreetmap.josm.gui.MainMenu; 30 import org.openstreetmap.josm.gui.MapView; 30 31 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 31 32 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; … … 116 117 } 117 118 119 private double latToTileY(double lat, int zoom) { 120 double l = lat / 180 * Math.PI; 121 double pf = Math.log(Math.tan(l) + (1 / Math.cos(l))); 122 return Math.pow(2.0, zoom - 1) * (Math.PI - pf) / Math.PI; 123 } 124 125 private double lonToTileX(double lon, int zoom) { 126 return Math.pow(2.0, zoom - 3) * (lon + 180.0) / 45.0; 127 } 128 129 private double getTMSZoom() { 130 if (Main.map == null || Main.map.mapView == null) return 1; 131 MapView mv = Main.map.mapView; 132 LatLon topLeft = mv.getLatLon(0, 0); 133 LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight()); 134 double x1 = lonToTileX(topLeft.lon(), 1); 135 double y1 = latToTileY(topLeft.lat(), 1); 136 double x2 = lonToTileX(botRight.lon(), 1); 137 double y2 = latToTileY(botRight.lat(), 1); 138 139 int screenPixels = mv.getWidth()*mv.getHeight(); 140 double tilePixels = Math.abs((y2-y1)*(x2-x1)*65536); 141 if (screenPixels == 0 || tilePixels == 0) return 1; 142 return Math.log(screenPixels/tilePixels)/Math.log(2)/2+1; 143 } 144 118 145 protected void showErrorMessage(String message, String details) { 119 146 final JPanel p = new JPanel(new GridBagLayout()); … … 140 167 replace.put("{lon}", "" + pos.lon()); 141 168 replace.put("{PPD}", "" + getPPD()); 169 replace.put("{TZoom}", "" + getTMSZoom()); 142 170 143 171 ArrayList<String> cmdParams = new ArrayList<String>();
Note:
See TracChangeset
for help on using the changeset viewer.