Fix ruler

This commit is contained in:
Victor Shcherb 2015-01-25 22:56:48 +01:00
parent 5651c54ca4
commit 1568f9b598
2 changed files with 15 additions and 3 deletions

View file

@ -561,4 +561,16 @@ public class RotatedTileBox {
return lat;
}
@Override
public String toString() {
return "RotatedTileBox [lat=" + lat + ", lon=" + lon + ", rotate="
+ rotate + ", density=" + density + ", zoom=" + zoom
+ ", mapDensity=" + mapDensity + ", zoomAnimation="
+ zoomAnimation + ", zoomFloatPart=" + zoomFloatPart + ", cx="
+ cx + ", cy=" + cy + ", pixWidth=" + pixWidth + ", pixHeight="
+ pixHeight + "]";
}
}

View file

@ -58,14 +58,14 @@ public class RulerControl extends MapControls {
// update cache
if (view.isZooming()) {
cacheRulerText = null;
} else if((tb.getZoom()) != cacheRulerZoom ||
Math.abs(tb.getCenterTileX() - cacheRulerTileX) + Math.abs(tb.getCenterTileY() - cacheRulerTileY) > 1){
} else if(((tb.getZoom()) != cacheRulerZoom ||
Math.abs(tb.getCenterTileX() - cacheRulerTileX) + Math.abs(tb.getCenterTileY() - cacheRulerTileY) > 1) &&
tb.getPixWidth() > 0){
cacheRulerZoom = (tb.getZoom());
cacheRulerTileX = tb.getCenterTileX();
cacheRulerTileY = tb.getCenterTileY();
final double dist = tb.getDistance(0, tb.getPixHeight() / 2, tb.getPixWidth(), tb.getPixHeight() / 2);
double pixDensity = tb.getPixWidth() / dist;
double roundedDist = OsmAndFormatter.calculateRoundedDist(dist * screenRulerPercent, view.getApplication());
int cacheRulerDistPix = (int) (pixDensity * roundedDist);