import java.util.Comparator;\r
import java.util.Date;\r
import java.util.GregorianCalendar;\r
-import java.util.HashMap;\r
import java.util.Iterator;\r
import java.util.Set;\r
import java.util.TimeZone;\r
+import java.util.TreeMap;\r
import java.util.logging.LogManager;\r
import java.util.logging.Logger;\r
\r
</wpt>\r
</gpx>\r
*/\r
- HashMap<Long,Element> map = new HashMap<>();\r
+ TreeMap<Long,Element> map = new TreeMap<>();\r
Element trk = null;\r
gpx = builder.parse(gpxFile).getFirstChild();\r
NodeList nodes = gpx.getChildNodes();\r
* @throws ImageReadException \r
* @throws ImageWriteException \r
*/\r
- static void proc(File dir, long delta, long gpxStartTime, long gpxEndTime, HashMap<Long,Element> map, boolean exifWrite, Node gpx) throws ParseException, ImageReadException, IOException, ImageWriteException {\r
+ static void proc(File dir, long delta, long gpxStartTime, long gpxEndTime, TreeMap<Long,Element> map, boolean exifWrite, Node gpx) throws ParseException, ImageReadException, IOException, ImageWriteException {\r
DecimalFormat yearFormatter = new DecimalFormat("0000");\r
DecimalFormat monthFormatter = new DecimalFormat("00");\r
DecimalFormat dayFormatter = new DecimalFormat("00");\r
* @param map\r
* @throws ParseException\r
*/\r
- public static void trkptMap(Element trk, HashMap<Long,Element> map) throws ParseException {\r
+ public static void trkptMap(Element trk, TreeMap<Long,Element> map) throws ParseException {\r
dfuk.setTimeZone(TimeZone.getTimeZone("GMT"));\r
\r
NodeList nodes1 = trk.getChildNodes();\r
* @param jptime\r
* @throws ParseException\r
*/\r
- public static Element trkpt(HashMap<Long,Element> map, Date jptime) throws ParseException {\r
- Double R = 20000000 / Math.PI; // 地球の半径(m)\r
+ public static Element trkpt(TreeMap<Long,Element> map, Date jptime) throws ParseException {\r
+ Double R = 20000000 / Math.PI;\r
long sa = 2L * 3600000L;\r
long jpt = jptime.getTime();\r
Element ret = null;\r
break;\r
}\r
}\r
- Double dLON = imaLON - maeLON;\r
- Double dLAT = imaLAT - maeLAT;\r
- Double r = Math.cos(Math.toRadians((imaLAT + maeLAT) * 2)) * R;\r
+ Double r = Math.cos(Math.toRadians((imaLAT + maeLAT) / 2)) * R;\r
Double x = Math.toRadians(imaLON - maeLON) * r;\r
Double y = Math.toRadians(imaLAT - maeLAT) * R;\r
- double rad = Math.toDegrees(Math.atan(y / x));\r
+ double rad = Math.toDegrees(Math.atan2(y, x));\r
\r
- if (y < 0) {\r
- rad = rad * -1;\r
- if (x > 0) {\r
- rad = rad + 90;\r
+ if (y >= 0) {\r
+ if (x >= 0) {\r
+ rad = 0 - (rad - 90);\r
}\r
else {\r
- rad = rad - 90;\r
+ rad = 360 - (rad - 90);\r
+ }\r
+ }\r
+ else {\r
+ if (x >= 0) {\r
+ rad = 90 - rad;\r
+ }\r
+ else {\r
+ rad = 90 - rad;\r
}\r
}\r
\r
}\r
magvar.setTextContent(str);\r
ret.appendChild(magvar);\r
+ \r
+ Element speed = ret.getOwnerDocument().createElement("speed");\r
+ str = Double.toString(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));\r
+ iDot = str.indexOf('.');\r
+ if (iDot > 0) {\r
+ str = str.substring(0, iDot);\r
+ }\r
+ speed.setTextContent(str);\r
+ ret.appendChild(speed);\r
}\r
}\r
}\r