- Timestamp:
- 2015-05-14T13:26:49+02:00 (10 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/maps.xsd
r8344 r8349 671 671 </xs:complexType> 672 672 </xs:element> 673 <!-- list of HTTP headers, that indicate "no tile at this zoom level" situation --> 673 674 <xs:element name="no-tile-header" minOccurs="0" maxOccurs="unbounded"> 674 675 <xs:complexType> … … 677 678 </xs:complexType> 678 679 </xs:element> 680 <!-- tile size provided by imagery source. Default - 256 --> 681 <xs:element name="tile-size" minOccurs="0" maxOccurs="1" type="xs:positiveInteger" /> 679 682 </xs:choice> 680 683 </xs:sequence> -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r8344 r8349 19 19 20 20 import org.openstreetmap.gui.jmapviewer.Coordinate; 21 import org.openstreetmap.gui.jmapviewer.OsmMercator; 21 22 import org.openstreetmap.gui.jmapviewer.interfaces.Attributed; 22 23 import org.openstreetmap.gui.jmapviewer.tilesources.AbstractTileSource; … … 225 226 @pref String description; 226 227 @pref Map<String, String> noTileHeaders; 228 @pref int tileSize = OsmMercator.DEFAUL_TILE_SIZE; 227 229 228 230 /** … … 281 283 noTileHeaders = i.noTileHeaders; 282 284 } 285 286 tileSize = i.getTileSize(); 283 287 } 284 288 … … 402 406 noTileHeaders = e.noTileHeaders; 403 407 } 408 setTileSize(e.tileSize); 404 409 } 405 410 -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
r8344 r8349 150 150 for (ImageryInfo def : defaultLayers) { 151 151 // temporary migration code, so all user preferences will get updated with new settings from JOSM site (can be removed ~Dez. 2015) 152 if (def.getNoTileHeaders() != null) { 152 if (def.getNoTileHeaders() != null || def.getTileSize() > 0) { 153 153 for (ImageryInfo i: layers) { 154 154 if (isSimilar(def, i)) { 155 i.setNoTileHeaders(def.getNoTileHeaders()); 155 if (def.getNoTileHeaders() != null) { 156 i.setNoTileHeaders(def.getNoTileHeaders()); 157 } 158 if (def.getTileSize() > 0) { 159 i.setTileSize(def.getTileSize()); 160 } 156 161 changed = true; 157 162 } -
trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java
r8308 r8349 125 125 126 126 // upper left and lower right corners of the selection rectangle (x/y on ZOOM_MAX) 127 private PointiSelectionRectStart;128 private PointiSelectionRectEnd;127 private Coordinate iSelectionRectStart; 128 private Coordinate iSelectionRectEnd; 129 129 130 130 /** … … 210 210 // draw selection rectangle 211 211 if (iSelectionRectStart != null && iSelectionRectEnd != null) { 212 213 int zoomDiff = MAX_ZOOM - zoom; 214 Point tlc = getTopLeftCoordinates(); 215 int x_min = (iSelectionRectStart.x >> zoomDiff) - tlc.x; 216 int y_min = (iSelectionRectStart.y >> zoomDiff) - tlc.y; 217 int x_max = (iSelectionRectEnd.x >> zoomDiff) - tlc.x; 218 int y_max = (iSelectionRectEnd.y >> zoomDiff) - tlc.y; 219 220 int w = x_max - x_min; 221 int h = y_max - y_min; 212 Rectangle box = new Rectangle(getMapPosition(iSelectionRectStart, false)); 213 box.add(getMapPosition(iSelectionRectEnd, false)); 214 222 215 g.setColor(new Color(0.9f, 0.7f, 0.7f, 0.6f)); 223 g.fillRect( x_min, y_min, w, h);216 g.fillRect(box.x, box.y, box.width, box.height); 224 217 225 218 g.setColor(Color.BLACK); 226 g.drawRect( x_min, y_min, w, h);219 g.drawRect(box.x, box.y, box.width, box.height); 227 220 } 228 221 } catch (Exception e) { … … 257 250 Point p_min = new Point(Math.min(aEnd.x, aStart.x), Math.min(aEnd.y, aStart.y)); 258 251 259 Point tlc = getTopLeftCoordinates(); 260 int zoomDiff = MAX_ZOOM - zoom; 261 Point pEnd = new Point(p_max.x + tlc.x, p_max.y + tlc.y); 262 Point pStart = new Point(p_min.x + tlc.x, p_min.y + tlc.y); 263 264 pEnd.x <<= zoomDiff; 265 pEnd.y <<= zoomDiff; 266 pStart.x <<= zoomDiff; 267 pStart.y <<= zoomDiff; 268 269 iSelectionRectStart = pStart; 270 iSelectionRectEnd = pEnd; 271 272 Coordinate l1 = getPosition(p_max); // lon may be outside [-180,180] 273 Coordinate l2 = getPosition(p_min); // lon may be outside [-180,180] 252 iSelectionRectStart = getPosition(p_min); 253 iSelectionRectEnd = getPosition(p_max); 254 274 255 Bounds b = new Bounds( 275 256 new LatLon( 276 Math.min( l2.getLat(),l1.getLat()),277 LatLon.toIntervalLon(Math.min( l1.getLon(),l2.getLon()))257 Math.min(iSelectionRectStart.getLat(), iSelectionRectEnd.getLat()), 258 LatLon.toIntervalLon(Math.min(iSelectionRectStart.getLon(), iSelectionRectEnd.getLon())) 278 259 ), 279 260 new LatLon( 280 Math.max( l2.getLat(),l1.getLat()),281 LatLon.toIntervalLon(Math.max( l1.getLon(),l2.getLon())))261 Math.max(iSelectionRectStart.getLat(), iSelectionRectEnd.getLat()), 262 LatLon.toIntervalLon(Math.max(iSelectionRectStart.getLon(), iSelectionRectEnd.getLon()))) 282 263 ); 283 264 Bounds oldValue = this.bbox; … … 332 313 } 333 314 334 int y1 = tileSource.LatToY(bbox.getMinLat(), MAX_ZOOM); 335 int y2 = tileSource.LatToY(bbox.getMaxLat(), MAX_ZOOM); 336 int x1 = tileSource.LonToX(minLon, MAX_ZOOM); 337 int x2 = tileSource.LonToX(maxLon, MAX_ZOOM); 338 339 iSelectionRectStart = new Point(Math.min(x1, x2), Math.min(y1, y2)); 340 iSelectionRectEnd = new Point(Math.max(x1, x2), Math.max(y1, y2)); 315 iSelectionRectStart = new Coordinate(bbox.getMinLat(), bbox.getMinLon()); 316 iSelectionRectEnd = new Coordinate(bbox.getMaxLat(), bbox.getMaxLon()); 341 317 342 318 // calc the screen coordinates for the new selection rectangle -
trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
r8345 r8349 66 66 import org.openstreetmap.josm.data.preferences.StringProperty; 67 67 import org.openstreetmap.josm.data.projection.Projection; 68 import org.openstreetmap.josm.gui.ExtendedDialog; 68 69 import org.openstreetmap.josm.gui.MapFrame; 69 70 import org.openstreetmap.josm.gui.MapView; … … 423 424 424 425 private final int getBestZoom() { 425 double factor = getScaleFactor(1); 426 double factor = getScaleFactor(1); // check the ratio between area of tilesize at zoom 1 to current view 426 427 double result = Math.log(factor)/Math.log(2)/2+1; 427 // In general, smaller zoom levels are more readable. We prefer big, 428 // block, pixelated (but readable) map text to small, smeared, 429 // unreadable underzoomed text. So, use .floor() instead of rounding 430 // to skew things a bit toward the lower zooms. 428 /* 429 * Math.log(factor)/Math.log(2) - gives log base 2 of factor 430 * We divide result by 2, as factor contains ratio between areas. We could do Math.sqrt before log, or just divide log by 2 431 * In general, smaller zoom levels are more readable. We prefer big, 432 * block, pixelated (but readable) map text to small, smeared, 433 * unreadable underzoomed text. So, use .floor() instead of rounding 434 * to skew things a bit toward the lower zooms. 435 * Remember, that result here, should correspond to TMSLayer.paint(...) 436 * getScaleFactor(...) is supposed to be between 0.75 and 3 437 */ 431 438 int intResult = (int)Math.floor(result); 432 439 if (intResult > getMaxZoomLvl()) … … 514 521 public void actionPerformed(ActionEvent ae) { 515 522 if (clickedTile != null) { 516 showMetadataTile = clickedTile; 517 redraw(); 523 ExtendedDialog ed = new ExtendedDialog(Main.parent, tr("Tile Info"), new String[]{tr("OK")}); 524 ed.setIcon(JOptionPane.INFORMATION_MESSAGE); 525 StringBuilder content = new StringBuilder(); 526 content.append("Tile name: ").append(clickedTile.getKey()).append("\n"); 527 try { 528 content.append("Tile url: ").append(clickedTile.getUrl()).append("\n"); 529 } catch (IOException e) { 530 } 531 content.append("Tile size: ").append(clickedTile.getTileSource().getTileSize()).append("x").append(clickedTile.getTileSource().getTileSize()).append("\n"); 532 Rectangle displaySize = tileToRect(clickedTile); 533 content.append("Tile display size: ").append(displaySize.width).append("x").append(displaySize.height).append("\n"); 534 ed.setContent(content.toString()); 535 ed.showDialog(); 518 536 } 519 537 } … … 1384 1402 myDrawString(g, tr("Display zoom: {0}", displayZoomLevel), 50, 155); 1385 1403 myDrawString(g, tr("Pixel scale: {0}", getScaleFactor(currentZoomLevel)), 50, 170); 1386 myDrawString(g, tr("Best zoom: {0}", Math.log(getScaleFactor(1))/Math.log(2)/2+1), 50, 185);1404 myDrawString(g, tr("Best zoom: {0}", getBestZoom()), 50, 185); 1387 1405 if(tileLoader instanceof TMSCachedTileLoader) { 1388 1406 TMSCachedTileLoader cachedTileLoader = (TMSCachedTileLoader)tileLoader; -
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r8347 r8349 138 138 "country-code", 139 139 "icon", 140 "tile-size", 140 141 }).contains(qName)) { 141 142 newState = State.ENTRY_ATTRIBUTE; … … 300 301 entry.setIcon(accumulator.toString()); 301 302 break; 303 case "tile-size": 304 Integer tileSize = null; 305 try { 306 tileSize = Integer.parseInt(accumulator.toString()); 307 } catch(NumberFormatException e) { 308 tileSize = null; 309 } 310 if (tileSize == null) { 311 skipEntry = true; 312 } else { 313 entry.setTileSize(tileSize.intValue()); 314 } 315 break; 302 316 } 303 317 break;
Note:
See TracChangeset
for help on using the changeset viewer.