diff --git a/importPicture/src/osm/jp/gpx/ImportPicture.java b/importPicture/src/osm/jp/gpx/ImportPicture.java index 0fb6179..784fa35 100644 --- a/importPicture/src/osm/jp/gpx/ImportPicture.java +++ b/importPicture/src/osm/jp/gpx/ImportPicture.java @@ -1,5 +1,6 @@ package osm.jp.gpx; import java.io.*; +import java.nio.channels.FileChannel; import java.text.DecimalFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -179,7 +180,7 @@ paramStr = obj.params.getProperty(AppParameters.IMG_OUTPUT_ALL); if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) { - obj.param_GpxOutputWpt = true; + obj.param_ImgOutputAll = true; } paramStr = obj.params.getProperty(AppParameters.GPX_OUTPUT_WPT); @@ -536,41 +537,48 @@ // 時刻uktimeにおけるをtrkptに追加する Element trkptE = trkpt(map, uktime); + String eleStr = "-"; + String magvarStr = "-"; + String speedStr = "-"; + double latitude = 90.5D; + double longitude = 180.5D; + TagTrkpt trkptT = null; if (trkptE == null) { System.out.println(String.format("%20s ", "Out of GPX logging time.")); - continue; + if (!this.param_ImgOutputAll) { + continue; + } + } + else { + trkptT = new TagTrkpt(trkptE); + + //Element wpt = createWptTag(image, uktime.getTime(), trkptE); + //String latStr = trkptT.lat.toString(); + //String lonStr = trkptT.lon.toString(); + latitude = trkptT.lat; + longitude = trkptT.lon; + + if (trkptT.eleStr != null) { + eleStr = new String(trkptT.eleStr); + } + + if (trkptT.magvarStr != null) { + magvarStr = new String(trkptT.magvarStr); + } + + if (trkptT.speedStr != null) { + speedStr = new String(trkptT.speedStr); + } + System.out.print(String.format("%12s %12s|", (new Double(latitude)).toString(), (new Double(longitude)).toString())); + System.out.println(String.format("%8s|%6s|%6s|", eleStr, magvarStr, speedStr)); } - TagTrkpt trkptT = new TagTrkpt(trkptE); - - //Element wpt = createWptTag(image, uktime.getTime(), trkptE); - //String latStr = trkptT.lat.toString(); - //String lonStr = trkptT.lon.toString(); - double latitude = trkptT.lat; - double longitude = trkptT.lon; - - String eleStr = "-"; - if (trkptT.eleStr != null) { - eleStr = new String(trkptT.eleStr); - } - - String magvarStr = "-"; - if (trkptT.magvarStr != null) { - magvarStr = new String(trkptT.magvarStr); - } - - String speedStr = "-"; - if (trkptT.speedStr != null) { - speedStr = new String(trkptT.speedStr); - } - - System.out.print(String.format("%12s %12s|", (new Double(latitude)).toString(), (new Double(longitude)).toString())); - System.out.println(String.format("%8s|%6s|%6s|", eleStr, magvarStr, speedStr)); ret = true; + FileOutputStream fos = null; + outDir.mkdir(); if (exifWrite) { TiffOutputSet outputSet = null; - FileOutputStream fos = null; ImageMetadata meta = Imaging.getMetadata(image); JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta; @@ -614,62 +622,63 @@ gpsDir.add(GpsTagConstants.GPS_TAG_GPS_DATE_STAMP, dateStamp); } - //---- EXIF GPS elevation/ALTITUDE ---- - if (eleStr.equals("-") == false) { - final double altitude = Double.parseDouble(eleStr); - gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_ALTITUDE); - gpsDir.add(GpsTagConstants.GPS_TAG_GPS_ALTITUDE, RationalNumber.valueOf(altitude)); + if (trkptE != null) { + //---- EXIF GPS elevation/ALTITUDE ---- + if (eleStr.equals("-") == false) { + final double altitude = Double.parseDouble(eleStr); + gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_ALTITUDE); + gpsDir.add(GpsTagConstants.GPS_TAG_GPS_ALTITUDE, RationalNumber.valueOf(altitude)); + } + + //---- EXIF GPS magvar/IMG_DIRECTION ---- + if (magvarStr.equals("-") == false) { + final double magvar = Double.parseDouble(magvarStr); + gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION); + gpsDir.add(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION, RationalNumber.valueOf(magvar)); + } + + //---- EXIF GPS_ ---- + final String longitudeRef = (longitude < 0 ? "W" : "E"); + longitude = Math.abs(longitude); + final String latitudeRef = (latitude < 0 ? "S" : "N"); + latitude = Math.abs(latitude); + + gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF); + gpsDir.add(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF, longitudeRef); + gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF); + gpsDir.add(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF, latitudeRef); + { + double value = longitude; + final double longitudeDegrees = (long) value; + value %= 1; + value *= 60.0; + final double longitudeMinutes = (long) value; + value %= 1; + value *= 60.0; + final double longitudeSeconds = value; + gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_LONGITUDE); + gpsDir.add(GpsTagConstants.GPS_TAG_GPS_LONGITUDE, + RationalNumber.valueOf(longitudeDegrees), + RationalNumber.valueOf(longitudeMinutes), + RationalNumber.valueOf(longitudeSeconds)); + } + { + double value = latitude; + final double latitudeDegrees = (long) value; + value %= 1; + value *= 60.0; + final double latitudeMinutes = (long) value; + value %= 1; + value *= 60.0; + final double latitudeSeconds = value; + gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_LATITUDE); + gpsDir.add(GpsTagConstants.GPS_TAG_GPS_LATITUDE, + RationalNumber.valueOf(latitudeDegrees), + RationalNumber.valueOf(latitudeMinutes), + RationalNumber.valueOf(latitudeSeconds)); + } } - //---- EXIF GPS magvar/IMG_DIRECTION ---- - if (magvarStr.equals("-") == false) { - final double magvar = Double.parseDouble(magvarStr); - gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION); - gpsDir.add(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION, RationalNumber.valueOf(magvar)); - } - - //---- EXIF GPS_ ---- - final String longitudeRef = (longitude < 0 ? "W" : "E"); - longitude = Math.abs(longitude); - final String latitudeRef = (latitude < 0 ? "S" : "N"); - latitude = Math.abs(latitude); - - gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF); - gpsDir.add(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF, longitudeRef); - gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF); - gpsDir.add(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF, latitudeRef); - { - double value = longitude; - final double longitudeDegrees = (long) value; - value %= 1; - value *= 60.0; - final double longitudeMinutes = (long) value; - value %= 1; - value *= 60.0; - final double longitudeSeconds = value; - gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_LONGITUDE); - gpsDir.add(GpsTagConstants.GPS_TAG_GPS_LONGITUDE, - RationalNumber.valueOf(longitudeDegrees), - RationalNumber.valueOf(longitudeMinutes), - RationalNumber.valueOf(longitudeSeconds)); - } - { - double value = latitude; - final double latitudeDegrees = (long) value; - value %= 1; - value *= 60.0; - final double latitudeMinutes = (long) value; - value %= 1; - value *= 60.0; - final double latitudeSeconds = value; - gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_LATITUDE); - gpsDir.add(GpsTagConstants.GPS_TAG_GPS_LATITUDE, - RationalNumber.valueOf(latitudeDegrees), - RationalNumber.valueOf(latitudeMinutes), - RationalNumber.valueOf(latitudeSeconds)); - } - - outDir.mkdir(); ExifRewriter rewriter = new ExifRewriter(); try { fos = new FileOutputStream(new File(outDir, imageName)); @@ -680,11 +689,31 @@ fos.close(); } } - } - if (Boolean.parseBoolean(params.getProperty(AppParameters.GPX_OUTPUT_WPT))) { - Element temp = createWptTag(image, itime.getTime(), trkptT.trkpt); - gpx.appendChild(temp); + if (Boolean.parseBoolean(params.getProperty(AppParameters.GPX_OUTPUT_WPT))) { + if (trkptT != null) { + Element temp = createWptTag(image, itime.getTime(), trkptT.trkpt); + gpx.appendChild(temp); + } + } + } + else { + if (this.param_ImgOutputAll) { + // EXIFの変換を伴わない単純なファイルコピー + FileInputStream sStream = new FileInputStream(image); + FileInputStream dStream = new FileInputStream(new File(outDir, imageName)); + FileChannel srcChannel = sStream.getChannel(); + FileChannel destChannel = dStream.getChannel(); + try { + srcChannel.transferTo(0, srcChannel.size(), destChannel); + } + finally { + srcChannel.close(); + destChannel.close(); + sStream.close(); + dStream.close(); + } + } } } return ret; @@ -692,6 +721,7 @@ static Document document; + /** * 2012-06-10T05:09:46Z (日本時間の'2012-06-10T14:09:46') */ diff --git a/importPicture/src/osm/jp/gpx/matchtime/gui/AboutDialog.java b/importPicture/src/osm/jp/gpx/matchtime/gui/AboutDialog.java index 8e82bc4..dc72b4e 100644 --- a/importPicture/src/osm/jp/gpx/matchtime/gui/AboutDialog.java +++ b/importPicture/src/osm/jp/gpx/matchtime/gui/AboutDialog.java @@ -55,7 +55,7 @@ okButton.setLabel("OK"); okButton.setBounds(145,65,66,27); add(okButton); - label2 = new java.awt.Label("Copyright(C) 2014,2016, yuuhayashi \n The MIT License (MIT).",Label.RIGHT); + label2 = new java.awt.Label("Copyright(C) 2014,2017, yuuhayashi \n The MIT License (MIT).",Label.RIGHT); label2.setBounds(10,40,340,20); add(label2); setTitle("About... "+ AdjustTime.PROGRAM_NAME); diff --git a/importPicture/src/osm/jp/gpx/matchtime/gui/AdjustTime.java b/importPicture/src/osm/jp/gpx/matchtime/gui/AdjustTime.java index c6e22c3..b22ee16 100644 --- a/importPicture/src/osm/jp/gpx/matchtime/gui/AdjustTime.java +++ b/importPicture/src/osm/jp/gpx/matchtime/gui/AdjustTime.java @@ -25,8 +25,8 @@ public class AdjustTime extends JFrame { public static final String PROGRAM_NAME = "AdjustTime for JOSM"; - public static final String PROGRAM_VARSION = "3.0"; - public static final String PROGRAM_UPDATE = "2016/10/04"; + public static final String PROGRAM_VARSION = "3.1"; + public static final String PROGRAM_UPDATE = "2017/05/15"; // Used for addNotify check. boolean fComponentsAdjusted = false; @@ -49,6 +49,7 @@ ParameterPanelImageFile arg2_baseTimeImg; ParameterPanel arg3_basetiome; JCheckBox outputIMG; // IMGの変換 する/しない + JCheckBox outputIMG_all; // 'out of GPX time'でもIMGの変換をする {ON | OFF} JCheckBox exifON; // EXIF 書き出しモード / !(EXIFの書き換えはしない) JCheckBox gpxOutputWpt; // GPXにを書き出す JCheckBox gpxOverwriteMagvar; // ソースGPXのを無視する @@ -119,6 +120,9 @@ else if (object == outputIMG) { outputIMG_Action(event); } + else if (object == outputIMG_all) { + outputIMGall_Action(event); + } else if (object == exifON) { exifON_Action(event); } @@ -281,6 +285,9 @@ outputIMG = new JCheckBox("IMGの変換をする", Boolean.parseBoolean(params.getProperty(AppParameters.IMG_OUTPUT))); tmpPanel5.add(outputIMG); + outputIMG_all = new JCheckBox("GPXファイル時間外のファイルもコピーする", Boolean.parseBoolean(params.getProperty(AppParameters.IMG_OUTPUT_ALL))); + tmpPanel5.add(outputIMG_all); + arg5_outputFolder = new ParameterPanelFolder("出力フォルダ: ", params.getProperty(AppParameters.IMG_OUTPUT_FOLDER)); tmpPanel5.add(arg5_outputFolder); @@ -338,6 +345,7 @@ arg2_baseTimeImg.argField.addActionListener(lSymAction); arg2_baseTimeImg.openButton.addActionListener(lSymAction); doButton.addActionListener(lSymAction); + outputIMG_all.addActionListener(lSymAction); exifON.addActionListener(lSymAction); gpxOutputSpeed.addActionListener(lSymAction); noFirstNode.addActionListener(lSymAction); @@ -552,6 +560,9 @@ arg5_outputFolder.setEnabled(outputIMG.isEnabled()); } + void outputIMGall_Action (ActionEvent event) { + } + /** * checkbox[EXIF書き出し]を変更した場合のアクション * @param event @@ -604,6 +615,7 @@ this.params.setProperty(AppParameters.IMG_TIME, arg3_basetiome.getText()); this.params.setProperty(AppParameters.IMG_OUTPUT, String.valueOf(outputIMG.isSelected())); this.params.setProperty(AppParameters.IMG_OUTPUT_FOLDER, arg5_outputFolder.getText()); + this.params.setProperty(AppParameters.IMG_OUTPUT_ALL, String.valueOf(exifON.isSelected())); this.params.setProperty(AppParameters.IMG_OUTPUT_EXIF, String.valueOf(exifON.isSelected())); this.params.setProperty(AppParameters.GPX_OVERWRITE_MAGVAR, String.valueOf(gpxOverwriteMagvar.isSelected())); this.params.setProperty(AppParameters.GPX_OUTPUT_SPEED, String.valueOf(gpxOutputSpeed.isSelected()));