- Timestamp:
- 2015-08-27T21:19:44+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java
r8659 r8696 62 62 }; 63 63 64 /* 65 * Constant taken from OGC WMTS Implementation Specification (http://www.opengeospatial.org/standards/wmts) 66 * From table E.4 - Definition of Well-known scale set GoogleMapsCompatibile 67 * 68 * As higher zoom levels have denominator divided by 2, we keep only zoom level 1 in the code 69 */ 70 private static final float SCALE_DENOMINATOR_ZOOM_LEVEL_1 = 559082264.0287178f; 71 64 72 /** 65 73 * Creates a tile source based on imagery info … … 72 80 initProjection(); 73 81 // FIXME: remove in September 2015, when ImageryPreferenceEntry.tileSize will be initialized to -1 instead to 256 74 // need to leave it as it is to keep compatib lity between tested and latest JOSM versions82 // need to leave it as it is to keep compatibility between tested and latest JOSM versions 75 83 tileSize = WMSLayer.PROP_IMAGE_SIZE.get(); 76 84 } … … 94 102 95 103 LatLon bottomRight = new LatLon(worldBounds.getMinLat(), worldBounds.getMaxLon()); 104 105 // use 256 as "tile size" to keep the scale in line with default tiles in Mercator projection 106 double crsScale = 256 * 0.28e-03 / proj.getMetersPerUnit(); 96 107 tileXMax = new int[getMaxZoom() + 1]; 97 108 tileYMax = new int[getMaxZoom() + 1]; 98 degreesPerTile = new double[getMaxZoom() +1]; 109 degreesPerTile = new double[getMaxZoom() + 1]; 110 99 111 for (int zoom = getMinZoom(); zoom <= getMaxZoom(); zoom++) { 100 112 TileXY maxTileIndex = latLonToTileXY(bottomRight.toCoordinate(), zoom); 101 113 tileXMax[zoom] = maxTileIndex.getXIndex(); 102 114 tileYMax[zoom] = maxTileIndex.getYIndex(); 103 int tilesPerZoom = (int) Math.pow(2d, zoom - 1); 104 degreesPerTile[zoom] = Math.max( 105 Math.abs(max.getY() - min.getY()) / tilesPerZoom, 106 Math.abs(max.getX() - min.getX()) / tilesPerZoom 107 ); 108 115 // use well known scale set "GoogleCompatibile" from OGC WMTS spec to calculate number of tiles per zoom level 116 // this makes the zoom levels "glued" to standard TMS zoom levels 117 degreesPerTile[zoom] = (SCALE_DENOMINATOR_ZOOM_LEVEL_1 / Math.pow(2, zoom - 1)) * crsScale; 109 118 } 110 119
Note:
See TracChangeset
for help on using the changeset viewer.