From b00da5c5dd91da1cc7ceb97b9bf1110c785f0059 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 6 Jun 2013 01:17:10 +0200 Subject: [PATCH] Fix bugs --- .../src/net/osmand/plus/OsmandApplication.java | 6 +++--- .../plus/audionotes/AudioVideoNotesPlugin.java | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 737b5b11f2..f2707bf417 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -140,9 +140,9 @@ public class OsmandApplication extends Application implements ClientContext { uiHandler = new Handler(); rendererRegistry = new RendererRegistry(); targetPointsHelper = new TargetPointsHelper(this); - if(!osmandSettings.FOLLOW_THE_ROUTE.get()) { - targetPointsHelper.clearPointToNavigate(false); - } +// if(!osmandSettings.FOLLOW_THE_ROUTE.get()) { +// targetPointsHelper.clearPointToNavigate(false); +// } checkPrefferedLocale(); startApplication(); diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index 2344d4152c..86c971c955 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -183,7 +183,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { } @SuppressWarnings("rawtypes") - public void updatePhotoInformation(double lat, double lon, double rot) throws IOException { + public void updatePhotoInformation(double lat, double lon, Location loc, double rot) throws IOException { try { Class exClass = Class.forName("android.media.ExifInterface"); @@ -197,9 +197,19 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { setAttribute.invoke(exInstance,"GPSLongitudeRef", lon > 0?"E" : "W"); if(!Double.isNaN(rot)){ setAttribute.invoke(exInstance,"GPSImgDirectionRef", "T"); - String rotString = (int) (rot * 100.0) + "/100"; + while(rot < 0) { rot += 360; } + while(rot > 360) { rot -= 360; } + int abs = (int) (Math.abs(rot) * 100.0); + String rotString = abs/100f+""; setAttribute.invoke(exInstance,"GPSImgDirection", rotString); } + if(loc != null && loc.hasAltitude()){ + double alt = loc.getAltitude(); + String altString = (int) (Math.abs(alt) * 100.0) + "/100"; + System.err.println(altString); + setAttribute.invoke(exInstance,"GPSAltitude", altString); + setAttribute.invoke(exInstance,"GPSAltitudeRef", alt < 0 ? "1" : "0"); + } Method saveAttributes = exClass.getMethod("saveAttributes", new Class[] {} ); saveAttributes.invoke(exInstance); @@ -857,10 +867,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { r.lat = l.getLatitude(); r.lon = l.getLongitude(); Float heading = app.getLocationProvider().getHeading(); + Location loc = app.getLocationProvider().getLastKnownLocation(); if(lastTakingPhoto != null && lastTakingPhoto.getName().equals(f.getName()) && heading != null) { float rot = heading.floatValue(); try { - r.updatePhotoInformation(r.lat, r.lon, rot == 0 ? Double.NaN : rot); + r.updatePhotoInformation(r.lat, r.lon, loc, rot == 0 ? Double.NaN : rot); } catch (IOException e) { log.error("Error updating EXIF information " + e.getMessage(), e); }