Changeset 11894 in josm
 Timestamp:
 20170413T12:58:56+02:00 (11 days ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java
r11893 r11894 46 46 } 47 47 48 /** 49 * Get the scale that was used for reprojecting the tile. 50 * 51 * This is not necessarily the mapview scale, but may be 52 * adjusted to avoid excessively large cache image. 53 * @return the scale that was used for reprojecting the tile 54 */ 48 55 public double getNativeScale() { 49 56 return nativeScale; 50 57 } 51 58 59 /** 60 * Check if it is necessary to refresh the cache to match the current mapview 61 * scale and get optimized image quality. 62 * 63 * When the maximum zoom is exceeded, this method will generally return false. 64 * @param currentScale the current mapview scale 65 * @return true if the tile should be reprojected again from the source image. 66 */ 52 67 public boolean needsUpdate(double currentScale) { 53 68 if (Utils.equalsEpsilon(nativeScale, currentScale)) 54 69 return false; 55 // zoomed in even more  max zoom already reached, so no update56 70 return !maxZoomReached  currentScale >= nativeScale; 57 71 } … … 107 121 ProjectionBounds pbTarget = projCurrent.getEastNorthBoundsBox(pbServer, projServer); 108 122 109 // add margin and align to pixel grid 110 double minEast = Math.floor(pbTarget.minEast / scaleMapView  margin) * scaleMapView; 111 double minNorth = Math.floor((pbTarget.minNorth / scaleMapView  margin)) * scaleMapView; 112 double maxEast = Math.ceil(pbTarget.maxEast / scaleMapView + margin) * scaleMapView; 113 double maxNorth = Math.ceil((pbTarget.maxNorth / scaleMapView + margin)) * scaleMapView; 114 ProjectionBounds pbTargetAligned = new ProjectionBounds(minEast, minNorth, maxEast, maxNorth); 115 116 Dimension dim = getDimension(pbTargetAligned, scaleMapView); 123 Dimension dim = getDimension(pbMarginAndAlign(pbTarget, scaleMapView, margin), scaleMapView); 117 124 Integer scaleFix = limitScale(source.getTileSize(), Math.sqrt(dim.getWidth() * dim.getHeight())); 118 125 double scale = scaleFix == null ? scaleMapView : (scaleMapView * scaleFix); 126 ProjectionBounds pbTargetAligned = pbMarginAndAlign(pbTarget, scale, margin); 119 127 120 128 ImageWarp.PointTransform pointTransform = pt > { … … 151 159 } 152 160 161 // add margin and align to pixel grid 162 private ProjectionBounds pbMarginAndAlign(ProjectionBounds box, double scale, double margin) { 163 double minEast = Math.floor(box.minEast / scale  margin) * scale; 164 double minNorth = Math.floor((box.minNorth / scale  margin)) * scale; 165 double maxEast = Math.ceil(box.maxEast / scale + margin) * scale; 166 double maxNorth = Math.ceil((box.maxNorth / scale + margin)) * scale; 167 return new ProjectionBounds(minEast, minNorth, maxEast, maxNorth); 168 } 169 170 // dimension in pixel 153 171 private Dimension getDimension(ProjectionBounds bounds, double scale) { 154 172 return new Dimension(
Note: See TracChangeset
for help on using the changeset viewer.