Fix rotation for osmo

This commit is contained in:
Victor Shcherb 2014-07-12 01:51:56 +02:00
parent 92560f268b
commit d33cc44507

View file

@ -117,22 +117,22 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye
} }
@Override @Override
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) { public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
final int r = getRadiusPoi(tb); final int r = getRadiusPoi(tileBox);
long treshold = System.currentTimeMillis() - 15000; long treshold = System.currentTimeMillis() - 15000;
for (OsMoDevice t : getTrackingDevices()) { for (OsMoDevice t : getTrackingDevices()) {
Location l = t.getLastLocation(); Location l = t.getLastLocation();
ConcurrentLinkedQueue<Location> plocations = t.getPreviousLocations(treshold); ConcurrentLinkedQueue<Location> plocations = t.getPreviousLocations(treshold);
if (!plocations.isEmpty() && l != null) { if (!plocations.isEmpty() && l != null) {
int x = (int) tb.getPixXFromLatLon(l.getLatitude(), l.getLongitude()); int x = (int) tileBox.getPixXFromLonNoRot(l.getLongitude());
int y = (int) tb.getPixYFromLatLon(l.getLatitude(), l.getLongitude()); int y = (int) tileBox.getPixYFromLatNoRot(l.getLatitude());
pth.rewind(); pth.rewind();
Iterator<Location> it = plocations.iterator(); Iterator<Location> it = plocations.iterator();
boolean f = true; boolean f = true;
while (it.hasNext()) { while (it.hasNext()) {
Location lo = it.next(); Location lo = it.next();
int xt = (int) tb.getPixXFromLatLon(lo.getLatitude(), lo.getLongitude()); int xt = (int) tileBox.getPixXFromLonNoRot(lo.getLongitude());
int yt = (int) tb.getPixYFromLatLon(lo.getLatitude(), lo.getLongitude()); int yt = (int) tileBox.getPixYFromLatNoRot(lo.getLatitude());
if (f) { if (f) {
f = false; f = false;
pth.moveTo(xt, yt); pth.moveTo(xt, yt);
@ -145,14 +145,15 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye
canvas.drawPath(pth, paintPath); canvas.drawPath(pth, paintPath);
} }
} }
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
for (OsMoDevice t : getTrackingDevices()) { for (OsMoDevice t : getTrackingDevices()) {
Location l = t.getLastLocation(); Location l = t.getLastLocation();
if (l != null) { if (l != null) {
int x = (int) tb.getPixXFromLatLon(l.getLatitude(), l.getLongitude()); int x = (int) tileBox.getPixXFromLatLon(l.getLatitude(), l.getLongitude());
int y = (int) tb.getPixYFromLatLon(l.getLatitude(), l.getLongitude()); int y = (int) tileBox.getPixYFromLatLon(l.getLatitude(), l.getLongitude());
pointInnerCircle.setColor(t.getColor()); pointInnerCircle.setColor(t.getColor());
canvas.drawCircle(x, y, r + (float)Math.ceil(tb.getDensity()), pointOuter); canvas.drawCircle(x, y, r + (float)Math.ceil(tileBox.getDensity()), pointOuter);
canvas.drawCircle(x, y, r - (float)Math.ceil(tb.getDensity()), pointInnerCircle); canvas.drawCircle(x, y, r - (float)Math.ceil(tileBox.getDensity()), pointInnerCircle);
paintTextIcon.setTextSize(r * 3 / 2); paintTextIcon.setTextSize(r * 3 / 2);
canvas.drawText(t.getVisibleName().substring(0, 1).toUpperCase(), x, y + r / 2, paintTextIcon); canvas.drawText(t.getVisibleName().substring(0, 1).toUpperCase(), x, y + r / 2, paintTextIcon);
} }