diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..c32e555
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..4e0947d
--- /dev/null
+++ b/.project
@@ -0,0 +1,27 @@
+
+
+ AdjustTime
+
+
+
+
+
+ org.eclipse.ui.externaltools.ExternalToolBuilder
+ full,incremental,
+
+
+ LaunchConfigHandle
+ <project>/.externalToolBuilders/New_Builder.launch
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/importPicture/src/osm/jp/gpx/ImportPicture.java b/importPicture/src/osm/jp/gpx/ImportPicture.java
index 29d4c4b..3c798bb 100644
--- a/importPicture/src/osm/jp/gpx/ImportPicture.java
+++ b/importPicture/src/osm/jp/gpx/ImportPicture.java
@@ -321,167 +321,176 @@
File[] files = dir.listFiles();
Arrays.sort(files, new FileSort());
for (File image : files) {
+ System.out.print(String.format("%12s|", image.getName()));
if (image.isDirectory()) {
ret = proc(image, delta, gpxStartTime, gpxEndTime, map, exifWrite, gpx);
+ continue;
}
- else {
- String imageName = image.getName();
- if (checkFile(imageName)) {
- Date itime = new Date(image.lastModified());
- Date uktime = new Date(itime.getTime() + delta);
- if ((uktime.getTime() >= gpxStartTime) && (uktime.getTime() <= gpxEndTime)) {
- Element trkpt = trkpt(map, uktime);
- if (trkpt != null) {
- Element wpt = createWptTag(image, uktime.getTime(), trkpt);
- String latStr = wpt.getAttribute("lat");
- String lonStr = wpt.getAttribute("lon");
- double latitude = Double.parseDouble(latStr);
- double longitude = Double.parseDouble(lonStr);
-
- String eleStr = "-";
- String magvarStr = "-";
- NodeList nodes = wpt.getChildNodes(); // 子ノードを取得
- for (int i4 = 0; i4 < nodes.getLength(); i4++) {
- Node node = nodes.item(i4);
- if (node != null) {
- switch (node.getNodeName()) {
- case "ele":
- eleStr = node.getFirstChild().getNodeValue();
- break;
- case "magvar":
- magvarStr = node.getFirstChild().getNodeValue();
- break;
- }
- }
- }
+
+ String imageName = image.getName();
+ if (!checkFile(imageName)) {
+ System.out.println(String.format("%20s ", "it is not image file."));
+ continue;
+ }
+
+ Date itime = new Date(image.lastModified());
+ Date uktime = new Date(itime.getTime() + delta);
+ System.out.print(String.format("%20s ", dfjp.format(itime)));
+ System.out.print(String.format("%20s|", dfjp.format(uktime)));
+ if ((uktime.getTime() < gpxStartTime) || (uktime.getTime() > gpxEndTime)) {
+ System.out.println(String.format("%20s ", "out of time."));
+ continue;
+ }
- System.out.print(String.format("%12s|", image.getName()));
- System.out.print(String.format("%20s ", dfjp.format(itime)));
- System.out.print(String.format("%20s|", dfjp.format(uktime)));
- System.out.print(String.format("%12s %12s|", latStr, lonStr));
- System.out.println(String.format("%8s|%6s|", eleStr, magvarStr));
- ret = true;
-
- if (exifWrite) {
- TiffOutputSet outputSet = null;
- FileOutputStream fos = null;
-
- ImageMetadata meta = Imaging.getMetadata(image);
- JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta;
- if (jpegMetadata != null) {
- TiffImageMetadata exif = jpegMetadata.getExif();
- if (exif != null) {
- outputSet = exif.getOutputSet();
- }
- }
-
- if (outputSet == null) {
- System.out.println("added : new tiff output set");
- outputSet = new TiffOutputSet();
- }
-
- //---- EXIF_TAG_DATE_TIME_ORIGINAL / 「撮影日時/オリジナル画像の生成日時」----
- TiffOutputDirectory exifDir = outputSet.getOrCreateExifDirectory();
- {
- Calendar cal = GregorianCalendar.getInstance();
- cal.setTime(uktime);
- exifDir.removeField(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
- exifDir.add(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL, new SimpleDateFormat("yyyy:MM:dd HH:mm:ss").format(cal.getTime()));
- }
-
- //---- EXIF GPS_TIME_STAMP ----
- TiffOutputDirectory gpsDir = outputSet.getOrCreateGPSDirectory();
- {
- Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC"));
- cal.setTime(uktime);
- final String yearStr = yearFormatter.format(cal.get(Calendar.YEAR));
- final String monthStr = monthFormatter.format(cal.get(Calendar.MONTH) + 1);
- final String dayStr = dayFormatter.format(cal.get(Calendar.DAY_OF_MONTH));
- final String dateStamp = yearStr +":"+ monthStr +":"+ dayStr;
-
- gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_TIME_STAMP);
- gpsDir.add(GpsTagConstants.GPS_TAG_GPS_TIME_STAMP,
- RationalNumber.valueOf(cal.get(Calendar.HOUR_OF_DAY)),
- RationalNumber.valueOf(cal.get(Calendar.MINUTE)),
- RationalNumber.valueOf(cal.get(Calendar.SECOND)));
- gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_DATE_STAMP);
- 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));
- }
-
- //---- 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));
- rewriter.updateExifMetadataLossy(image, fos, outputSet);
- }
- finally {
- if (fos != null) {
- fos.close();
- }
- }
- }
-
- Element temp = getCopy(gpx.getOwnerDocument(), wpt);
- gpx.appendChild(temp);
- }
+ Element trkpt = trkpt(map, uktime);
+ if (trkpt == null) {
+ System.out.println(String.format("%20s ", "Out of GPX logging time."));
+ continue;
+ }
+
+ Element wpt = createWptTag(image, uktime.getTime(), trkpt);
+ String latStr = wpt.getAttribute("lat");
+ String lonStr = wpt.getAttribute("lon");
+ double latitude = Double.parseDouble(latStr);
+ double longitude = Double.parseDouble(lonStr);
+
+ String eleStr = "-";
+ String magvarStr = "-";
+ NodeList nodes = wpt.getChildNodes(); // 子ノードを取得
+ for (int i4 = 0; i4 < nodes.getLength(); i4++) {
+ Node node = nodes.item(i4);
+ if (node != null) {
+ switch (node.getNodeName()) {
+ case "ele":
+ eleStr = node.getFirstChild().getNodeValue();
+ break;
+ case "magvar":
+ magvarStr = node.getFirstChild().getNodeValue();
+ break;
}
}
}
+
+ System.out.print(String.format("%12s %12s|", latStr, lonStr));
+ System.out.println(String.format("%8s|%6s|", eleStr, magvarStr));
+ ret = true;
+
+ if (exifWrite) {
+ TiffOutputSet outputSet = null;
+ FileOutputStream fos = null;
+
+ ImageMetadata meta = Imaging.getMetadata(image);
+ JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta;
+ if (jpegMetadata != null) {
+ TiffImageMetadata exif = jpegMetadata.getExif();
+ if (exif != null) {
+ outputSet = exif.getOutputSet();
+ }
+ }
+
+ if (outputSet == null) {
+ System.out.println("added : new tiff output set");
+ outputSet = new TiffOutputSet();
+ }
+
+ //---- EXIF_TAG_DATE_TIME_ORIGINAL / 「撮影日時/オリジナル画像の生成日時」----
+ TiffOutputDirectory exifDir = outputSet.getOrCreateExifDirectory();
+ {
+ Calendar cal = GregorianCalendar.getInstance();
+ cal.setTime(uktime);
+ exifDir.removeField(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
+ exifDir.add(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL, new SimpleDateFormat("yyyy:MM:dd HH:mm:ss").format(cal.getTime()));
+ }
+
+ //---- EXIF GPS_TIME_STAMP ----
+ TiffOutputDirectory gpsDir = outputSet.getOrCreateGPSDirectory();
+ {
+ Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("UTC"));
+ cal.setTime(uktime);
+ final String yearStr = yearFormatter.format(cal.get(Calendar.YEAR));
+ final String monthStr = monthFormatter.format(cal.get(Calendar.MONTH) + 1);
+ final String dayStr = dayFormatter.format(cal.get(Calendar.DAY_OF_MONTH));
+ final String dateStamp = yearStr +":"+ monthStr +":"+ dayStr;
+
+ gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_TIME_STAMP);
+ gpsDir.add(GpsTagConstants.GPS_TAG_GPS_TIME_STAMP,
+ RationalNumber.valueOf(cal.get(Calendar.HOUR_OF_DAY)),
+ RationalNumber.valueOf(cal.get(Calendar.MINUTE)),
+ RationalNumber.valueOf(cal.get(Calendar.SECOND)));
+ gpsDir.removeField(GpsTagConstants.GPS_TAG_GPS_DATE_STAMP);
+ 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));
+ }
+
+ //---- 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));
+ rewriter.updateExifMetadataLossy(image, fos, outputSet);
+ }
+ finally {
+ if (fos != null) {
+ fos.close();
+ }
+ }
+ }
+
+ Element temp = getCopy(gpx.getOwnerDocument(), wpt);
+ gpx.appendChild(temp);
}
return ret;
}