| | package osm.jp.gpx; |
---|
| | |
---|
| | import java.text.ParseException; |
---|
| | import java.util.Date; |
---|
| | import java.util.TreeMap; |
---|
| | |
---|
| | import org.w3c.dom.*; |
---|
| | |
---|
| | @SuppressWarnings("serial") |
---|
| | public class ElementMapTRKSEG extends TreeMap<Date, ElementMapTRKPT> { |
---|
| | |
---|
| | public ElementMapTRKSEG() { |
---|
| | super(new TimeComparator()); |
---|
| | } |
---|
| | |
---|
| | /** |
---|
| | * 拡張put value:Node<TRKSEG>をputするとNode<TRKSEG>内のNode<TRKSPT>を put(key,value)する。 |
---|
| | * @param nodeTRKSEG |
---|
| | * @return keyとして登録したtime:Date |
---|
| | * @throws ParseException |
---|
| | * @throws DOMException |
---|
| | */ |
---|
| | public Date put(Node nodeTRKSEG) throws DOMException, ParseException { |
---|
| | if (nodeTRKSEG.getNodeName().equals("trkseg")) { |
---|
| | NodeList nodes2 = nodeTRKSEG.getChildNodes(); |
---|
| | |
---|
| | Date trksegStartTime = new Date(); // 対象とする開始時刻(現在時刻) |
---|
| | ElementMapTRKPT mapTRKPT = new ElementMapTRKPT(); |
---|
| | for (int i2 = 0; i2 < nodes2.getLength(); i2++) { |
---|
| | Node nodeTRKPT = nodes2.item(i2); |
---|
| | if (nodeTRKPT.getNodeName().equals("trkpt")) { |
---|
| | if (ImportPicture.param_GpxNoFirstNode && (i2 == 0)) { |
---|
| | continue; |
---|
| | } |
---|
| | Date time = mapTRKPT.put((Element)nodeTRKPT); |
---|
| | if (trksegStartTime.compareTo(time) < 0) { |
---|
| | trksegStartTime = time; |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | this.put(trksegStartTime, mapTRKPT); |
---|
| | return trksegStartTime; |
---|
| | } |
---|
| | return null; |
---|
| | } |
---|
| | |
---|
| | /** |
---|
| | * 拡張put value:ElementMapTRKPTをputするとElementMapTRKPT内の最初のエントリのtimeを読み取ってkeyとしてthis.put(key,value)する。 |
---|
| | * @param value |
---|
| | * @return keyとして登録したtime:Date |
---|
| | * @throws ParseException |
---|
| | * @throws DOMException |
---|
| | */ |
---|
| | public Date put(ElementMapTRKPT value) { |
---|
| | for (Date key : value.keySet()) { |
---|
| | this.put(key, value); |
---|
| | return key; |
---|
| | } |
---|
| | return null; |
---|
| | } |
---|
| | |
---|
| | public void printinfo() { |
---|
| | for (java.util.Map.Entry<Date, ElementMapTRKPT> map : this.entrySet()) { |
---|
| | System.out.println("|--------------------------------|--------------------|--------------------|"); |
---|
| | ElementMapTRKPT mapTRKPT = map.getValue(); |
---|
| | mapTRKPT.printinfo(); |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |