diff --git a/importPicture/src/osm/jp/gpx/ImportPicture.java b/importPicture/src/osm/jp/gpx/ImportPicture.java index 0696de1..d219503 100644 --- a/importPicture/src/osm/jp/gpx/ImportPicture.java +++ b/importPicture/src/osm/jp/gpx/ImportPicture.java @@ -8,8 +8,8 @@ import java.util.Date; import java.util.HashMap; import java.util.Iterator; -import java.util.Locale; import java.util.Set; +import java.util.TimeZone; import java.util.logging.LogManager; import java.util.logging.Logger; @@ -175,6 +175,7 @@ */ + HashMap map = new HashMap(); Element trk = null; gpx = builder.parse(gpxFile).getFirstChild(); NodeList nodes = gpx.getChildNodes(); @@ -182,12 +183,12 @@ Node node2 = nodes.item(i); if (node2.getNodeName().equals("trk")) { trk = (Element) node2; + trkptMap(trk, map); } } if (trk != null) { - HashMap map = trkptMap(trk); - + dfjp.setTimeZone(TimeZone.getTimeZone("JST")); String timeStr = argv[2]; try { Date t = dfjp.parse(timeStr); @@ -196,7 +197,7 @@ /* * GPXへ割りつける開始時刻と終了時刻を求める */ - long gpxStartTime = (new Date()).getTime(); // 対象とする開始時刻 + long gpxStartTime = (new Date()).getTime(); // 対象とする開始時刻(現在時刻) long gpxEndTime = 0L; // 対象とする終了時刻 Set keySet = map.keySet(); //すべてのキー値を取得 for (Iterator keyIte = keySet.iterator(); keyIte.hasNext();) { @@ -212,14 +213,14 @@ System.out.println(" 時差: "+ (delta / 1000) +"(sec)"); System.out.println(" Target GPX: ["+ gpxFile.getName() +"]"); - System.out.println("GPX start time: "+ dfjp.format(new Date(gpxStartTime).getTime())); - System.out.println(" GPX end time: "+ dfjp.format(new Date(gpxEndTime).getTime())); + System.out.println("GPX start time: "+ dfjp.format(new Date(gpxStartTime)) + "\t[GMT " + dfuk.format(new Date(gpxStartTime))+"]"); + System.out.println(" GPX end time: "+ dfjp.format(new Date(gpxEndTime)) + "\t[GMT " + dfuk.format(new Date(gpxEndTime))+"]"); System.out.println(); - System.out.println("------------|--------------------|--------------------|--------|-------|--------"); - System.out.println(" name | UpdateTime | GPStime | LAT | LON | ele"); - System.out.println("------------|--------------------|--------------------|--------|-------|--------"); + System.out.println("------------|--------------------|--------------------|------------|----------|--------"); + System.out.println(" name | UpdateTime | GPStime | LAT | LON | ele"); + System.out.println("------------|--------------------|--------------------|------------|----------|--------"); proc(gpxDir, delta, gpxStartTime, gpxEndTime, map, gpx); - System.out.println("------------|--------------------|--------------------|--------|-------|--------"); + System.out.println("------------|--------------------|--------------------|------------|----------|--------"); } catch (ParseException e) { System.out.println("'"+ timeStr +"' の書式が違います("+ TIME_FORMAT_STRING +")"); @@ -275,12 +276,14 @@ Element trkpt = trkpt(map, uktime); if (trkpt != null) { System.out.print(String.format("%12s ", image.getName())); - System.out.print(String.format("%19s ", dfjp.format(itime))); - System.out.print(String.format("%19s ", dfjp.format(uktime))); + System.out.print(String.format("%20s ", dfjp.format(itime))); + System.out.print(String.format("%20s ", dfjp.format(uktime))); Element wpt = createWptTag(image, uktime.getTime(), trkpt); System.out.print(String.format("%12s ", wpt.getAttribute("lat"))); - System.out.print(String.format("%12s "+ wpt.getAttribute("lon"))); + String lonStr = wpt.getAttribute("lon"); + //System.out.print(String.format("%12s "+ lonStr)); + System.out.print(lonStr + " "); NodeList nodes = wpt.getChildNodes(); // 子ノードを取得 for (int i4=0; i4< nodes.getLength(); i4++) { @@ -291,6 +294,9 @@ System.out.println(eleStr); } } + else { + System.out.println("-"); + } } Element temp = getCopy(gpx.getOwnerDocument(), wpt); @@ -310,7 +316,7 @@ */ public static final String TIME_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ss"; public static SimpleDateFormat dfjp = new SimpleDateFormat(TIME_FORMAT_STRING); - public static SimpleDateFormat dfuk = new SimpleDateFormat(TIME_FORMAT_STRING +"'Z'", Locale.UK); + public static SimpleDateFormat dfuk = new SimpleDateFormat(TIME_FORMAT_STRING +"'Z'"); /** * XMLエレメントをTIMEでキー付したHashMapを生成する
@@ -321,9 +327,9 @@ * @return * @throws ParseException */ - public static HashMap trkptMap(Element trk) throws ParseException { - HashMap map = new HashMap(); - + public static void trkptMap(Element trk, HashMap map) throws ParseException { + dfuk.setTimeZone(TimeZone.getTimeZone("GMT")); + NodeList nodes1 = trk.getChildNodes(); for (int i1=0; i1 < nodes1.getLength(); i1++) { Node node2 = nodes1.item(i1); @@ -346,7 +352,7 @@ if (node5 != null) { if (node5.getNodeType() == Node.TEXT_NODE) { String timeStr = node5.getNodeValue(); - long t = dfuk.parse(timeStr).getTime() + (9L * 3600000L); + long t = dfuk.parse(timeStr).getTime(); map.put(new Long(t), getCopy(trk.getOwnerDocument(), trkpt)); } } @@ -357,7 +363,6 @@ } } } - return map; } public static Element trkpt(HashMap map, Date jptime) throws ParseException { @@ -377,7 +382,7 @@ } if (sa < (60000L * 10L)) { - System.out.println(dfuk.format(jpt) +" ("+ sa +")"); + // System.out.println(dfuk.format(jpt) +" ("+ sa +")"); return ret; } return null; diff --git a/importPicture/src/osm/jp/gpx/matchtime/gui/Command.java b/importPicture/src/osm/jp/gpx/matchtime/gui/Command.java index 04d67b1..130af21 100644 --- a/importPicture/src/osm/jp/gpx/matchtime/gui/Command.java +++ b/importPicture/src/osm/jp/gpx/matchtime/gui/Command.java @@ -1,4 +1,5 @@ package osm.jp.gpx.matchtime.gui; +import java.lang.reflect.InvocationTargetException; import java.text.SimpleDateFormat; class Command extends Thread { @@ -50,6 +51,11 @@ System.out.println(); System.out.println("[END:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName); } + catch (InvocationTargetException e) { + System.out.println("[ERR!:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName); + e.getCause().printStackTrace(); + throw e; + } catch (Exception e) { System.out.println("[ERR!:"+ (new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss")).format(new java.util.Date()) +"]\t"+ this.commandName); throw e;