| |
---|
| | public boolean param_GpxReuse = false; |
---|
| | public boolean param_GpxOutputWpt = true; |
---|
| | public boolean param_ImgOutputAll = false; |
---|
| | public String param_GpxSourceFolder = "."; |
---|
| | |
---|
| | Document document; |
---|
| | |
---|
| | public static final String TIME_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ss"; |
---|
| | public static final SimpleDateFormat dfjp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
---|
| | public static final SimpleDateFormat dfuk = new SimpleDateFormat(TIME_FORMAT_STRING +"'Z'"); |
---|
| | |
---|
| | @Override |
---|
| | public void run() { |
---|
| | /** |
---|
| | * |
---|
| |
---|
| | * @throws ImageReadException |
---|
| | * @throws TransformerException |
---|
| | */ |
---|
| | void procGPXfile(File gpxFile) throws ParserConfigurationException, SAXException, IOException, ParseException, ImageReadException, ImageWriteException, TransformerException { |
---|
| | DocumentBuilderFactory factory; |
---|
| | DocumentBuilder builder; |
---|
| | DocumentBuilderFactory factory = null; |
---|
| | DocumentBuilder builder = null; |
---|
| | ElementMapTRKSEG mapTRKSEG = null; |
---|
| | Node gpx = null; |
---|
| | |
---|
| | System.gc(); |
---|
| | |
---|
| | String fileName = gpxFile.getName(); |
---|
| | String iStr = fileName.substring(0, fileName.length() - 4); |
---|
| | |
---|
| |
---|
| | factory.setIgnoringComments(true); |
---|
| | factory.setValidating(true); |
---|
| | |
---|
| | // GPXファイルをパースする |
---|
| | ElementMapTRKSEG mapTRKSEG = new ElementMapTRKSEG(); |
---|
| | mapTRKSEG = new ElementMapTRKSEG(); |
---|
| | document = mapTRKSEG.parse(gpxFile); |
---|
| | |
---|
| | // パースされた mapTRKSEG の中身を出力する |
---|
| | mapTRKSEG.printinfo(); |
---|
| | |
---|
| | // GPX file --> Node root |
---|
| | Node gpx = builder.parse(gpxFile).getFirstChild(); |
---|
| | gpx = builder.parse(gpxFile).getFirstChild(); |
---|
| | |
---|
| | // imgDir内の画像ファイルを処理する |
---|
| | System.out.println("|--------------------------------|--------------------|--------------------|--------------|--------------|--------|------|------|"); |
---|
| | System.out.println("| name | Camera Time | GPStime | Latitude | Longitude | ele |magvar| km/h |"); |
---|
| |
---|
| | } |
---|
| | return ret; |
---|
| | } |
---|
| | |
---|
| | static Document document; |
---|
| | |
---|
| | |
---|
| | /** |
---|
| | * 2012-06-10T05:09:46Z (日本時間の'2012-06-10T14:09:46') |
---|
| | */ |
---|
| | public static final String TIME_FORMAT_STRING = "yyyy-MM-dd'T'HH:mm:ss"; |
---|
| | public static SimpleDateFormat dfjp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
---|
| | public static SimpleDateFormat dfuk = new SimpleDateFormat(TIME_FORMAT_STRING +"'Z'"); |
---|
| | |
---|
| | /** |
---|
| | * 対象は '*.JPG' のみ対象とする |
---|
| | * @return |
---|
| | * @param name |
---|
| |
---|
| | name.appendChild(document.createCDATASection("写真")); |
---|
| | wpt.appendChild(name); |
---|
| | |
---|
| | Element link = document.createElement("link"); |
---|
| | link.setAttribute("href", getShortPathName(imgDir, iFile)); |
---|
| | link.setAttribute("href", ImportPicture.getShortPathName(imgDir, iFile)); |
---|
| | Element text = document.createElement("text"); |
---|
| | text.setTextContent(iFile.getName()); |
---|
| | link.appendChild(text); |
---|
| | wpt.appendChild(link); |
---|
| |
---|
| | else { |
---|
| | return filePath; |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | public static Element getCopy(Document doc, Node node) { |
---|
| | Element root = doc.createElement(node.getNodeName()); |
---|
| | |
---|
| | NamedNodeMap nodeMap = node.getAttributes(); |
---|
| | if (null != nodeMap) { |
---|
| | for (int j=0; j < nodeMap.getLength(); j++ ) { |
---|
| | root.setAttribute(nodeMap.item(j).getNodeName(), nodeMap.item(j).getNodeValue()); |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | NodeList nodes = node.getChildNodes(); |
---|
| | for (int i=0; i < nodes.getLength(); i++) { |
---|
| | Node node2 = nodes.item(i); |
---|
| | if (node2.getNodeType() == Node.ELEMENT_NODE) { |
---|
| | root.appendChild(getCopy(doc, node2)); |
---|
| | } |
---|
| | else if (node2.getNodeType() == Node.TEXT_NODE) { |
---|
| | String str = node2.getNodeValue(); |
---|
| | Text textContents = doc.createTextNode(str); |
---|
| | root.appendChild(textContents); |
---|
| | } |
---|
| | else if (node2.getNodeType() == Node.CDATA_SECTION_NODE) { |
---|
| | String str = node2.getNodeValue(); |
---|
| | CDATASection cdataSection = doc.createCDATASection(str); |
---|
| | root.appendChild(cdataSection); |
---|
| | } |
---|
| | } |
---|
| | return root; |
---|
| | } |
---|
| | |
---|
| | |
---|
| | /** |
---|
| | * ファイル名の順序に並び替えるためのソートクラス |
---|
| | * |
---|
| | * @author hayashi |
---|
| | */ |
---|
| | static class FileSort implements Comparator<File>{ |
---|
| | static class FileSort implements Comparator<File> { |
---|
| | @Override |
---|
| | public int compare(File src, File target){ |
---|
| | int diff = src.getName().compareTo(target.getName()); |
---|
| | return diff; |
---|
| |
---|
| | /** |
---|
| | * JPEGファイルフィルター |
---|
| | * @author yuu |
---|
| | */ |
---|
| | class JpegFileFilter implements FilenameFilter{ |
---|
| | class JpegFileFilter implements FilenameFilter { |
---|
| | public boolean accept(File dir, String name) { |
---|
| | if (name.toUpperCase().matches(".*\\.JPG$")) { |
---|
| | return true; |
---|
| | } |
---|
| | |