Modify layers
This commit is contained in:
parent
368f9b7493
commit
7f8a088a4a
24 changed files with 266 additions and 511 deletions
|
@ -10,6 +10,7 @@ public class RotatedTileBox {
|
|||
private float density;
|
||||
private int zoom;
|
||||
private float zoomScale;
|
||||
private float zoomAnimation;
|
||||
private int cx;
|
||||
private int cy;
|
||||
private int pixWidth;
|
||||
|
@ -41,6 +42,7 @@ public class RotatedTileBox {
|
|||
this.lon = r.lon;
|
||||
this.zoom = r.zoom;
|
||||
this.zoomScale = r.zoomScale;
|
||||
this.zoomAnimation = r.zoomAnimation;
|
||||
this.rotate = r.rotate;
|
||||
this.density = r.density;
|
||||
this.cx = r.cx;
|
||||
|
@ -80,7 +82,7 @@ public class RotatedTileBox {
|
|||
}
|
||||
|
||||
public void calculateDerivedFields() {
|
||||
zoomFactor = (float) Math.pow(2, zoomScale) * 256;
|
||||
zoomFactor = (float) Math.pow(2, zoomScale + zoomAnimation) * 256;
|
||||
float rad = (float) Math.toRadians(this.rotate);
|
||||
rotateCos = (float) Math.cos(rad);
|
||||
rotateSin = (float) Math.sin(rad);
|
||||
|
@ -243,11 +245,21 @@ public class RotatedTileBox {
|
|||
return (int) (dTilex * zoomFactor + cx);
|
||||
}
|
||||
|
||||
public int getPixXFromTileXNoRot(double tileX) {
|
||||
float dTilex = (float) tileX - oxTile;
|
||||
return (int) (dTilex * zoomFactor + cx);
|
||||
}
|
||||
|
||||
public int getPixYFromLatNoRot(double latitude) {
|
||||
float dTileY = (float) MapUtils.getTileNumberY(zoom, latitude) - oyTile;
|
||||
return (int) ((dTileY * zoomFactor) + cy);
|
||||
}
|
||||
|
||||
public int getPixYFromTileYNoRot(double tileY) {
|
||||
float dTileY = (float) tileY - oyTile;
|
||||
return (int) ((dTileY * zoomFactor) + cy);
|
||||
}
|
||||
|
||||
|
||||
private boolean isMapRotateEnabled() {
|
||||
return rotate != 0;
|
||||
|
@ -281,6 +293,14 @@ public class RotatedTileBox {
|
|||
calculateDerivedFields();
|
||||
}
|
||||
|
||||
public void increasePixelDimensions(int dwidth, int dheight) {
|
||||
this.pixWidth += 2 * dwidth;
|
||||
this.pixHeight += 2 * dheight;
|
||||
this.cx += dwidth;
|
||||
this.cy += dheight;
|
||||
calculateDerivedFields();
|
||||
}
|
||||
|
||||
public void setPixelDimensions(int width, int height) {
|
||||
setPixelDimensions(width, height, 0.5f, 0.5f);
|
||||
}
|
||||
|
@ -293,6 +313,19 @@ public class RotatedTileBox {
|
|||
calculateDerivedFields();
|
||||
}
|
||||
|
||||
public boolean isZoomAnimated() {
|
||||
return zoomAnimation != 0;
|
||||
}
|
||||
|
||||
public float getZoomAnimation() {
|
||||
return zoomAnimation;
|
||||
}
|
||||
|
||||
public void setZoomAnimation(float z) {
|
||||
this.zoomAnimation = z;
|
||||
calculateDerivedFields();
|
||||
}
|
||||
|
||||
public void setCenterLocation(float ratiocx, float ratiocy) {
|
||||
this.cx = (int) (pixWidth * ratiocx);
|
||||
this.cy = (int) (pixHeight * ratiocy);
|
||||
|
@ -320,6 +353,13 @@ public class RotatedTileBox {
|
|||
calculateDerivedFields();
|
||||
}
|
||||
|
||||
public void setZoom(int zoom, float zoomScale, float zoomToAnimate) {
|
||||
this.zoom = zoom;
|
||||
this.zoomScale = zoomScale;
|
||||
this.zoomAnimation = zoomToAnimate;
|
||||
calculateDerivedFields();
|
||||
}
|
||||
|
||||
public float getZoomScale() {
|
||||
return zoomScale;
|
||||
}
|
||||
|
|
|
@ -1,199 +0,0 @@
|
|||
package net.osmand.plus;
|
||||
import net.osmand.data.QuadPoint;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
public class RotatedTileBox {
|
||||
private float leftTileX;
|
||||
private float topTileY;
|
||||
private float tileWidth;
|
||||
private float tileHeight;
|
||||
private float rotate;
|
||||
private float zoom;
|
||||
private float rotateCos;
|
||||
private float rotateSin;
|
||||
private QuadRect latLonBounds;
|
||||
private int pixelWidth;
|
||||
private int pixelHeight;
|
||||
|
||||
|
||||
|
||||
public RotatedTileBox(float leftTileX, float topTileY, float tileWidth, float tileHeight, float rotate, int zoom) {
|
||||
set(leftTileX, topTileY, tileWidth, tileHeight, rotate, zoom);
|
||||
}
|
||||
|
||||
public RotatedTileBox(RotatedTileBox r){
|
||||
set(r.leftTileX, r.topTileY, r.tileWidth, r.tileHeight, r.rotate, r.zoom);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
float rad = (float) Math.toRadians(this.rotate);
|
||||
rotateCos = (float) Math.cos(rad);
|
||||
rotateSin = (float) Math.sin(rad);
|
||||
}
|
||||
|
||||
public void set(float leftTileX, float topTileY, float tileWidth, float tileHeight, float rotate, float zoom) {
|
||||
this.leftTileX = leftTileX;
|
||||
if(rotate < 0){
|
||||
rotate += 360;
|
||||
} else if(rotate > 360){
|
||||
rotate -= 360;
|
||||
}
|
||||
this.rotate = rotate;
|
||||
this.tileHeight = tileHeight;
|
||||
this.tileWidth = tileWidth;
|
||||
this.topTileY = topTileY;
|
||||
this.zoom = zoom;
|
||||
init();
|
||||
latLonBounds = calculateLatLonBox(new QuadRect());
|
||||
}
|
||||
|
||||
|
||||
public int getPixelWidth() {
|
||||
return pixelWidth;
|
||||
}
|
||||
|
||||
public int getPixelHeight() {
|
||||
return pixelHeight;
|
||||
}
|
||||
|
||||
public void setPixelDimensions(int width, int height) {
|
||||
this.pixelHeight = height;
|
||||
this.pixelWidth = width;
|
||||
}
|
||||
|
||||
|
||||
public QuadRect getLatLonBounds() {
|
||||
return latLonBounds;
|
||||
}
|
||||
|
||||
public float getRotateCos() {
|
||||
return rotateCos;
|
||||
}
|
||||
|
||||
public float getRotateSin() {
|
||||
return rotateSin;
|
||||
}
|
||||
|
||||
public float getZoom() {
|
||||
return zoom;
|
||||
}
|
||||
|
||||
public int getIntZoom() {
|
||||
return Math.round(zoom);
|
||||
}
|
||||
|
||||
public float getRotate() {
|
||||
return rotate;
|
||||
}
|
||||
|
||||
public float getTileHeight() {
|
||||
return tileHeight;
|
||||
}
|
||||
|
||||
public float getTileWidth() {
|
||||
return tileWidth;
|
||||
}
|
||||
|
||||
public float getLeftTileX() {
|
||||
return leftTileX;
|
||||
}
|
||||
|
||||
public float getTopTileY() {
|
||||
return topTileY;
|
||||
}
|
||||
|
||||
public boolean containsTileBox(RotatedTileBox box) {
|
||||
QuadPoint temp = new QuadPoint();
|
||||
if(box.zoom != zoom){
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
box.calcPointTile(0, 0, temp);
|
||||
if(!containsPoint(temp.x, temp.y)){
|
||||
return false;
|
||||
}
|
||||
box.calcPointTile(box.tileWidth, 0, temp);
|
||||
if(!containsPoint(temp.x, temp.y)){
|
||||
return false;
|
||||
}
|
||||
box.calcPointTile(0, box.tileHeight, temp);
|
||||
if(!containsPoint(temp.x, temp.y)){
|
||||
return false;
|
||||
}
|
||||
box.calcPointTile(box.tileWidth, box.tileHeight, temp);
|
||||
if(!containsPoint(temp.x, temp.y)){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private QuadRect calculateLatLonBox(QuadRect rectF) {
|
||||
float tx = calcPointTileX(tileWidth, 0);
|
||||
float tx2 = calcPointTileX(tileWidth, tileHeight);
|
||||
float tx3 = calcPointTileX(0, tileHeight);
|
||||
float minTileX = Math.min(Math.min(leftTileX, tx), Math.min(tx2, tx3)) ;
|
||||
float maxTileX = Math.max(Math.max(leftTileX, tx), Math.max(tx2, tx3)) ;
|
||||
int max = (int) MapUtils.getPowZoom(zoom);
|
||||
if(minTileX < 0){
|
||||
minTileX = 0;
|
||||
}
|
||||
if(maxTileX > max){
|
||||
maxTileX = max;
|
||||
}
|
||||
|
||||
rectF.left = (float) MapUtils.getLongitudeFromTile(zoom, minTileX);
|
||||
rectF.right = (float) MapUtils.getLongitudeFromTile(zoom, maxTileX);
|
||||
|
||||
float ty = calcPointTileY(tileWidth, 0);
|
||||
float ty2 = calcPointTileY(tileWidth, tileHeight);
|
||||
float ty3 = calcPointTileY(0, tileHeight);
|
||||
|
||||
float minTileY = Math.min(Math.min(topTileY, ty), Math.min(ty2, ty3)) ;
|
||||
float maxTileY = Math.max(Math.max(topTileY, ty), Math.max(ty2, ty3)) ;
|
||||
if(minTileY < 0){
|
||||
minTileY = 0;
|
||||
}
|
||||
if(maxTileY > max){
|
||||
maxTileY = max;
|
||||
}
|
||||
|
||||
rectF.top = (float) MapUtils.getLatitudeFromTile(zoom, minTileY);
|
||||
rectF.bottom = (float) MapUtils.getLatitudeFromTile(zoom, maxTileY);
|
||||
|
||||
return rectF;
|
||||
}
|
||||
|
||||
public boolean containsPoint(float tileX, float tileY) {
|
||||
tileX -= leftTileX;
|
||||
tileY -= topTileY;
|
||||
double tx = rotateCos * tileX - rotateSin * tileY;
|
||||
double ty = rotateSin * tileX + rotateCos * tileY;
|
||||
return tx >= 0 && tx <= tileWidth && ty >= 0 && ty <= tileHeight;
|
||||
}
|
||||
|
||||
protected QuadPoint calcPointTile(float dx, float dy, QuadPoint p){
|
||||
float tx = rotateCos * dx + rotateSin * dy + leftTileX;
|
||||
float ty = - rotateSin * dx + rotateCos * dy + topTileY;
|
||||
p.set(tx, ty);
|
||||
return p;
|
||||
}
|
||||
|
||||
protected float calcPointTileX(float dx, float dy){
|
||||
return rotateCos * dx + rotateSin * dy + leftTileX;
|
||||
}
|
||||
|
||||
protected float calcPointTileY(float dx, float dy){
|
||||
return - rotateSin * dx + rotateCos * dy + topTileY;
|
||||
}
|
||||
|
||||
public float getRightBottomTileX() {
|
||||
return calcPointTileX(tileWidth, tileHeight);
|
||||
}
|
||||
|
||||
public float getRightBottomTileY() {
|
||||
return calcPointTileY(tileWidth, tileHeight);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -81,9 +81,9 @@ public class IntermediatePointsDialog {
|
|||
if (activity instanceof MapActivity) {
|
||||
// AnimateDraggingMapThread thread = mapActivity.getMapView().getAnimatedDraggingThread();
|
||||
LatLon pointToNavigate = intermediates.get(position);
|
||||
float fZoom = ((MapActivity) activity).getMapView().getFloatZoom() < 15 ? 15 : ((MapActivity) activity).getMapView().getFloatZoom();
|
||||
int fZoom = ((MapActivity) activity).getMapView().getZoom() < 15 ? 15 : ((MapActivity) activity).getMapView().getZoom();
|
||||
// thread.startMoving(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(), fZoom, true);
|
||||
((MapActivity) activity).getMapView().setZoom(fZoom);
|
||||
((MapActivity) activity).getMapView().setIntZoom(fZoom);
|
||||
((MapActivity) activity).getMapView().setLatLon(pointToNavigate.getLatitude(), pointToNavigate.getLongitude());
|
||||
listadapter.notifyDataSetInvalidated();
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ public class MapActivity extends AccessibleActivity {
|
|||
net.osmand.Location location = app.getLocationProvider().getFirstTimeRunDefaultLocation();
|
||||
if(location != null){
|
||||
mapView.setLatLon(location.getLatitude(), location.getLongitude());
|
||||
mapView.setZoom(14);
|
||||
mapView.setIntZoom(14);
|
||||
}
|
||||
}
|
||||
addDialogProvider(mapActions);
|
||||
|
@ -290,7 +290,7 @@ public class MapActivity extends AccessibleActivity {
|
|||
if (settings != null && settings.isLastKnownMapLocation()) {
|
||||
LatLon l = settings.getLastKnownMapLocation();
|
||||
mapView.setLatLon(l.getLatitude(), l.getLongitude());
|
||||
mapView.setZoom(settings.getLastKnownMapZoom());
|
||||
mapView.setIntZoom(settings.getLastKnownMapZoom());
|
||||
}
|
||||
|
||||
settings.MAP_ACTIVITY_ENABLED.set(true);
|
||||
|
@ -362,9 +362,10 @@ public class MapActivity extends AccessibleActivity {
|
|||
}
|
||||
}
|
||||
|
||||
public void changeZoom(float newZoom){
|
||||
newZoom = Math.round(newZoom * OsmandMapTileView.ZOOM_DELTA) * OsmandMapTileView.ZOOM_DELTA_1;
|
||||
public void changeZoom(int stp){
|
||||
// delta = Math.round(delta * OsmandMapTileView.ZOOM_DELTA) * OsmandMapTileView.ZOOM_DELTA_1;
|
||||
boolean changeLocation = settings.AUTO_ZOOM_MAP.get();
|
||||
final int newZoom = mapView.getZoom() + stp;
|
||||
mapView.getAnimatedDraggingThread().startZooming(newZoom, changeLocation);
|
||||
if (app.getInternalAPI().accessibilityEnabled())
|
||||
AccessibleToast.makeText(this, getString(R.string.zoomIs) + " " + newZoom, Toast.LENGTH_SHORT).show(); //$NON-NLS-1$
|
||||
|
@ -403,13 +404,13 @@ public class MapActivity extends AccessibleActivity {
|
|||
// Find more appropriate plugin for it?
|
||||
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && event.getRepeatCount() == 0) {
|
||||
if (mapView.isZooming()) {
|
||||
changeZoom(mapView.getZoom() + 2);
|
||||
changeZoom(+ 2);
|
||||
} else {
|
||||
changeZoom(mapView.getZoom() + 1);
|
||||
changeZoom(+ 1);
|
||||
}
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && event.getRepeatCount() == 0) {
|
||||
changeZoom(mapView.getZoom() - 1);
|
||||
changeZoom(- 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -519,9 +520,9 @@ public class MapActivity extends AccessibleActivity {
|
|||
|
||||
settings.setLastKnownMapLocation((float) mapView.getLatitude(), (float) mapView.getLongitude());
|
||||
AnimateDraggingMapThread animatedThread = mapView.getAnimatedDraggingThread();
|
||||
if(animatedThread.isAnimating() && animatedThread.getTargetZoom() != 0){
|
||||
if(animatedThread.isAnimating() && animatedThread.getTargetIntZoom() != 0){
|
||||
settings.setMapLocationToShow(animatedThread.getTargetLatitude(), animatedThread.getTargetLongitude(),
|
||||
(int) animatedThread.getTargetZoom());
|
||||
animatedThread.getTargetIntZoom());
|
||||
}
|
||||
|
||||
settings.setLastKnownMapZoom(mapView.getZoom());
|
||||
|
@ -573,10 +574,10 @@ public class MapActivity extends AccessibleActivity {
|
|||
} else if (settings.ZOOM_BY_TRACKBALL.get()) {
|
||||
// Parrot device has only dpad left and right
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
|
||||
changeZoom(mapView.getZoom() - 1);
|
||||
changeZoom(- 1);
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
|
||||
changeZoom(mapView.getZoom() + 1);
|
||||
changeZoom( 1);
|
||||
return true;
|
||||
}
|
||||
} else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT ||
|
||||
|
|
|
@ -390,7 +390,7 @@ public class MapActivityLayers {
|
|||
WptPt loc = toShow.findPointToShow();
|
||||
if(loc != null){
|
||||
mapView.getAnimatedDraggingThread().startMoving(loc.lat, loc.lon,
|
||||
mapView.getFloatZoom(), true);
|
||||
mapView.getZoom(), true);
|
||||
}
|
||||
mapView.refreshMap();
|
||||
return true;
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.base;
|
|||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.map.IMapLocationListener;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
|
||||
|
@ -150,13 +151,11 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
}
|
||||
}
|
||||
|
||||
private float defineZoomFromSpeed(float speed) {
|
||||
private float defineZoomFromSpeed(RotatedTileBox tb, float speed) {
|
||||
if (speed < 7f / 3.6) {
|
||||
return 0;
|
||||
}
|
||||
double topLat = mapView.calcLatitude(-mapView.getCenterPointY());
|
||||
double cLat = mapView.calcLatitude(0);
|
||||
double visibleDist = MapUtils.getDistance(cLat, mapView.getLongitude(), topLat, mapView.getLongitude());
|
||||
double visibleDist = tb.getDistance(tb.getCenterPixelX(), 0, tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
float time = 75f;
|
||||
if (speed < 83f / 3.6) {
|
||||
time = 60f;
|
||||
|
@ -165,8 +164,9 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
float zoomDelta = (float) (Math.log(visibleDist / distToSee) / Math.log(2.0f));
|
||||
zoomDelta = Math.round(zoomDelta * OsmandMapTileView.ZOOM_DELTA) * OsmandMapTileView.ZOOM_DELTA_1;
|
||||
// check if 17, 18 is correct?
|
||||
if (zoomDelta + mapView.getFloatZoom() > 18 - OsmandMapTileView.ZOOM_DELTA_1) {
|
||||
return 18 - OsmandMapTileView.ZOOM_DELTA_1 - mapView.getFloatZoom();
|
||||
final float zoomScale = tb.getZoom() + tb.getZoomScale();
|
||||
if (zoomDelta + zoomScale > 18 - OsmandMapTileView.ZOOM_DELTA_1) {
|
||||
return 18 - OsmandMapTileView.ZOOM_DELTA_1 - zoomScale ;
|
||||
}
|
||||
return zoomDelta;
|
||||
}
|
||||
|
@ -174,7 +174,8 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
public void autozoom(Location location) {
|
||||
if (location.hasSpeed()) {
|
||||
long now = System.currentTimeMillis();
|
||||
float zdelta = defineZoomFromSpeed(location.getSpeed());
|
||||
final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
|
||||
float zdelta = defineZoomFromSpeed(tb, location.getSpeed());
|
||||
if (Math.abs(zdelta) >= OsmandMapTileView.ZOOM_DELTA_1) {
|
||||
// prevent ui hysteresis (check time interval for autozoom)
|
||||
if (zdelta >= 2) {
|
||||
|
@ -186,9 +187,12 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
}
|
||||
if (now - lastTimeAutoZooming > 4500) {
|
||||
lastTimeAutoZooming = now;
|
||||
float newZoom = Math.round((mapView.getFloatZoom() + zdelta) * OsmandMapTileView.ZOOM_DELTA)
|
||||
float complexZoom = tb.getZoom() + tb.getZoomScale();
|
||||
float newZoom = Math.round((complexZoom + zdelta) * OsmandMapTileView.ZOOM_DELTA)
|
||||
* OsmandMapTileView.ZOOM_DELTA_1;
|
||||
mapView.setZoom(newZoom);
|
||||
// TODO test round final int tz = Math.round(newZoom);
|
||||
final int tz = (int)newZoom;
|
||||
mapView.setComplexZoom(tz, newZoom - tz);
|
||||
// mapView.getAnimatedDraggingThread().startZooming(mapView.getFloatZoom() + zdelta, false);
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +207,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
if (locationProvider.getLastKnownLocation() != null) {
|
||||
net.osmand.Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
||||
AnimateDraggingMapThread thread = mapView.getAnimatedDraggingThread();
|
||||
float fZoom = mapView.getFloatZoom() < 15 ? 15 : mapView.getFloatZoom();
|
||||
int fZoom = mapView.getZoom() < 15 ? 15 : mapView.getZoom();
|
||||
thread.startMoving(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), fZoom, false);
|
||||
}
|
||||
mapView.refreshMap();
|
||||
|
|
|
@ -67,8 +67,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
private List<LinkedList<WptPt>> measurementPoints = new ArrayList<LinkedList<WptPt>>();
|
||||
private GPXFile originalGPX;
|
||||
private String distance = null;
|
||||
private DisplayMetrics dm;
|
||||
|
||||
|
||||
private int distanceMeasurementMode = 0;
|
||||
|
||||
public DistanceCalculatorPlugin(OsmandApplication app) {
|
||||
|
@ -215,7 +214,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
OsmandMapTileView mapView = activity.getMapView();
|
||||
if(pt != null){
|
||||
mapView.getAnimatedDraggingThread().startMoving(pt.lat, pt.lon,
|
||||
mapView.getFloatZoom(), true);
|
||||
mapView.getZoom(), true);
|
||||
}
|
||||
}
|
||||
calculateDistance();
|
||||
|
@ -411,9 +410,6 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
@Override
|
||||
public void initLayer(OsmandMapTileView view) {
|
||||
this.view = view;
|
||||
dm = new DisplayMetrics();
|
||||
WindowManager wmgr = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
wmgr.getDefaultDisplay().getMetrics(dm);
|
||||
originIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_origin);
|
||||
destinationIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pin_destination);
|
||||
bitmapPaint = new Paint();
|
||||
|
@ -425,7 +421,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
int distanceColor = view.getResources().getColor(R.color.distance_color);
|
||||
paint = new Paint();
|
||||
paint.setStyle(Style.STROKE);
|
||||
paint.setStrokeWidth(7 * dm.density);
|
||||
paint.setStrokeWidth(7 * view.getDensity());
|
||||
paint.setAntiAlias(true);
|
||||
paint.setStrokeCap(Cap.ROUND);
|
||||
paint.setStrokeJoin(Join.ROUND);
|
||||
|
@ -440,7 +436,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
@Override
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
if(distanceMeasurementMode == 1) {
|
||||
LatLon l = view.getLatLonFromScreenPoint(point.x, point.y);
|
||||
LatLon l = tileBox.getLatLonFromPixel(point.x, point.y);
|
||||
if(measurementPoints.size() == 0) {
|
||||
measurementPoints.add(new LinkedList<GPXUtilities.WptPt>());
|
||||
}
|
||||
|
@ -482,8 +478,8 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
boolean first = true;
|
||||
while (it.hasNext()) {
|
||||
WptPt point = it.next();
|
||||
int locationX = view.getMapXForPoint(point.lon);
|
||||
int locationY = view.getMapYForPoint(point.lat);
|
||||
int locationX = tileBox.getPixXFromLonNoRot(point.lon);
|
||||
int locationY = tileBox.getPixYFromLatNoRot(point.lat);
|
||||
if (first) {
|
||||
path.moveTo(locationX, locationY);
|
||||
first = false;
|
||||
|
@ -498,9 +494,9 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
boolean first = true;
|
||||
while(it.hasNext()) {
|
||||
WptPt pt = it.next();
|
||||
if (view.isPointOnTheRotatedMap(pt.lat, pt.lon)) {
|
||||
int locationX = view.getMapXForPoint(pt.lon);
|
||||
int locationY = view.getMapYForPoint(pt.lat);
|
||||
if (tileBox.containsLatLon(pt.lat, pt.lon)) {
|
||||
int locationX = tileBox.getPixXFromLonNoRot(pt.lon);
|
||||
int locationY = tileBox.getPixYFromLatNoRot(pt.lat);
|
||||
|
||||
if(first || !it.hasNext() || pt.desc != null) {
|
||||
canvas.rotate(-view.getRotate(), locationX, locationY);
|
||||
|
@ -508,7 +504,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
locationX - marginX, locationY - marginY, bitmapPaint);
|
||||
canvas.rotate(view.getRotate(), locationX, locationY);
|
||||
} else {
|
||||
canvas.drawCircle(locationX, locationY, 10 * dm.density, paint2);
|
||||
canvas.drawCircle(locationX, locationY, 10 * tileBox.getDensity(), paint2);
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
|
@ -528,12 +524,12 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
|
||||
@Override
|
||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
|
||||
getMPointsFromPoint(point, o);
|
||||
getMPointsFromPoint(tileBox, point, o);
|
||||
}
|
||||
|
||||
public void getMPointsFromPoint(PointF point, List<? super WptPt> res) {
|
||||
int r = (int) (14 * dm.density);
|
||||
int rs = (int) (10 * dm.density);
|
||||
public void getMPointsFromPoint(RotatedTileBox tb, PointF point, List<? super WptPt> res) {
|
||||
int r = (int) (14 * tb.getDensity());
|
||||
int rs = (int) (10 * tb.getDensity());
|
||||
int ex = (int) point.x;
|
||||
int ey = (int) point.y;
|
||||
for (int i = 0; i < measurementPoints.size(); i++) {
|
||||
|
@ -541,8 +537,8 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
boolean first = true;
|
||||
while (it.hasNext()) {
|
||||
WptPt pt = it.next();
|
||||
int x = view.getRotatedMapXForPoint(pt.lat, pt.lon);
|
||||
int y = view.getRotatedMapYForPoint(pt.lat, pt.lon);
|
||||
int x = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
int y = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
if (pt.desc != null || !it.hasNext() || first) {
|
||||
if (calculateBelongsBig(ex, ey, x, y, r)) {
|
||||
res.add(pt);
|
||||
|
|
|
@ -92,7 +92,7 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox latLonBounds, DrawSettings nightMode) {
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) {
|
||||
|
||||
for (OsMoDroidPoint op : OsMoDroidPointArrayList) {
|
||||
LatLon newLatlon;
|
||||
|
@ -121,12 +121,10 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
|||
prevlongitude = op.prevlatlon.getLongitude();
|
||||
}
|
||||
|
||||
// int locationX = view.getMapXForPoint(longitude);
|
||||
// int locationY = view.getMapYForPoint(latitude);
|
||||
int locationX = view.getRotatedMapXForPoint(latitude, longitude);
|
||||
int locationY = view.getRotatedMapYForPoint(latitude, longitude);
|
||||
int prevlocationX = view.getRotatedMapXForPoint(prevlatitude, prevlongitude);
|
||||
int prevlocationY = view.getRotatedMapYForPoint(prevlatitude, prevlongitude);
|
||||
int locationX = tb.getPixXFromLatLon(latitude, longitude);
|
||||
int locationY = tb.getPixYFromLatLon(latitude, longitude);
|
||||
int prevlocationX = tb.getPixXFromLatLon(prevlatitude, prevlongitude);
|
||||
int prevlocationY = tb.getPixYFromLatLon(prevlatitude, prevlongitude);
|
||||
|
||||
// int y = opIcon.getHeight()/2;
|
||||
// int x = opIcon.getWidth()/2;
|
||||
|
@ -145,7 +143,7 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
|||
}
|
||||
}
|
||||
|
||||
public void getOsMoDroidPointFromPoint(PointF point, List<? super OsMoDroidPoint> om) {
|
||||
public void getOsMoDroidPointFromPoint(RotatedTileBox tb,PointF point, List<? super OsMoDroidPoint> om) {
|
||||
if (myOsMoDroidPlugin.getOsMoDroidPointArrayList(layerId) != null) {
|
||||
int ex = (int) point.x;
|
||||
int ey = (int) point.y;
|
||||
|
@ -154,8 +152,8 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
|||
for (int i = 0; i < myOsMoDroidPlugin.getOsMoDroidPointArrayList(layerId).size(); i++) {
|
||||
OsMoDroidPoint n = myOsMoDroidPlugin.getOsMoDroidPointArrayList(layerId).get(i);
|
||||
if (!om.contains(n)) {
|
||||
int x = view.getRotatedMapXForPoint(n.latlon.getLatitude(), n.latlon.getLongitude());
|
||||
int y = view.getRotatedMapYForPoint(n.latlon.getLatitude(), n.latlon.getLongitude());
|
||||
int x = tb.getPixXFromLatLon(n.latlon.getLatitude(), n.latlon.getLongitude());
|
||||
int y = tb.getPixYFromLatLon(n.latlon.getLatitude(), n.latlon.getLongitude());
|
||||
if (Math.abs(x - ex) <= opIcon.getWidth() && Math.abs(y - ey) <= opIcon.getHeight()) {
|
||||
om.add(n);
|
||||
}
|
||||
|
@ -187,7 +185,7 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
|||
@Override
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
List<OsMoDroidPoint> om = new ArrayList<OsMoDroidPoint>();
|
||||
getOsMoDroidPointFromPoint(point, om);
|
||||
getOsMoDroidPointFromPoint(tileBox, point, om);
|
||||
if (!om.isEmpty()) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (int i = 0; i < om.size(); i++) {
|
||||
|
@ -223,7 +221,7 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
|||
|
||||
@Override
|
||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
|
||||
getOsMoDroidPointFromPoint(point, o);
|
||||
getOsMoDroidPointFromPoint(tileBox, point, o);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox latLonBounds, DrawSettings nightMode) {
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) {
|
||||
LatLon parkingPoint = getParkingPoint();
|
||||
if (parkingPoint == null)
|
||||
return;
|
||||
|
@ -88,11 +88,11 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
|
|||
}
|
||||
double latitude = parkingPoint.getLatitude();
|
||||
double longitude = parkingPoint.getLongitude();
|
||||
if (isLocationVisible(latitude, longitude)) {
|
||||
if (isLocationVisible(tb, latitude, longitude)) {
|
||||
int marginX = parkingNoLimitIcon.getWidth() / 2;
|
||||
int marginY = parkingNoLimitIcon.getHeight();
|
||||
int locationX = view.getMapXForPoint(longitude);
|
||||
int locationY = view.getMapYForPoint(latitude);
|
||||
int locationX = tb.getPixXFromLonNoRot(longitude);
|
||||
int locationY = tb.getPixYFromLatNoRot(latitude);
|
||||
canvas.rotate(-view.getRotate(), locationX, locationY);
|
||||
canvas.drawBitmap(parkingIcon, locationX - marginX, locationY - marginY, bitmapPaint);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
|
|||
@Override
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
List <LatLon> parkPos = new ArrayList<LatLon>();
|
||||
getParkingFromPoint(point, parkPos);
|
||||
getParkingFromPoint(tileBox, point, parkPos);
|
||||
if(!parkPos.isEmpty()){
|
||||
StringBuilder res = new StringBuilder();
|
||||
res.append(view.getContext().getString(R.string.osmand_parking_position_description));
|
||||
|
@ -122,7 +122,7 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
|
|||
|
||||
@Override
|
||||
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
|
||||
getParkingFromPoint(point, o);
|
||||
getParkingFromPoint(tileBox, point, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -192,11 +192,11 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
|
|||
* @param longitude
|
||||
* @return true if the parking point is located on a visible part of map
|
||||
*/
|
||||
private boolean isLocationVisible(double latitude, double longitude){
|
||||
private boolean isLocationVisible(RotatedTileBox tb, double latitude, double longitude){
|
||||
if(getParkingPoint() == null || view == null){
|
||||
return false;
|
||||
}
|
||||
return view.isPointOnTheRotatedMap(latitude, longitude);
|
||||
return tb.containsLatLon(latitude, longitude);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -204,14 +204,14 @@ public class ParkingPositionLayer extends OsmandMapLayer implements ContextMenuL
|
|||
* @param parkingPosition is in this case not necessarily has to be a list,
|
||||
* but it's also used in method <link>collectObjectsFromPoint(PointF point, List<Object> o)</link>
|
||||
*/
|
||||
private void getParkingFromPoint(PointF point, List<? super LatLon> parkingPosition) {
|
||||
private void getParkingFromPoint(RotatedTileBox tb,PointF point, List<? super LatLon> parkingPosition) {
|
||||
LatLon parkingPoint = getParkingPoint();
|
||||
if (parkingPoint != null && view != null) {
|
||||
int ex = (int) point.x;
|
||||
int ey = (int) point.y;
|
||||
LatLon position = plugin.getParkingPosition();
|
||||
int x = view.getRotatedMapXForPoint(position.getLatitude(), position.getLongitude());
|
||||
int y = view.getRotatedMapYForPoint(position.getLatitude(), position.getLongitude());
|
||||
int x = tb.getPixXFromLatLon(position.getLatitude(), position.getLongitude());
|
||||
int y = tb.getPixYFromLatLon(position.getLatitude(), position.getLongitude());
|
||||
// the width of an image is 40 px, the height is 60 px -> radius = 20,
|
||||
// the position of a parking point relatively to the icon is at the center of the bottom line of the image
|
||||
if (Math.abs(x - ex) <= radius && ((y - ey) <= radius * 2) && ((y - ey) >= -radius)) {
|
||||
|
|
|
@ -496,7 +496,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
AnimateDraggingMapThread thread = view.getAnimatedDraggingThread();
|
||||
LatLon parkingPoint = parkingPosition;
|
||||
if (parkingPoint != null) {
|
||||
float fZoom = view.getFloatZoom() < 15 ? 15 : view.getFloatZoom();
|
||||
int fZoom = view.getZoom() < 15 ? 15 : view.getZoom();
|
||||
thread.startMoving(parkingPoint.getLatitude(), parkingPoint.getLongitude(), fZoom, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,16 @@
|
|||
package net.osmand.plus.render;
|
||||
|
||||
import android.graphics.*;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.plus.views.BaseMapLayer;
|
||||
import net.osmand.plus.views.MapTileLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.util.MapUtils;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
|
||||
public class MapVectorLayer extends BaseMapLayer {
|
||||
|
||||
private OsmandMapTileView view;
|
||||
private Rect pixRect = new Rect();
|
||||
private RotatedTileBox rotatedTileBox =
|
||||
new RotatedTileBox.RotatedTileBoxBuilder().setPixelDimensions(0, 0).
|
||||
setLocation(0, 0).setZoomAndScale(5, 0).build();
|
||||
private ResourceManager resourceManager;
|
||||
private Paint paintImg;
|
||||
|
||||
|
@ -50,14 +41,6 @@ public class MapVectorLayer extends BaseMapLayer {
|
|||
paintImg.setAlpha(getAlpha());
|
||||
}
|
||||
|
||||
private void updateRotatedTileBox(){
|
||||
float mult = (float) Math.pow(2, view.getFloatZoom() - view.getZoom());
|
||||
float xL = (view.calcDiffTileX(pixRect.left - view.getCenterPointX(), pixRect.top - view.getCenterPointY()) + view.getXTile());
|
||||
float yT = (view.calcDiffTileY(pixRect.left - view.getCenterPointX(), pixRect.top - view.getCenterPointY()) + view.getYTile()) ;
|
||||
float ts = view.getSourceTileSize();
|
||||
rotatedTileBox.set(xL * mult, yT * mult, ((float) pixRect.width()) / ts , ((float) pixRect.height()) / ts, view.getRotate(), view.getFloatZoom());
|
||||
}
|
||||
|
||||
public boolean isVectorDataVisible() {
|
||||
return visible && view.getZoom() >= view.getSettings().LEVEL_TO_SWITCH_VECTOR_RASTER.get();
|
||||
}
|
||||
|
@ -95,20 +78,18 @@ public class MapVectorLayer extends BaseMapLayer {
|
|||
resourceManager.getRenderer().interruptLoadingMap();
|
||||
} else {
|
||||
if (!view.isZooming()) {
|
||||
pixRect.set(0, 0, view.getWidth(), view.getHeight());
|
||||
updateRotatedTileBox();
|
||||
if (resourceManager.updateRenderedMapNeeded(rotatedTileBox, drawSettings)) {
|
||||
if (resourceManager.updateRenderedMapNeeded(tilesRect, drawSettings)) {
|
||||
// pixRect.set(-view.getWidth(), -view.getHeight() / 2, 2 * view.getWidth(), 3 * view.getHeight() / 2);
|
||||
pixRect.set(-view.getWidth() / 3, -view.getHeight() / 4, 4 * view.getWidth() / 3, 5 * view.getHeight() / 4);
|
||||
updateRotatedTileBox();
|
||||
resourceManager.updateRendererMap(rotatedTileBox);
|
||||
final RotatedTileBox copy = tilesRect.copy();
|
||||
copy.increasePixelDimensions(copy.getPixWidth() / 3, copy.getPixHeight() / 4);
|
||||
resourceManager.updateRendererMap(copy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MapRenderRepositories renderer = resourceManager.getRenderer();
|
||||
drawRenderedMap(canvas, renderer.getBitmap(), renderer.getBitmapLocation());
|
||||
drawRenderedMap(canvas, renderer.getPrevBitmap(), renderer.getPrevBmpLocation());
|
||||
drawRenderedMap(canvas, renderer.getBitmap(), renderer.getBitmapLocation(), tilesRect);
|
||||
drawRenderedMap(canvas, renderer.getPrevBitmap(), renderer.getPrevBmpLocation(), tilesRect);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,30 +98,19 @@ public class MapVectorLayer extends BaseMapLayer {
|
|||
boolean shown = false;
|
||||
if (bmp != null && bmpLoc != null) {
|
||||
float rot = bmpLoc.getRotate();
|
||||
bmpLoc.getLeftTopTilePoint()
|
||||
float mult = (float) MapUtils.getPowZoom(view.getZoom() - bmpLoc.getZoom());
|
||||
float fmult = (float) MapUtils.getPowZoom(view.getFloatZoom() - bmpLoc.getZoom());
|
||||
|
||||
float tx = view.getXTile() / mult;
|
||||
float ty = view.getYTile() / mult;
|
||||
float dleftX1 = bmpLoc.getLeftTileX() - tx;
|
||||
float dtopY1 = bmpLoc.getTopTileY() - ty;
|
||||
|
||||
float ts = view.getSourceTileSize() * fmult;
|
||||
|
||||
float cos = bmpLoc.getRotateCos();
|
||||
float sin = bmpLoc.getRotateSin();
|
||||
float x1 = MapUtils.calcDiffPixelX(sin, cos, dleftX1, dtopY1, ts) + view.getCenterPointX();
|
||||
float y1 = MapUtils.calcDiffPixelY(sin, cos, dleftX1, dtopY1, ts) + view.getCenterPointY();
|
||||
|
||||
canvas.rotate(-rot, view.getCenterPointX(), view.getCenterPointY());
|
||||
destImage.set(x1, y1, x1 + bmpLoc.getTileWidth() * ts, y1 +
|
||||
bmpLoc.getTileHeight() * ts);
|
||||
final LatLon lt = bmpLoc.getLeftTopLatLon();
|
||||
final LatLon rb = bmpLoc.getRightBottomLatLon();
|
||||
canvas.rotate(-rot, currentViewport.getCenterPixelX(), currentViewport.getCenterPixelY());
|
||||
final int x1 = currentViewport.getPixXFromLonNoRot(lt.getLongitude());
|
||||
final int y1 = currentViewport.getPixYFromLatNoRot(lt.getLatitude());
|
||||
final int x2 = currentViewport.getPixXFromLonNoRot(rb.getLongitude());
|
||||
final int y2 = currentViewport.getPixYFromLatNoRot(rb.getLatitude());
|
||||
destImage.set(x1, y1, x2, y2);
|
||||
if(!bmp.isRecycled()){
|
||||
canvas.drawBitmap(bmp, null, destImage, paintImg);
|
||||
shown = true;
|
||||
}
|
||||
canvas.rotate(rot, view.getCenterPointX(), view.getCenterPointY());
|
||||
canvas.rotate(rot, currentViewport.getCenterPixelX(), currentViewport.getCenterPixelY());
|
||||
}
|
||||
return shown;
|
||||
}
|
||||
|
|
|
@ -837,8 +837,7 @@ public class ResourceManager {
|
|||
|
||||
public void updateRendererMap(RotatedTileBox rotatedTileBox){
|
||||
renderer.interruptLoadingMap();
|
||||
asyncLoadingThread.requestToLoadMap(
|
||||
new MapLoadRequest(rotatedTileBox.copy()));
|
||||
asyncLoadingThread.requestToLoadMap(new MapLoadRequest(rotatedTileBox));
|
||||
}
|
||||
|
||||
public void interruptRendering(){
|
||||
|
|
|
@ -32,7 +32,8 @@ public class AnimateDraggingMapThread {
|
|||
private float targetRotate = 0;
|
||||
private double targetLatitude = 0;
|
||||
private double targetLongitude = 0;
|
||||
private float targetZoom = 0;
|
||||
private int targetIntZoom = 0;
|
||||
private float targetZoomScale = 0;
|
||||
|
||||
|
||||
public AnimateDraggingMapThread(OsmandMapTileView tileView){
|
||||
|
@ -106,13 +107,17 @@ public class AnimateDraggingMapThread {
|
|||
currentThread.start();
|
||||
|
||||
}
|
||||
|
||||
public void startMoving(final double finalLat, final double finalLon, final int endZoom, final boolean notifyListener){
|
||||
startMoving(finalLat, finalLon, endZoom, tileView.getZoomScale(), notifyListener);
|
||||
}
|
||||
|
||||
public void startMoving(final double finalLat, final double finalLon, final float endZoom, final boolean notifyListener){
|
||||
public void startMoving(final double finalLat, final double finalLon, final int endZoom, final float endZoomScale, final boolean notifyListener){
|
||||
stopAnimatingSync();
|
||||
double startLat = tileView.getLatitude();
|
||||
double startLon = tileView.getLongitude();
|
||||
float rotate = tileView.getRotate();
|
||||
final float startZoom = tileView.getFloatZoom();
|
||||
final float startZoom = tileView.getZoom() + tileView.getZoomScale();
|
||||
int tileSize = tileView.getSourceTileSize();
|
||||
|
||||
|
||||
|
@ -133,7 +138,7 @@ public class AnimateDraggingMapThread {
|
|||
skipAnimation = skipAnimation || (Math.abs(moveZoom - startZoom) >= 3 || Math.abs(endZoom - moveZoom) > 3);
|
||||
if (skipAnimation) {
|
||||
tileView.setLatLonAnimate(finalLat, finalLon, notifyListener);
|
||||
tileView.zoomToAnimate(endZoom, notifyListener);
|
||||
tileView.setZoomAnimate(endZoom, endZoomScale, notifyListener);
|
||||
return;
|
||||
}
|
||||
float rad = (float) Math.toRadians(rotate);
|
||||
|
@ -146,7 +151,7 @@ public class AnimateDraggingMapThread {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
setTargetValues(endZoom, finalLat, finalLon);
|
||||
setTargetValues(endZoom, endZoomScale, finalLat, finalLon);
|
||||
if(moveZoom != startZoom){
|
||||
animatingZoomInThread(startZoom, moveZoom, ZOOM_MOVE_ANIMATION_TIME, notifyListener);
|
||||
}
|
||||
|
@ -159,7 +164,12 @@ public class AnimateDraggingMapThread {
|
|||
}
|
||||
|
||||
if (!stopped && moveZoom != endZoom) {
|
||||
animatingZoomInThread(moveZoom, endZoom, ZOOM_MOVE_ANIMATION_TIME, notifyListener);
|
||||
animatingZoomInThread(moveZoom, endZoom + endZoomScale, ZOOM_MOVE_ANIMATION_TIME, notifyListener);
|
||||
}
|
||||
if(!stopped){
|
||||
tileView.setZoomAnimate(endZoom, endZoomScale, notifyListener);
|
||||
} else{
|
||||
tileView.setZoomAnimate(endZoom, endZoomScale, notifyListener);
|
||||
}
|
||||
|
||||
pendingRotateAnimation();
|
||||
|
@ -233,13 +243,13 @@ public class AnimateDraggingMapThread {
|
|||
}
|
||||
|
||||
|
||||
public void startZooming(final float zoomEnd, final boolean notifyListener){
|
||||
public void startZooming(final int zoomEnd, final boolean notifyListener){
|
||||
final float animationTime = ZOOM_ANIMATION_TIME;
|
||||
startThreadAnimating(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
final float zoomStart = tileView.getFloatZoom();
|
||||
setTargetValues(zoomEnd, tileView.getLatitude(), tileView.getLongitude());
|
||||
final float zoomStart = tileView.getZoom() + tileView.getZoomScale();
|
||||
setTargetValues(zoomEnd, tileView.getZoomScale(), tileView.getLatitude(), tileView.getLongitude());
|
||||
animatingZoomInThread(zoomStart, zoomEnd, animationTime, notifyListener);
|
||||
pendingRotateAnimation();
|
||||
}
|
||||
|
@ -287,11 +297,13 @@ public class AnimateDraggingMapThread {
|
|||
}
|
||||
|
||||
private void clearTargetValues(){
|
||||
targetZoom = 0;
|
||||
targetIntZoom = 0;
|
||||
targetZoomScale = 0;
|
||||
}
|
||||
|
||||
private void setTargetValues(float zoom, double lat, double lon){
|
||||
targetZoom = zoom;
|
||||
private void setTargetValues(int zoom, float zoomScale, double lat, double lon){
|
||||
targetIntZoom = zoom;
|
||||
targetZoomScale = zoomScale;
|
||||
targetLatitude = lat;
|
||||
targetLongitude = lon;
|
||||
}
|
||||
|
@ -314,10 +326,15 @@ public class AnimateDraggingMapThread {
|
|||
}
|
||||
}
|
||||
|
||||
public float getTargetZoom() {
|
||||
return targetZoom;
|
||||
|
||||
public int getTargetIntZoom() {
|
||||
return targetIntZoom;
|
||||
}
|
||||
|
||||
|
||||
public float getTargetZoomScale() {
|
||||
return targetZoomScale;
|
||||
}
|
||||
|
||||
public double getTargetLatitude() {
|
||||
return targetLatitude;
|
||||
}
|
||||
|
@ -328,3 +345,4 @@ public class AnimateDraggingMapThread {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -327,9 +327,9 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
if (view.isZooming()) {
|
||||
activity.changeZoom(Math.round(view.getFloatZoom() + 2 * ZOOM_DELTA));
|
||||
activity.changeZoom(2);
|
||||
} else {
|
||||
activity.changeZoom(Math.round(view.getFloatZoom() + 1 * ZOOM_DELTA));
|
||||
activity.changeZoom(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
zoomOutButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
activity.changeZoom(Math.round(view.getFloatZoom() - 1 * ZOOM_DELTA));
|
||||
activity.changeZoom(- 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import android.widget.*;
|
|||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.*;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivityActions;
|
||||
|
@ -528,7 +529,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox latlonBounds, DrawSettings drawSettings) {
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
|
||||
updateColorShadowsOfText(drawSettings);
|
||||
// update data on draw
|
||||
rightStack.updateInfo(drawSettings);
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.views;
|
|||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.RectF;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
|
||||
/**
|
||||
* This class is designed to represent adapter for specific map sources
|
||||
|
@ -17,7 +18,7 @@ public abstract class MapTileAdapter {
|
|||
this.view = view;
|
||||
}
|
||||
|
||||
public abstract void onDraw(Canvas canvas, RectF latlonRect, RectF tilesRect, boolean nightMode);
|
||||
public abstract void onDraw(Canvas canvas, RotatedTileBox tileBox, OsmandMapLayer.DrawSettings drawSettings);
|
||||
|
||||
public abstract void onClear();
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.map.TileSourceManager;
|
||||
|
@ -28,8 +29,6 @@ public class MapTileLayer extends BaseMapLayer {
|
|||
protected MapTileAdapter mapTileAdapter = null;
|
||||
|
||||
Paint paintBitmap;
|
||||
protected RectF tilesRect = new RectF();
|
||||
protected RectF latlonRect = new RectF();
|
||||
protected RectF bitmapToDraw = new RectF();
|
||||
protected Rect bitmapToZoom = new Rect();
|
||||
|
||||
|
@ -116,9 +115,9 @@ public class MapTileLayer extends BaseMapLayer {
|
|||
return;
|
||||
}
|
||||
if(mapTileAdapter != null){
|
||||
mapTileAdapter.onDraw(canvas, tileBox, tilesRect, drawSettings.isNightMode());
|
||||
mapTileAdapter.onDraw(canvas, tileBox, drawSettings);
|
||||
}
|
||||
drawTileMap(canvas, tilesRect);
|
||||
drawTileMap(canvas, tileBox);
|
||||
}
|
||||
|
||||
public void drawTileMap(Canvas canvas, RotatedTileBox tileBox) {
|
||||
|
@ -126,21 +125,19 @@ public class MapTileLayer extends BaseMapLayer {
|
|||
return;
|
||||
}
|
||||
ResourceManager mgr = resourceManager;
|
||||
int nzoom = view.getZoom();
|
||||
float tileX = view.getXTile();
|
||||
float tileY = view.getYTile();
|
||||
float w = view.getCenterPointX();
|
||||
float h = view.getCenterPointY();
|
||||
float ftileSize = view.getTileSize();
|
||||
|
||||
int nzoom = tileBox.getZoom();
|
||||
final QuadRect tilesRect = tileBox.getTileBounds();
|
||||
|
||||
// recalculate for ellipsoid coordinates
|
||||
if (map.isEllipticYTile()) {
|
||||
// TODO elliptic
|
||||
// if (map.isEllipticYTile()) {
|
||||
// return (float) MapUtils.getTileEllipsoidNumberY(getZoom(), currentViewport.get);
|
||||
float ellipticYTile = view.getEllipticYTile();
|
||||
tilesRect.bottom += (ellipticYTile - tileY);
|
||||
tilesRect.top += (ellipticYTile - tileY);
|
||||
tileY = ellipticYTile;
|
||||
}
|
||||
// float ellipticYTile = view.getEllipticYTile();
|
||||
// tilesRect.bottom += (ellipticYTile - tileY);
|
||||
// tilesRect.top += (ellipticYTile - tileY);
|
||||
// tileY = ellipticYTile;
|
||||
// }
|
||||
|
||||
|
||||
int left = (int) FloatMath.floor(tilesRect.left);
|
||||
int top = (int) FloatMath.floor(tilesRect.top);
|
||||
|
@ -157,8 +154,12 @@ public class MapTileLayer extends BaseMapLayer {
|
|||
for (int j = 0; j < height; j++) {
|
||||
int leftPlusI = left + i;
|
||||
int topPlusJ = top + j;
|
||||
float x1 = (left + i - tileX) * ftileSize + w;
|
||||
float y1 = (top + j - tileY) * ftileSize + h;
|
||||
int x1 = tileBox.getPixXFromTileXNoRot(leftPlusI);
|
||||
int x2 = tileBox.getPixXFromTileXNoRot(leftPlusI + 1);
|
||||
int y1 = tileBox.getPixYFromTileYNoRot(topPlusJ);
|
||||
int y2 = tileBox.getPixYFromTileYNoRot(topPlusJ);
|
||||
// TODO elliptic
|
||||
// float y1 = (top + j - tileY) * ftileSize + h;
|
||||
String ordImgTile = mgr.calculateTileId(map, leftPlusI, topPlusJ, nzoom);
|
||||
// asking tile image async
|
||||
boolean imgExist = mgr.tileExistOnFileSystem(ordImgTile, map, leftPlusI, topPlusJ, nzoom, false);
|
||||
|
@ -196,13 +197,13 @@ public class MapTileLayer extends BaseMapLayer {
|
|||
int xZoom = ((left + i) % div) * tileSize / div;
|
||||
int yZoom = ((top + j) % div) * tileSize / div;
|
||||
bitmapToZoom.set(xZoom, yZoom, xZoom + tileSize / div, yZoom + tileSize / div);
|
||||
bitmapToDraw.set(x1, y1, x1 + ftileSize, y1 + ftileSize);
|
||||
bitmapToDraw.set(x1, y1, x2 , y2);
|
||||
canvas.drawBitmap(bmp, bitmapToZoom, bitmapToDraw, paintBitmap);
|
||||
oneTileShown = true;
|
||||
}
|
||||
} else {
|
||||
bitmapToZoom.set(0, 0, tileSize, tileSize);
|
||||
bitmapToDraw.set(x1, y1, x1 + ftileSize, y1 + ftileSize);
|
||||
bitmapToDraw.set(x1, y1, x2, y2 );
|
||||
canvas.drawBitmap(bmp, bitmapToZoom, bitmapToDraw, paintBitmap);
|
||||
oneTileShown = true;
|
||||
}
|
||||
|
|
|
@ -27,14 +27,11 @@ import android.graphics.Color;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.FloatMath;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.OnDoubleTapListener;
|
||||
import android.view.GestureDetector.OnGestureListener;
|
||||
|
@ -122,8 +119,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
public OsmandMapTileView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
application = (OsmandApplication) context.getApplicationContext();
|
||||
currentViewport = new RotatedTileBox.RotatedTileBoxBuilder().
|
||||
setLocation(0, 0).setZoomAndScale(3, 1).build();
|
||||
initView();
|
||||
|
||||
}
|
||||
|
@ -131,8 +126,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
public OsmandMapTileView(Context context) {
|
||||
super(context);
|
||||
application = (OsmandApplication) context.getApplicationContext();
|
||||
currentViewport = new RotatedTileBox.RotatedTileBoxBuilder().
|
||||
setLocation(0, 0).setZoomAndScale(3, 1).build();
|
||||
initView();
|
||||
}
|
||||
|
||||
|
@ -176,7 +169,8 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
WindowManager mgr = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
dm = new DisplayMetrics();
|
||||
mgr.getDefaultDisplay().getMetrics(dm);
|
||||
currentViewport.setPixelDimensions(getWidth(), getHeight());
|
||||
currentViewport = new RotatedTileBox.RotatedTileBoxBuilder().
|
||||
setLocation(0, 0).setZoomAndScale(3, 1).setPixelDimensions(getWidth(), getHeight()).build();
|
||||
currentViewport.setDensity(dm.density);
|
||||
|
||||
}
|
||||
|
@ -252,10 +246,19 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
return r;
|
||||
}
|
||||
|
||||
public void setZoom(int zoom, float zoomScale) {
|
||||
public void setIntZoom(int zoom) {
|
||||
if (mainLayer != null && zoom <= mainLayer.getMaximumShownMapZoom() && zoom >= mainLayer.getMinimumShownMapZoom()) {
|
||||
animatedDraggingThread.stopAnimating();
|
||||
currentViewport.setZoom(zoom, zoomScale);
|
||||
currentViewport.setZoom(zoom, currentViewport.getZoomScale());
|
||||
currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0 );
|
||||
refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
public void setComplexZoom(int zoom, float scale) {
|
||||
if (mainLayer != null && zoom <= mainLayer.getMaximumShownMapZoom() && zoom >= mainLayer.getMinimumShownMapZoom()) {
|
||||
animatedDraggingThread.stopAnimating();
|
||||
currentViewport.setZoom(zoom, scale, 0);
|
||||
currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0 );
|
||||
refreshMap();
|
||||
}
|
||||
|
@ -311,13 +314,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
}
|
||||
|
||||
public boolean isZooming(){
|
||||
// zooming scale
|
||||
float diff = (zoom - getZoom()) * ZOOM_DELTA;
|
||||
if(Math.abs(diff - Math.round(diff)) < 0.02) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
// return zoom != getZoom();
|
||||
return currentViewport.isZoomAnimated();
|
||||
}
|
||||
|
||||
public void setMapLocationListener(IMapLocationListener l) {
|
||||
|
@ -338,12 +335,14 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
|
||||
public void setMainLayer(BaseMapLayer mainLayer) {
|
||||
this.mainLayer = mainLayer;
|
||||
if (mainLayer.getMaximumShownMapZoom() < this.zoom) {
|
||||
int zoom = currentViewport.getZoom();
|
||||
if (mainLayer.getMaximumShownMapZoom() < zoom) {
|
||||
zoom = mainLayer.getMaximumShownMapZoom();
|
||||
}
|
||||
if (mainLayer.getMinimumShownMapZoom() > this.zoom) {
|
||||
if (mainLayer.getMinimumShownMapZoom() > zoom) {
|
||||
zoom = mainLayer.getMinimumShownMapZoom();
|
||||
}
|
||||
currentViewport.setZoom(zoom, currentViewport.getZoomScale());
|
||||
refreshMap();
|
||||
}
|
||||
|
||||
|
@ -516,7 +515,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
float dy = (fromY - toY);
|
||||
moveTo(dx, dy);
|
||||
if (locationListener != null && notify) {
|
||||
locationListener.locationChanged(latitude, longitude, this);
|
||||
locationListener.locationChanged(getLatitude(), getLongitude(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -537,11 +536,31 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
locationListener.locationChanged(latitude, longitude, this);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setZoomAnimate(int zoom, float zoomScale, boolean notify) {
|
||||
currentViewport.setZoom(zoom, zoomScale, 0);
|
||||
refreshMap();
|
||||
if (locationListener != null && notify) {
|
||||
locationListener.locationChanged(getLatitude(), getLongitude(), this);
|
||||
}
|
||||
}
|
||||
|
||||
// for internal usage
|
||||
protected void zoomToAnimate(float zoom, boolean notify) {
|
||||
protected void zoomToAnimate(float tzoom, boolean notify) {
|
||||
int zoom = getZoom();
|
||||
float zoomToScale = getZoomScale();
|
||||
float zoomToAnimate = tzoom - zoom - zoomToScale;
|
||||
if(zoomToAnimate >= 1) {
|
||||
zoom += (int) zoomToAnimate;
|
||||
zoomToAnimate -= (int) zoomToAnimate;
|
||||
}
|
||||
while (zoomToAnimate < 0) {
|
||||
zoom++;
|
||||
zoomToAnimate += 1;
|
||||
}
|
||||
if (mainLayer != null && mainLayer.getMaximumShownMapZoom() >= zoom && mainLayer.getMinimumShownMapZoom() <= zoom) {
|
||||
this.zoom = zoom;
|
||||
currentViewport.setZoom(zoom, zoomToScale, zoomToAnimate);
|
||||
currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0 );
|
||||
refreshMap();
|
||||
if (notify && locationListener != null) {
|
||||
locationListener.locationChanged(getLatitude(), getLongitude(), this);
|
||||
|
@ -628,9 +647,8 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
public void onZoomEnded(float distance, float relativeToStart) {
|
||||
float dz = (float) (Math.log(relativeToStart) / Math.log(2) * 1.5);
|
||||
float calcZoom = initialViewport.getZoom() + dz;
|
||||
setZoom(Math.round(calcZoom));
|
||||
changeZoomPosition(dz);
|
||||
final int newZoom = getZoom();
|
||||
zoomPositionChanged(newZoom);
|
||||
if (application.getInternalAPI().accessibilityEnabled()) {
|
||||
if (newZoom != initialViewport.getZoom()) {
|
||||
showMessage(getContext().getString(R.string.zoomIs) + " " + newZoom); //$NON-NLS-1$
|
||||
|
@ -661,20 +679,20 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
@Override
|
||||
public void onZooming(float distance, float relativeToStart) {
|
||||
float dz = (float) (Math.log(relativeToStart) / Math.log(2) * 1.5);
|
||||
float calcZoom = initialViewport.getZoom() + dz;
|
||||
if (Math.abs(calcZoom - zoom) > 0.05) {
|
||||
setZoom(calcZoom);
|
||||
zoomPositionChanged(calcZoom);
|
||||
if (Math.abs(dz) > 0.05) {
|
||||
changeZoomPosition(dz);
|
||||
}
|
||||
}
|
||||
|
||||
private void zoomPositionChanged(float calcZoom) {
|
||||
private void changeZoomPosition(float dz) {
|
||||
float calcZoom = initialViewport.getZoom() + dz + initialViewport.getZoomScale();
|
||||
final QuadPoint cp = initialViewport.getCenterPixelPoint();
|
||||
float dx = initialMultiTouchCenterPoint.x - cp.x;
|
||||
float dy = initialMultiTouchCenterPoint.y - cp.y;
|
||||
final RotatedTileBox calc = initialViewport.copy();
|
||||
calc.setLatLonCenter(initialCenterLatLon.getLatitude(), initialCenterLatLon.getLongitude());
|
||||
final LatLon r = calc.getLatLonFromPixel(cp.x + dx, cp.y + dy);
|
||||
zoomToAnimate(calcZoom, true);
|
||||
setLatLon(r.getLatitude(), r.getLongitude());
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ public class RouteInfoLayer extends OsmandMapLayer implements IRouteInformationL
|
|||
if(info.getDescriptionRoute() != null) {
|
||||
contextMenu.setLocation(new LatLon(l.getLatitude(), l.getLongitude()), info.getDescriptionRoute());
|
||||
}
|
||||
view.getAnimatedDraggingThread().startMoving(l.getLatitude(), l.getLongitude(), view.getFloatZoom(), true);
|
||||
view.getAnimatedDraggingThread().startMoving(l.getLatitude(), l.getLongitude(), view.getZoom(), true);
|
||||
}
|
||||
}
|
||||
view.refreshMap();
|
||||
|
@ -112,7 +112,7 @@ public class RouteInfoLayer extends OsmandMapLayer implements IRouteInformationL
|
|||
if(info.getDescriptionRoute() != null){
|
||||
contextMenu.setLocation(new LatLon(l.getLatitude(), l.getLongitude()), info.getDescriptionRoute());
|
||||
}
|
||||
view.getAnimatedDraggingThread().startMoving(l.getLatitude(), l.getLongitude(), view.getFloatZoom(), true);
|
||||
view.getAnimatedDraggingThread().startMoving(l.getLatitude(), l.getLongitude(), view.getZoom(), true);
|
||||
}
|
||||
view.refreshMap();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
|
@ -24,8 +25,6 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
private OsmandMapTileView view;
|
||||
|
||||
private final RoutingHelper helper;
|
||||
private Rect boundsRect;
|
||||
private RectF latlonRect;
|
||||
private List<Location> points = new ArrayList<Location>();
|
||||
private Paint paint;
|
||||
|
||||
|
@ -42,8 +41,6 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
|
||||
|
||||
private void initUI() {
|
||||
boundsRect = new Rect(0, 0, view.getWidth(), view.getHeight());
|
||||
latlonRect = new RectF();
|
||||
paint = new Paint();
|
||||
|
||||
paint.setStyle(Style.STROKE);
|
||||
|
@ -80,47 +77,50 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox latLonBounds, DrawSettings nightMode) {
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) {
|
||||
path.reset();
|
||||
if (helper.getFinalLocation() != null && helper.getRoute().isCalculated()) {
|
||||
paint.setColor(getColor(nightMode));
|
||||
int w = view.getWidth();
|
||||
int h = view.getHeight();
|
||||
int w = tb.getPixWidth();
|
||||
int h = tb.getPixHeight();
|
||||
Location lastProjection = helper.getLastProjection();
|
||||
final RotatedTileBox cp ;
|
||||
if(lastProjection != null &&
|
||||
view.isPointOnTheRotatedMap(lastProjection.getLatitude(), lastProjection.getLongitude())){
|
||||
boundsRect = new Rect(-w / 2, -h, 3 * w / 2, h);
|
||||
tb.containsLatLon(lastProjection.getLatitude(), lastProjection.getLongitude())){
|
||||
cp = tb.copy();
|
||||
cp.increasePixelDimensions(w /2, h);
|
||||
} else {
|
||||
boundsRect = new Rect(0, 0, w, h);
|
||||
cp = tb;
|
||||
}
|
||||
view.calculateLatLonRectangle(boundsRect, latlonRect);
|
||||
|
||||
final QuadRect latlonRect = cp.getLatLonBounds();
|
||||
double topLatitude = latlonRect.top;
|
||||
double leftLongitude = latlonRect.left;
|
||||
double bottomLatitude = latlonRect.bottom;
|
||||
double rightLongitude = latlonRect.right;
|
||||
double lat = topLatitude - bottomLatitude + 0.1;
|
||||
double lon = rightLongitude - leftLongitude + 0.1;
|
||||
drawLocations(canvas, topLatitude + lat, leftLongitude - lon, bottomLatitude - lat, rightLongitude + lon);
|
||||
drawLocations(tb, canvas, topLatitude + lat, leftLongitude - lon, bottomLatitude - lat, rightLongitude + lon);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void drawSegment(Canvas canvas) {
|
||||
private void drawSegment(RotatedTileBox tb, Canvas canvas) {
|
||||
if (points.size() > 0) {
|
||||
int px = view.getMapXForPoint(points.get(0).getLongitude());
|
||||
int py = view.getMapYForPoint(points.get(0).getLatitude());
|
||||
int px = tb.getPixXFromLonNoRot(points.get(0).getLongitude());
|
||||
int py = tb.getPixYFromLatNoRot(points.get(0).getLatitude());
|
||||
path.moveTo(px, py);
|
||||
for (int i = 1; i < points.size(); i++) {
|
||||
Location o = points.get(i);
|
||||
int x = view.getMapXForPoint(o.getLongitude());
|
||||
int y = view.getMapYForPoint(o.getLatitude());
|
||||
int x = tb.getPixXFromLonNoRot(o.getLongitude());
|
||||
int y = tb.getPixYFromLatNoRot(o.getLatitude());
|
||||
path.lineTo(x, y);
|
||||
}
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawLocations(Canvas canvas, double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude) {
|
||||
public void drawLocations(RotatedTileBox tb, Canvas canvas, double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude) {
|
||||
points.clear();
|
||||
boolean previousVisible = false;
|
||||
Location lastProjection = helper.getLastProjection();
|
||||
|
@ -148,12 +148,12 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
} else if (previousVisible) {
|
||||
points.add(ls);
|
||||
|
||||
drawSegment(canvas);
|
||||
drawSegment(tb, canvas);
|
||||
previousVisible = false;
|
||||
points.clear();
|
||||
}
|
||||
}
|
||||
drawSegment(canvas);
|
||||
drawSegment(tb, canvas);
|
||||
}
|
||||
|
||||
public RoutingHelper getHelper() {
|
||||
|
|
|
@ -58,7 +58,7 @@ public class TransportInfoLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox latLonBounds, DrawSettings nightMode) {
|
||||
public void onDraw(Canvas canvas, RotatedTileBox t, DrawSettings nightMode) {
|
||||
if(routeHelper.routeIsCalculated() && visible){
|
||||
List<RouteInfoLocation> list = routeHelper.getRoute();
|
||||
for(RouteInfoLocation l : list){
|
||||
|
@ -86,10 +86,9 @@ public class TransportInfoLayer extends OsmandMapLayer {
|
|||
}
|
||||
if(start){
|
||||
LatLon location = st.getLocation();
|
||||
if (location.getLatitude() >= latLonBounds.bottom && location.getLatitude() <= latLonBounds.top && location.getLongitude() >= latLonBounds.left
|
||||
&& location.getLongitude() <= latLonBounds.right ) {
|
||||
int x = view.getRotatedMapXForPoint(location.getLatitude(), location.getLongitude());
|
||||
int y = view.getRotatedMapYForPoint(location.getLatitude(), location.getLongitude());
|
||||
if (t.containsLatLon(location.getLatitude(), location.getLongitude())) {
|
||||
int x = t.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
|
||||
int y = t.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
|
||||
canvas.drawRect(x - getRadius(), y - getRadius(), x + getRadius(), y + getRadius(), toShow);
|
||||
}
|
||||
}
|
||||
|
@ -136,8 +135,8 @@ public class TransportInfoLayer extends OsmandMapLayer {
|
|||
}
|
||||
if (start) {
|
||||
LatLon location = st.getLocation();
|
||||
int x = view.getRotatedMapXForPoint(location.getLatitude(), location.getLongitude());
|
||||
int y = view.getRotatedMapYForPoint(location.getLatitude(), location.getLongitude());
|
||||
int x = tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
|
||||
int y = tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
|
||||
if (Math.abs(x - ex) < getRadius() * 3 /2 && Math.abs(y - ey) < getRadius() * 3 /2) {
|
||||
AccessibleToast.makeText(view.getContext(), st.getName(view.getSettings().USE_ENGLISH_NAMES.get()) + " : " + //$NON-NLS-1$
|
||||
route.getType() + " " + route.getRef() //$NON-NLS-1$
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.net.URL;
|
|||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -33,7 +34,7 @@ public class YandexTrafficAdapter extends MapTileAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RectF latlonRect, RectF tilesRect, boolean nightMode) {
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, OsmandMapLayer.DrawSettings drawSettings) {
|
||||
updateTimeStamp();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
package net.osmand.plus.views.mapwidgets;
|
||||
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Cap;
|
||||
import android.graphics.Paint.Join;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Path;
|
||||
import android.view.View;
|
||||
|
||||
public class MiniMapWidget extends BaseMapWidget {
|
||||
private float scaleCoefficient = MapInfoLayer.scaleCoefficient;
|
||||
private static final float scaleMiniRoute = 0.15f;
|
||||
private final float width = 96 * scaleCoefficient;
|
||||
private final float height = 96 * scaleCoefficient;
|
||||
private final float centerMiniRouteY = 3 * height / 4;
|
||||
private final float centerMiniRouteX = width / 2;
|
||||
|
||||
private final OsmandMapTileView view;
|
||||
private Paint paintMiniRoute;
|
||||
private Paint fillBlack;
|
||||
protected Path miniMapPath = null;
|
||||
|
||||
public MiniMapWidget(Context ctx, OsmandMapTileView view) {
|
||||
super(ctx);
|
||||
this.view = view;
|
||||
|
||||
fillBlack = new Paint();
|
||||
fillBlack.setStyle(Style.FILL_AND_STROKE);
|
||||
fillBlack.setColor(Color.BLACK);
|
||||
fillBlack.setAntiAlias(true);
|
||||
|
||||
paintMiniRoute = new Paint();
|
||||
paintMiniRoute.setStyle(Style.STROKE);
|
||||
paintMiniRoute.setStrokeWidth(35 * scaleCoefficient);
|
||||
paintMiniRoute.setStrokeJoin(Join.ROUND);
|
||||
paintMiniRoute.setStrokeCap(Cap.ROUND);
|
||||
paintMiniRoute.setAntiAlias(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
if(getVisibility() == View.VISIBLE) {
|
||||
invalidate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setWDimensions((int) width, (int) height);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
|
||||
// to change color immediately when needed
|
||||
// could be deleted in future
|
||||
paintMiniRoute.setColor(getResources().getColor(R.color.nav_track));
|
||||
|
||||
if (miniMapPath != null && !miniMapPath.isEmpty()) {
|
||||
canvas.save();
|
||||
canvas.translate(centerMiniRouteX - view.getCenterPointX(), centerMiniRouteY - view.getCenterPointY());
|
||||
canvas.scale(scaleMiniRoute, scaleMiniRoute, view.getCenterPointX(), view.getCenterPointY());
|
||||
canvas.rotate(view.getRotate(), view.getCenterPointX(), view.getCenterPointY());
|
||||
canvas.drawCircle(view.getCenterPointX(), view.getCenterPointY(), 3 / scaleMiniRoute, fillBlack);
|
||||
canvas.drawPath(miniMapPath, paintMiniRoute);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -398,7 +398,7 @@ public class RouteInfoWidgetsFactory {
|
|||
AnimateDraggingMapThread thread = view.getAnimatedDraggingThread();
|
||||
LatLon pointToNavigate = getPointToNavigate();
|
||||
if (pointToNavigate != null) {
|
||||
float fZoom = view.getFloatZoom() < 15 ? 15 : view.getFloatZoom();
|
||||
int fZoom = view.getZoom() < 15 ? 15 : view.getZoom();
|
||||
thread.startMoving(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(), fZoom, true);
|
||||
}
|
||||
}
|
||||
|
@ -489,19 +489,6 @@ public class RouteInfoWidgetsFactory {
|
|||
return distanceControl;
|
||||
}
|
||||
|
||||
public MiniMapWidget createMiniMapControl(final RoutingHelper routingHelper, OsmandMapTileView view) {
|
||||
final MiniMapWidget miniMapControl = new MiniMapWidget(view.getContext(), view) {
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
boolean visible = routingHelper.isFollowingMode();
|
||||
updateVisibility(visible);
|
||||
return super.updateInfo(drawSettings);
|
||||
}
|
||||
};
|
||||
miniMapControl.setVisibility(View.GONE);
|
||||
return miniMapControl;
|
||||
}
|
||||
|
||||
private static final float miniCoeff = 2f;
|
||||
public BaseMapWidget createLanesControl(final RoutingHelper routingHelper, final OsmandMapTileView view) {
|
||||
final Path laneStraight = new Path();
|
||||
|
|
Loading…
Reference in a new issue