Fix mapillary selected image position while rotating the map

This commit is contained in:
Alexey Kulish 2017-05-20 17:02:17 +03:00
parent a74ab352c0
commit 5da5d0d41d
2 changed files with 10 additions and 9 deletions

View file

@ -42,10 +42,9 @@ class MapillaryRasterLayer extends MapTileLayer implements MapillaryLayer {
this.selectedImageCameraAngle = selectedImageCameraAngle;
}
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
super.onPrepareBufferImage(canvas, tileBox, drawSettings);
private void drawSelectedPoint(Canvas canvas, RotatedTileBox tileBox) {
if (selectedImageLocation != null) {
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
float x = tileBox.getPixXFromLatLon(selectedImageLocation.getLatitude(), selectedImageLocation.getLongitude());
float y = tileBox.getPixYFromLatLon(selectedImageLocation.getLatitude(), selectedImageLocation.getLongitude());
if (selectedImageCameraAngle != null) {
@ -56,6 +55,7 @@ class MapillaryRasterLayer extends MapTileLayer implements MapillaryLayer {
canvas.restore();
}
canvas.drawBitmap(selectedImage, x - selectedImage.getWidth() / 2, y - selectedImage.getHeight() / 2, paintIcon);
canvas.rotate(tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
}
}
@ -70,5 +70,6 @@ class MapillaryRasterLayer extends MapTileLayer implements MapillaryLayer {
return;
}
super.drawTileMap(canvas, tileBox);
drawSelectedPoint(canvas, tileBox);
}
}

View file

@ -82,8 +82,11 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
}
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
super.onPrepareBufferImage(canvas, tileBox, drawSettings);
public boolean drawInScreenPixels() {
return true;
}
private void drawSelectedPoint(Canvas canvas, RotatedTileBox tileBox) {
if (selectedImageLocation != null) {
float x = tileBox.getPixXFromLatLon(selectedImageLocation.getLatitude(), selectedImageLocation.getLongitude());
float y = tileBox.getPixYFromLatLon(selectedImageLocation.getLatitude(), selectedImageLocation.getLongitude());
@ -155,6 +158,7 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
}
}
this.visiblePoints = visiblePoints;
drawSelectedPoint(canvas, tileBox);
}
protected void drawPoints(Canvas canvas, RotatedTileBox tileBox, int tileX, int tileY,
@ -168,7 +172,6 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
float ph = point.getHeight();
float pwd = pw / 2;
float phd = ph / 2;
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
for (Geometry g : tile.getData()) {
if (g instanceof Point && !g.isEmpty() && g.getUserData() != null && g.getUserData() instanceof HashMap) {
@ -185,7 +188,6 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
}
}
}
canvas.rotate(tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
}
protected void drawLines(Canvas canvas, RotatedTileBox tileBox, int tileX, int tileY, GeometryTile tile) {
@ -216,7 +218,6 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
int mult = (int) Math.pow(2.0, dzoom);
QuadRect tileBounds = tileBox.getTileBounds();
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
Coordinate lastPt = points[0];
float x;
float y;
@ -257,7 +258,6 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
lx = px;
ly = py;
}
canvas.rotate(tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
}
}