From 3a7026d4cd7c180a16b80bd92de3f1619de92a52 Mon Sep 17 00:00:00 2001 From: hayashi yuu Date: Sun, 26 Jul 2015 19:28:15 +0900 Subject: [PATCH] =?utf8?q?FIX:EXIF=E3=81=AB=E6=92=AE=E5=BD=B1=E6=96=B9?= =?utf8?q?=E8=A7=92=E3=82=92=E6=AD=A3=E3=81=97=E3=81=8F=E4=BB=98=E5=8A=A0?= =?utf8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97?= =?utf8?q?=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- importPicture/src/osm/jp/gpx/ImportPicture.java | 44 ++++++++++++++++--------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/importPicture/src/osm/jp/gpx/ImportPicture.java b/importPicture/src/osm/jp/gpx/ImportPicture.java index e56c698..5c14a62 100644 --- a/importPicture/src/osm/jp/gpx/ImportPicture.java +++ b/importPicture/src/osm/jp/gpx/ImportPicture.java @@ -9,10 +9,10 @@ import java.util.Calendar; import java.util.Comparator; import java.util.Date; import java.util.GregorianCalendar; -import java.util.HashMap; import java.util.Iterator; import java.util.Set; import java.util.TimeZone; +import java.util.TreeMap; import java.util.logging.LogManager; import java.util.logging.Logger; @@ -200,7 +200,7 @@ public class ImportPicture { */ - HashMap map = new HashMap<>(); + TreeMap map = new TreeMap<>(); Element trk = null; gpx = builder.parse(gpxFile).getFirstChild(); NodeList nodes = gpx.getChildNodes(); @@ -270,7 +270,7 @@ public class ImportPicture { * @throws ImageReadException * @throws ImageWriteException */ - static void proc(File dir, long delta, long gpxStartTime, long gpxEndTime, HashMap map, boolean exifWrite, Node gpx) throws ParseException, ImageReadException, IOException, ImageWriteException { + static void proc(File dir, long delta, long gpxStartTime, long gpxEndTime, TreeMap map, boolean exifWrite, Node gpx) throws ParseException, ImageReadException, IOException, ImageWriteException { DecimalFormat yearFormatter = new DecimalFormat("0000"); DecimalFormat monthFormatter = new DecimalFormat("00"); DecimalFormat dayFormatter = new DecimalFormat("00"); @@ -462,7 +462,7 @@ public class ImportPicture { * @param map * @throws ParseException */ - public static void trkptMap(Element trk, HashMap map) throws ParseException { + public static void trkptMap(Element trk, TreeMap map) throws ParseException { dfuk.setTimeZone(TimeZone.getTimeZone("GMT")); NodeList nodes1 = trk.getChildNodes(); @@ -510,8 +510,8 @@ public class ImportPicture { * @param jptime * @throws ParseException */ - public static Element trkpt(HashMap map, Date jptime) throws ParseException { - Double R = 20000000 / Math.PI; // 地球の半径(m) + public static Element trkpt(TreeMap map, Date jptime) throws ParseException { + Double R = 20000000 / Math.PI; long sa = 2L * 3600000L; long jpt = jptime.getTime(); Element ret = null; @@ -572,20 +572,25 @@ public class ImportPicture { break; } } - Double dLON = imaLON - maeLON; - Double dLAT = imaLAT - maeLAT; - Double r = Math.cos(Math.toRadians((imaLAT + maeLAT) * 2)) * R; + Double r = Math.cos(Math.toRadians((imaLAT + maeLAT) / 2)) * R; Double x = Math.toRadians(imaLON - maeLON) * r; Double y = Math.toRadians(imaLAT - maeLAT) * R; - double rad = Math.toDegrees(Math.atan(y / x)); + double rad = Math.toDegrees(Math.atan2(y, x)); - if (y < 0) { - rad = rad * -1; - if (x > 0) { - rad = rad + 90; + if (y >= 0) { + if (x >= 0) { + rad = 0 - (rad - 90); } else { - rad = rad - 90; + rad = 360 - (rad - 90); + } + } + else { + if (x >= 0) { + rad = 90 - rad; + } + else { + rad = 90 - rad; } } @@ -597,6 +602,15 @@ public class ImportPicture { } magvar.setTextContent(str); ret.appendChild(magvar); + + Element speed = ret.getOwnerDocument().createElement("speed"); + str = Double.toString(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))); + iDot = str.indexOf('.'); + if (iDot > 0) { + str = str.substring(0, iDot); + } + speed.setTextContent(str); + ret.appendChild(speed); } } } -- 2.11.0