Changeset 9167 in josm for trunk/src/org/openstreetmap/josm
- Timestamp:
- 2015-12-26T20:41:45+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java
r8846 r9167 16 16 import java.util.regex.Pattern; 17 17 18 import org.openstreetmap.gui.jmapviewer.OsmMercator;19 18 import org.openstreetmap.gui.jmapviewer.Tile; 20 19 import org.openstreetmap.gui.jmapviewer.TileXY; … … 23 22 import org.openstreetmap.gui.jmapviewer.tilesources.TMSTileSource; 24 23 import org.openstreetmap.josm.Main; 25 import org.openstreetmap.josm.data. Bounds;24 import org.openstreetmap.josm.data.ProjectionBounds; 26 25 import org.openstreetmap.josm.data.coor.EastNorth; 27 26 import org.openstreetmap.josm.data.coor.LatLon; … … 40 39 private final Set<String> serverProjections; 41 40 private EastNorth topLeftCorner; 42 private Bounds worldBounds;43 41 private int[] tileXMax; 44 42 private int[] tileYMax; … … 96 94 */ 97 95 public void initProjection(Projection proj) { 98 this.worldBounds = getWorldBounds();99 EastNorth min = proj.latlon2eastNorth(worldBounds.getMin());100 EastNorth max = proj.latlon2eastNorth(worldBounds.getMax());96 ProjectionBounds worldBounds = proj.getWorldBoundsBoxEastNorth(); 97 EastNorth min = worldBounds.getMin(); 98 EastNorth max = worldBounds.getMax(); 101 99 this.topLeftCorner = new EastNorth(min.east(), max.north()); 102 100 103 LatLon bottomRight = new LatLon(worldBounds.getMinLat(), worldBounds.getMaxLon());101 EastNorth bottomRight = new EastNorth(worldBounds.getMax().east(), worldBounds.getMin().north()); 104 102 105 103 // use 256 as "tile size" to keep the scale in line with default tiles in Mercator projection … … 113 111 // this makes the zoom levels "glued" to standard TMS zoom levels 114 112 degreesPerTile[zoom] = (SCALE_DENOMINATOR_ZOOM_LEVEL_1 / Math.pow(2, zoom - 1)) * crsScale; 115 TileXY maxTileIndex = latLonToTileXY(bottomRight.toCoordinate(), zoom);113 TileXY maxTileIndex = eastNorthToTileXY(bottomRight, zoom); 116 114 tileXMax[zoom] = maxTileIndex.getXIndex(); 117 115 tileYMax[zoom] = maxTileIndex.getYIndex(); … … 243 241 Projection proj = Main.getProjection(); 244 242 EastNorth enPoint = proj.latlon2eastNorth(new LatLon(lat, lon)); 243 return eastNorthToTileXY(enPoint, zoom); 244 } 245 246 private TileXY eastNorthToTileXY(EastNorth enPoint, int zoom) { 245 247 double scale = getDegreesPerTile(zoom); 246 248 return new TileXY( … … 356 358 return degreesPerTile[zoom]; 357 359 } 358 359 /**360 * returns world bounds, but detect situation, when default bounds are provided (-90, -180, 90, 180), and projection361 * returns very close values for both min and max X. To work around this problem, cap this projection on north and south362 * pole, the same way they are capped in Mercator projection, so conversions should work properly363 */364 private static Bounds getWorldBounds() {365 Projection proj = Main.getProjection();366 Bounds bounds = proj.getWorldBoundsLatLon();367 EastNorth min = proj.latlon2eastNorth(bounds.getMin());368 EastNorth max = proj.latlon2eastNorth(bounds.getMax());369 370 if (Math.abs(min.getX() - max.getX()) < 1 && bounds.equals(new Bounds(new LatLon(-90, -180), new LatLon(90, 180)))) {371 return new Bounds(372 new LatLon(OsmMercator.MIN_LAT, bounds.getMinLon()),373 new LatLon(OsmMercator.MAX_LAT, bounds.getMaxLon())374 );375 }376 return bounds;377 }378 360 }
Note:
See TracChangeset
for help on using the changeset viewer.