diff --git a/importPicture/src/osm/jp/gpx/ImportPicture.java b/importPicture/src/osm/jp/gpx/ImportPicture.java index a5601c6..3163877 100644 --- a/importPicture/src/osm/jp/gpx/ImportPicture.java +++ b/importPicture/src/osm/jp/gpx/ImportPicture.java @@ -299,28 +299,23 @@ double latitude = Double.parseDouble(latStr); double longitude = Double.parseDouble(lonStr); - String eleStr = null; - String magvarStr = null; + String eleStr = "-"; + String magvarStr = "-"; NodeList nodes = wpt.getChildNodes(); // 子ノードを取得 - for (int i4=0; i4< nodes.getLength(); i4++) { + for (int i4 = 0; i4 < nodes.getLength(); i4++) { Node node = nodes.item(i4); if (node != null) { - if (node.getNodeName().equals("ele")) { - eleStr = node.getFirstChild().getNodeValue(); - System.out.println(String.format("%8s|", eleStr)); - break; + switch (node.getNodeName()) { + case "ele": + eleStr = node.getFirstChild().getNodeValue(); + break; + case "magvar": + magvarStr = node.getFirstChild().getNodeValue(); + break; } - if (node.getNodeName().equals("magvar")) { - magvarStr = node.getFirstChild().getNodeValue(); - System.out.println(String.format("%6s|", magvarStr)); - break; - } - } - else { - System.out.println("-"); - break; } } + System.out.println(String.format("%8s|%6s|", eleStr, magvarStr)); if (exifWrite) { TiffOutputSet outputSet = null; @@ -498,7 +493,7 @@ } /** - * < lat="35.32123832" lon="139.56965631"> + * <trkpt lat="35.32123832" lon="139.56965631"> * <ele>47.20000076293945</ele> * <time>2012-06-15T03:00:29Z</time> * </trkpt> @@ -575,9 +570,24 @@ Double x = Math.toRadians(imaLON - maeLON) * r; Double y = Math.toRadians(imaLAT - maeLAT) * R; double rad = Math.toDegrees(Math.atan(y / x)); - System.out.println("magvar = " + rad); + + if (y < 0) { + rad = rad * -1; + if (x > 0) { + rad = rad + 90; + } + else { + rad = rad - 90; + } + } + magvar = ret.getOwnerDocument().createElement("magvar"); - magvar.setTextContent(Double.toString(rad)); + String str = Double.toString(rad); + int iDot = str.indexOf('.'); + if (iDot > 0) { + str = str.substring(0, iDot); + } + magvar.setTextContent(str); ret.appendChild(magvar); } }