import java.util.logging.Logger;\r
\r
import javax.xml.parsers.*;\r
-import javax.xml.transform.OutputKeys;\r
-import javax.xml.transform.Transformer;\r
import javax.xml.transform.TransformerException;\r
-import javax.xml.transform.TransformerFactory;\r
-import javax.xml.transform.dom.DOMSource;\r
-import javax.xml.transform.stream.StreamResult;\r
\r
import org.apache.commons.imaging.ImageReadException;\r
import org.apache.commons.imaging.ImageWriteException;\r
*/\r
public static void main(String[] argv) throws Exception\r
{\r
+ ImportPicture obj = new ImportPicture();\r
+ obj.setUp(((argv.length < 1) ? AppParameters.FILE_PATH : argv[0]));\r
+ }\r
+ \r
+ public File gpxDir;\r
+ public File imgDir;\r
+ public File outDir;\r
+ public long delta = 0;\r
+ public boolean exif = false;\r
+ public boolean exifBase = false;\r
+ public ArrayList<File> gpxFiles = new ArrayList<>();\r
+ public AppParameters params;\r
+ public boolean param_GpxSplit = false;\r
+ public static boolean param_GpxNoFirstNode = false;\r
+ public boolean param_GpxReuse = false;\r
+ public boolean param_GpxOutputWpt = true;\r
+ public boolean param_ImgOutputAll = false;\r
+ public String param_GpxSourceFolder = ".";\r
+ \r
+ \r
+ public static final String TIME_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ss'Z'";\r
+ private static final String EXIF_DATE_TIME_FORMAT_STRING = "yyyy:MM:dd HH:mm:ss";\r
+ \r
+ public void setUp(String paramFilePath) throws Exception {\r
+ System.out.println("Param File = '"+ paramFilePath +"'");\r
+ this.params = new AppParameters(paramFilePath);\r
+\r
Date imgtime;\r
\r
- String paramFilePath = ((argv.length < 1) ? AppParameters.FILE_PATH : argv[0]);\r
- System.out.println("Param File = '"+ paramFilePath +"'");\r
- ImportPicture obj = new ImportPicture();\r
- obj.params = new AppParameters(paramFilePath);\r
-\r
- System.out.println(" - param: "+ AppParameters.IMG_TIME +"="+ obj.params.getProperty(AppParameters.IMG_TIME) );\r
- System.out.println(" - param: "+ AppParameters.IMG_BASE_FILE +"="+ obj.params.getProperty(AppParameters.IMG_BASE_FILE) );\r
- System.out.println(" - param: "+ AppParameters.GPX_BASETIME +"="+ obj.params.getProperty(AppParameters.GPX_BASETIME) );\r
- System.out.println(" - param: "+ AppParameters.IMG_SOURCE_FOLDER +"="+ obj.params.getProperty(AppParameters.IMG_SOURCE_FOLDER) );\r
- System.out.println(" - param: "+ AppParameters.IMG_OUTPUT_FOLDER +"="+ obj.params.getProperty(AppParameters.IMG_OUTPUT_FOLDER) );\r
- System.out.println(" - param: "+ AppParameters.IMG_OUTPUT +"="+ obj.params.getProperty(AppParameters.IMG_OUTPUT)); \r
- System.out.println(" - param: "+ AppParameters.IMG_OUTPUT_ALL +"="+ obj.param_ImgOutputAll);\r
- System.out.println(" - param: "+ AppParameters.IMG_OUTPUT_EXIF +"= "+ String.valueOf(obj.exif));\r
- System.out.println(" - param: "+ AppParameters.GPX_SOURCE_FOLDER +"="+ obj.param_GpxSourceFolder);\r
- System.out.println(" - param: "+ AppParameters.GPX_OUTPUT_WPT +"="+ obj.param_GpxOutputWpt);\r
+ System.out.println(" - param: "+ AppParameters.IMG_TIME +"="+ this.params.getProperty(AppParameters.IMG_TIME) );\r
+ System.out.println(" - param: "+ AppParameters.IMG_BASE_FILE +"="+ this.params.getProperty(AppParameters.IMG_BASE_FILE) );\r
+ System.out.println(" - param: "+ AppParameters.GPX_BASETIME +"="+ this.params.getProperty(AppParameters.GPX_BASETIME) );\r
+ System.out.println(" - param: "+ AppParameters.IMG_SOURCE_FOLDER +"="+ this.params.getProperty(AppParameters.IMG_SOURCE_FOLDER) );\r
+ System.out.println(" - param: "+ AppParameters.IMG_OUTPUT_FOLDER +"="+ this.params.getProperty(AppParameters.IMG_OUTPUT_FOLDER) );\r
+ System.out.println(" - param: "+ AppParameters.IMG_OUTPUT +"="+ this.params.getProperty(AppParameters.IMG_OUTPUT)); \r
+ System.out.println(" - param: "+ AppParameters.IMG_OUTPUT_ALL +"="+ this.param_ImgOutputAll);\r
+ System.out.println(" - param: "+ AppParameters.IMG_OUTPUT_EXIF +"= "+ String.valueOf(this.exif));\r
+ System.out.println(" - param: "+ AppParameters.GPX_SOURCE_FOLDER +"="+ this.param_GpxSourceFolder);\r
+ System.out.println(" - param: "+ AppParameters.GPX_OUTPUT_WPT +"="+ this.param_GpxOutputWpt);\r
System.out.println(" - param: "+ AppParameters.GPX_OVERWRITE_MAGVAR +"="+ Complementation.param_GpxOverwriteMagvar);\r
System.out.println(" - param: "+ AppParameters.GPX_OUTPUT_SPEED +"="+ Complementation.param_GpxOutputSpeed);\r
- System.out.println(" - param: "+ AppParameters.GPX_GPXSPLIT +"="+ obj.param_GpxSplit);\r
+ System.out.println(" - param: "+ AppParameters.GPX_GPXSPLIT +"="+ this.param_GpxSplit);\r
System.out.println(" - param: "+ AppParameters.GPX_NO_FIRST_NODE +"="+ ImportPicture.param_GpxNoFirstNode); \r
- System.out.println(" - param: "+ AppParameters.GPX_REUSE +"="+ obj.param_GpxReuse);\r
+ System.out.println(" - param: "+ AppParameters.GPX_REUSE +"="+ this.param_GpxReuse);\r
\r
- obj.ex = null;\r
+ this.ex = null;\r
// argv[0] --> AppParameters.IMG_SOURCE_FOLDER に置き換え\r
- obj.imgDir = new File(obj.params.getProperty(AppParameters.IMG_SOURCE_FOLDER));\r
+ this.imgDir = new File(this.params.getProperty(AppParameters.IMG_SOURCE_FOLDER));\r
\r
// 基準時刻(ファイル更新日時 | EXIF撮影日時)\r
- obj.exifBase = (obj.params.getProperty(AppParameters.GPX_BASETIME).equals("EXIF_TIME") ? true : false);\r
+ this.exifBase = (this.params.getProperty(AppParameters.GPX_BASETIME).equals("EXIF_TIME") ? true : false);\r
\r
// 基準時刻ファイルの「更新日時」を使って時刻合わせを行う。\r
// argv[1] --> AppParameters.IMG_BASE_FILE に置き換え\r
- File baseFile = new File(obj.imgDir, obj.params.getProperty(AppParameters.IMG_BASE_FILE));\r
- if (obj.exifBase) {\r
- ImageMetadata meta = Imaging.getMetadata(baseFile);\r
- JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta;\r
- if (jpegMetadata == null) {\r
- System.out.println("'"+ baseFile.getAbsolutePath() +"' にEXIF情報がありません");\r
- return;\r
- }\r
- TiffImageMetadata exif = jpegMetadata.getExif();\r
- if (exif == null) {\r
- System.out.println("'"+ baseFile.getAbsolutePath() +"' にEXIF情報がありません");\r
- return;\r
- }\r
- String dateTimeOriginal = exif.getFieldValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL)[0];\r
- long lastModifyTime = ImportPicture.toEXIFDate(dateTimeOriginal).getTime();\r
- imgtime = new Date(lastModifyTime);\r
- }\r
- else {\r
- imgtime = new Date(baseFile.lastModified());\r
- }\r
+ imgtime = this.adjustTime(new File(this.imgDir, this.params.getProperty(AppParameters.IMG_BASE_FILE)));\r
\r
// 出力ファイル\r
// argv[3] --> AppParameters.IMG_OUTPUT に置き換え\r
- obj.outDir = new File(obj.params.getProperty(AppParameters.IMG_OUTPUT_FOLDER));\r
+ this.outDir = new File(this.params.getProperty(AppParameters.IMG_OUTPUT_FOLDER));\r
\r
// その他のパラメータを読み取る\r
- String paramStr = obj.params.getProperty(AppParameters.GPX_GPXSPLIT);\r
+ String paramStr = this.params.getProperty(AppParameters.GPX_GPXSPLIT);\r
if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {\r
- obj.param_GpxSplit = true;\r
+ this.param_GpxSplit = true;\r
}\r
\r
- paramStr = obj.params.getProperty(AppParameters.GPX_NO_FIRST_NODE);\r
+ paramStr = this.params.getProperty(AppParameters.GPX_NO_FIRST_NODE);\r
if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {\r
ImportPicture.param_GpxNoFirstNode = true;\r
}\r
\r
- paramStr = obj.params.getProperty(AppParameters.GPX_REUSE);\r
+ paramStr = this.params.getProperty(AppParameters.GPX_REUSE);\r
if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {\r
- obj.param_GpxReuse = true;\r
+ this.param_GpxReuse = true;\r
}\r
\r
- paramStr = obj.params.getProperty(AppParameters.IMG_OUTPUT_ALL);\r
+ paramStr = this.params.getProperty(AppParameters.IMG_OUTPUT_ALL);\r
if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {\r
- obj.param_ImgOutputAll = true;\r
+ this.param_ImgOutputAll = true;\r
}\r
\r
- paramStr = obj.params.getProperty(AppParameters.GPX_OUTPUT_WPT);\r
+ paramStr = this.params.getProperty(AppParameters.GPX_OUTPUT_WPT);\r
if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {\r
- obj.param_GpxOutputWpt = true;\r
+ this.param_GpxOutputWpt = true;\r
}\r
\r
- paramStr = obj.params.getProperty(AppParameters.GPX_OVERWRITE_MAGVAR);\r
+ paramStr = this.params.getProperty(AppParameters.GPX_OVERWRITE_MAGVAR);\r
if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {\r
Complementation.param_GpxOverwriteMagvar = true;\r
}\r
\r
- paramStr = obj.params.getProperty(AppParameters.GPX_OUTPUT_SPEED);\r
+ paramStr = this.params.getProperty(AppParameters.GPX_OUTPUT_SPEED);\r
if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {\r
Complementation.param_GpxOutputSpeed = true;\r
}\r
\r
- paramStr = obj.params.getProperty(AppParameters.GPX_SOURCE_FOLDER);\r
+ paramStr = this.params.getProperty(AppParameters.GPX_SOURCE_FOLDER);\r
if (paramStr != null) {\r
- obj.param_GpxSourceFolder = new String(paramStr);\r
- obj.gpxDir = new File(obj.param_GpxSourceFolder);\r
- if (!obj.gpxDir.exists()) {\r
+ this.param_GpxSourceFolder = new String(paramStr);\r
+ this.gpxDir = new File(this.param_GpxSourceFolder);\r
+ if (!this.gpxDir.exists()) {\r
// GPXファイルまたはディレクトリが存在しません。\r
System.out.println("GPXファイルまたはディレクトリが存在しません。('"+ paramStr +"')");\r
return;\r
}\r
}\r
else {\r
- obj.gpxDir = obj.imgDir;\r
+ this.gpxDir = this.imgDir;\r
}\r
\r
// 指定されたディレクトリ内のGPXファイルすべてを対象とする\r
- if (obj.gpxDir.isDirectory()) {\r
- File[] files = obj.gpxDir.listFiles();\r
+ if (this.gpxDir.isDirectory()) {\r
+ File[] files = this.gpxDir.listFiles();\r
if (files == null) {\r
// 対象となるGPXファイルがありませんでした。\r
- System.out.println("対象となるGPXファイルがありませんでした。('"+ obj.gpxDir.getAbsolutePath() +"')");\r
+ System.out.println("対象となるGPXファイルがありませんでした。('"+ this.gpxDir.getAbsolutePath() +"')");\r
return;\r
}\r
- if (obj.param_ImgOutputAll && (files.length > 1)) {\r
+ if (this.param_ImgOutputAll && (files.length > 1)) {\r
System.out.println("複数のGPXファイルがあるときには、'IMG.OUTPUT_ALL'オプションは指定できません。");\r
return;\r
}\r
if (file.isFile()) {\r
String filename = file.getName().toUpperCase();\r
if (filename.toUpperCase().endsWith(".GPX")) {\r
- if (!filename.toUpperCase().endsWith("_.GPX") || obj.param_GpxReuse) {\r
- obj.gpxFiles.add(file);\r
+ if (!filename.toUpperCase().endsWith("_.GPX") || this.param_GpxReuse) {\r
+ this.gpxFiles.add(file);\r
}\r
}\r
}\r
}\r
}\r
else {\r
- obj.gpxFiles.add(obj.gpxDir);\r
+ this.gpxFiles.add(this.gpxDir);\r
}\r
\r
- paramStr = obj.params.getProperty(AppParameters.IMG_OUTPUT_EXIF);\r
+ paramStr = this.params.getProperty(AppParameters.IMG_OUTPUT_EXIF);\r
if ((paramStr != null) && (paramStr.equals(Boolean.toString(true)))) {\r
- obj.exif = true;\r
+ this.exif = true;\r
}\r
\r
- String timeStr = obj.params.getProperty(AppParameters.IMG_TIME);\r
+ String timeStr = this.params.getProperty(AppParameters.IMG_TIME);\r
try {\r
Date t = toUTCDate(timeStr);\r
- obj.delta = t.getTime() - imgtime.getTime();\r
+ this.delta = t.getTime() - imgtime.getTime();\r
}\r
catch (ParseException e) {\r
System.out.println("'"+ timeStr +"' の書式が違います("+ TIME_FORMAT_STRING +")");\r
return;\r
}\r
\r
- obj.start();\r
+ this.start();\r
try {\r
- obj.join();\r
+ this.join();\r
} catch(InterruptedException end) {}\r
- if (obj.ex != null) {\r
- throw obj.ex;\r
+ if (this.ex != null) {\r
+ throw this.ex;\r
}\r
+ \r
}\r
\r
- public File gpxDir;\r
- public File imgDir;\r
- public File outDir;\r
- public long delta = 0;\r
- public boolean exif = false;\r
- public boolean exifBase = false;\r
- public ArrayList<File> gpxFiles = new ArrayList<>();\r
- public AppParameters params;\r
- public boolean param_GpxSplit = false;\r
- public static boolean param_GpxNoFirstNode = false;\r
- public boolean param_GpxReuse = false;\r
- public boolean param_GpxOutputWpt = true;\r
- public boolean param_ImgOutputAll = false;\r
- public String param_GpxSourceFolder = ".";\r
- Document document;\r
- \r
- public static final String TIME_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ss'Z'";\r
- private static final String EXIF_DATE_TIME_FORMAT_STRING = "yyyy:MM:dd HH:mm:ss";\r
-\r
@Override\r
public void run() {\r
/**\r
}\r
\r
for (File gpxFile : this.gpxFiles) {\r
- procGPXfile(gpxFile);\r
+ procGPXfile(new GpxFile(gpxFile));\r
}\r
}\r
catch(ParserConfigurationException | DOMException | SAXException | IOException | ParseException | ImageReadException | ImageWriteException | IllegalArgumentException | TransformerException e) {\r
* @throws ImageReadException \r
* @throws TransformerException \r
*/\r
- void procGPXfile(File gpxFile) throws ParserConfigurationException, SAXException, IOException, ParseException, ImageReadException, ImageWriteException, TransformerException {\r
- DocumentBuilderFactory factory = null;\r
- DocumentBuilder builder = null;\r
- ElementMapTRKSEG mapTRKSEG = null;\r
- Node gpx = null;\r
- \r
+ void procGPXfile(GpxFile gpxFile) throws ParserConfigurationException, SAXException, IOException, ParseException, ImageReadException, ImageWriteException, TransformerException {\r
System.gc();\r
\r
- String fileName = gpxFile.getName();\r
- String iStr = fileName.substring(0, fileName.length() - 4);\r
-\r
- File outputFile = new File(outDir, iStr +"_.gpx");\r
- System.out.println(gpxFile.getAbsolutePath() + " => "+ outputFile.getAbsolutePath());\r
System.out.println(" 時差: "+ (delta / 1000) +"(sec)");\r
System.out.println(" Target GPX: ["+ gpxFile.getAbsolutePath() +"]");\r
System.out.println(" EXIF: "+ (exif ? ("convert to '" + outDir.getAbsolutePath() +"'") : "off"));\r
System.out.println();\r
\r
- factory = DocumentBuilderFactory.newInstance();\r
- builder = factory.newDocumentBuilder();\r
- factory.setIgnoringElementContentWhitespace(true);\r
- factory.setIgnoringComments(true);\r
- factory.setValidating(true);\r
-\r
- // GPXファイルをパースする\r
- mapTRKSEG = new ElementMapTRKSEG();\r
- document = mapTRKSEG.parse(gpxFile);\r
- \r
- // パースされた mapTRKSEG の中身を出力する\r
- mapTRKSEG.printinfo();\r
- \r
- // GPX file --> Node root\r
- gpx = builder.parse(gpxFile).getFirstChild();\r
-\r
// imgDir内の画像ファイルを処理する\r
System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|");\r
System.out.println("| name | Camera Time | GPStime | Latitude | Longitude | ele |magvar| km/h |");\r
System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|");\r
- proc(imgDir, delta, mapTRKSEG, exif, gpx);\r
+ proc(imgDir, delta, gpxFile.mapTRKSEG, exif, gpxFile);\r
System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|");\r
\r
- // 出力\r
- outputFile.getParentFile().mkdirs();\r
- DOMSource source = new DOMSource(gpx);\r
- FileOutputStream os = new FileOutputStream(outputFile);\r
- StreamResult result = new StreamResult(os);\r
- TransformerFactory transFactory = TransformerFactory.newInstance();\r
- Transformer transformer = transFactory.newTransformer();\r
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");\r
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");\r
- transformer.transform(source, result); \r
-\r
- os = new FileOutputStream(outputFile);\r
- result = new StreamResult(os);\r
- transformer.transform(source, result);\r
+ // GPX出力\r
+ gpxFile.output(outDir);\r
}\r
\r
\r
* @throws ImageReadException \r
* @throws ImageWriteException \r
*/\r
- boolean proc(File dir, long delta, ElementMapTRKSEG mapTRKSEG, boolean exifWrite, Node gpx) throws ParseException, ImageReadException, IOException, ImageWriteException {\r
+ boolean proc(File dir, long delta, ElementMapTRKSEG mapTRKSEG, boolean exifWrite, GpxFile gpxFile) throws ParseException, ImageReadException, IOException, ImageWriteException {\r
boolean ret = false;\r
File[] files = dir.listFiles(new JpegFileFilter());\r
Arrays.sort(files, new FileSort());\r
for (File image : files) {\r
System.out.print(String.format("|%-32s|", image.getName()));\r
if (image.isDirectory()) {\r
- ret = proc(image, delta, mapTRKSEG, exifWrite, gpx);\r
+ ret = proc(image, delta, mapTRKSEG, exifWrite, gpxFile);\r
continue;\r
}\r
\r
continue;\r
}\r
\r
- Discripter result = procImageFile(image, delta, mapTRKSEG, exifWrite, gpx);\r
+ Discripter result = procImageFile(image, delta, mapTRKSEG, exifWrite, gpxFile);\r
ret |= result.ret;\r
switch (result.control) {\r
case Discripter.CONTINUE:\r
}\r
}\r
\r
- Discripter procImageFile(File imageFile, long delta, ElementMapTRKSEG mapTRKSEG, boolean exifWrite, Node gpx) throws ParseException, ImageReadException, IOException, ImageWriteException {\r
+ Discripter procImageFile(File imageFile, long delta, ElementMapTRKSEG mapTRKSEG, boolean exifWrite, GpxFile gpxFile) throws ParseException, ImageReadException, IOException, ImageWriteException {\r
Discripter result = new Discripter(false);\r
\r
// itime <-- 画像ファイルの撮影時刻\r
\r
if (Boolean.parseBoolean(params.getProperty(AppParameters.GPX_OUTPUT_WPT))) {\r
if (trkptT != null) {\r
- Element temp = createWptTag(imageFile, itime.getTime(), trkptT.trkpt);\r
- gpx.appendChild(temp);\r
+ Element temp = gpxFile.createWptTag(imageFile, imgDir, itime.getTime(), trkptT.trkpt);\r
+ gpxFile.gpx.appendChild(temp);\r
}\r
}\r
}\r
}\r
\r
}\r
+ \r
+ // 基準時刻ファイルの「更新日時」を使って時刻合わせを行う。\r
+ // argv[1] --> AppParameters.IMG_BASE_FILE に置き換え\r
+ // File baseFile = new File(this.imgDir, this.params.getProperty(AppParameters.IMG_BASE_FILE));\r
+ private Date adjustTime(File baseFile) throws ImageReadException, IOException, ParseException {\r
+ if (exifBase) {\r
+ ImageMetadata meta = Imaging.getMetadata(baseFile);\r
+ JpegImageMetadata jpegMetadata = (JpegImageMetadata)meta;\r
+ if (jpegMetadata == null) {\r
+ System.out.println("'"+ baseFile.getAbsolutePath() +"' にEXIF情報がありません");\r
+ return null;\r
+ }\r
+ TiffImageMetadata exif = jpegMetadata.getExif();\r
+ if (exif == null) {\r
+ System.out.println("'"+ baseFile.getAbsolutePath() +"' にEXIF情報がありません");\r
+ return null;\r
+ }\r
+ String dateTimeOriginal = exif.getFieldValue(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL)[0];\r
+ return new Date(ImportPicture.toEXIFDate(dateTimeOriginal).getTime());\r
+ }\r
+ else {\r
+ return new Date(baseFile.lastModified());\r
+ }\r
+ }\r
+\r
\r
/**\r
* 対象は '*.JPG' のみ対象とする\r
return ((name != null) && name.toUpperCase().endsWith(".JPG"));\r
}\r
\r
- /**\r
- * <wpt lat="35.25714922" lon="139.15490497">\r
- * <ele>62.099998474121094</ele>\r
- * <time>2012-06-11T00:44:38Z</time>\r
- * <name><![CDATA[写真]]></name>\r
- * <link href="2012-06-11_09-44-38.jpg">\r
- * <text>2012-06-11_09-44-38.jpg</text>\r
- * </link>\r
- * </wpt>\r
- *\r
- * <trkpt lat="35.32123832" lon="139.56965631">\r
- * <ele>47.20000076293945</ele>\r
- * <time>2012-06-15T03:00:29Z</time>\r
- * </trkpt>\r
- *\r
- * @return\r
- * @param iFile\r
- * @param timestamp\r
- * @param trkpt\r
- */\r
- public Element createWptTag(File iFile, long timestamp, Element trkpt) {\r
- Element wpt = document.createElement("wpt");\r
-\r
- NamedNodeMap nodeMap = trkpt.getAttributes();\r
- if (null != nodeMap) {\r
- for (int j=0; j < nodeMap.getLength(); j++ ) {\r
- switch (nodeMap.item(j).getNodeName()) {\r
- case "lat":\r
- String lat = nodeMap.item(j).getNodeValue();\r
- wpt.setAttribute("lat", lat);\r
- break;\r
- case "lon":\r
- String lon = nodeMap.item(j).getNodeValue();\r
- wpt.setAttribute("lon", lon);\r
- break;\r
- }\r
- }\r
- }\r
\r
- NodeList nodes1 = trkpt.getChildNodes();\r
- for (int i1=0; i1 < nodes1.getLength(); i1++) {\r
- Node node1 = nodes1.item(i1);\r
- NodeList nodes2 = node1.getChildNodes();\r
- switch (node1.getNodeName()) {\r
- case "ele":\r
- for (int i2=0; i2 < nodes2.getLength(); i2++) {\r
- Node node2 = nodes2.item(i2);\r
- if (node2 != null) {\r
- if (node2.getNodeType() == Node.TEXT_NODE) {\r
- String eleStr = node2.getNodeValue();\r
- Element eleE = document.createElement("ele");\r
- eleE.setTextContent(eleStr);\r
- wpt.appendChild(eleE);\r
- }\r
- }\r
- }\r
- break;\r
- case "time":\r
- for (int i2=0; i2 < nodes2.getLength(); i2++) {\r
- Node node2 = nodes2.item(i2);\r
- if (node2 != null) {\r
- if (node2.getNodeType() == Node.TEXT_NODE) {\r
- String timeStr = node2.getNodeValue();\r
- Element timeE = document.createElement("time");\r
- timeE.setTextContent(timeStr);\r
- wpt.appendChild(timeE);\r
- }\r
- }\r
- }\r
- break;\r
- case "magvar":\r
- for (int i2=0; i2 < nodes2.getLength(); i2++) {\r
- Node node2 = nodes2.item(i2);\r
- if (node2 != null) {\r
- if (node2.getNodeType() == Node.TEXT_NODE) {\r
- String magvarStr = node2.getNodeValue();\r
- Element magvarE = document.createElement("magvar");\r
- magvarE.setTextContent(magvarStr);\r
- wpt.appendChild(magvarE);\r
- }\r
- }\r
- }\r
- break;\r
- case "speed":\r
- for (int i2=0; i2 < nodes2.getLength(); i2++) {\r
- Node node2 = nodes2.item(i2);\r
- if (node2 != null) {\r
- if (node2.getNodeType() == Node.TEXT_NODE) {\r
- String speedStr = node2.getNodeValue();\r
- Element speedE = document.createElement("speed");\r
- speedE.setTextContent(speedStr);\r
- wpt.appendChild(speedE);\r
- }\r
- }\r
- }\r
- break;\r
- }\r
- }\r
-\r
- Element name = document.createElement("name");\r
- name.appendChild(document.createCDATASection("写真"));\r
- wpt.appendChild(name);\r
-\r
- Element link = document.createElement("link");\r
- link.setAttribute("href", ImportPicture.getShortPathName(imgDir, iFile));\r
- Element text = document.createElement("text");\r
- text.setTextContent(iFile.getName());\r
- link.appendChild(text);\r
- wpt.appendChild(link);\r
-\r
- return wpt;\r
- }\r
- \r
/**\r
* DateをEXIFの文字列に変換する。\r
* 注意:EXiFの撮影時刻はUTC時間ではない\r