import java.util.TreeMap;
import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
@SuppressWarnings("serial")
-public class ElementMapTRKPT extends TreeMap<Date, Element> {
+public class ElementMapTRKPT extends TreeMap<Date, TagTrkpt> {
public static final long DIFF_MAE_TIME = 3000L; // before 3 secound
public ElementMapTRKPT() {
/**
* 拡張put value:ElementをputするとElement内のtimeを読み取ってkeyとしてthis.put(key,value)する。
+ * <trkpt lat="36.4260153752" lon="138.0117778201">
+ * <ele>614.90</ele>
+ * <time>2017-05-21T23:02:16Z</time>
+ * <hdop>0.5</hdop>
+ * </trkpt>
* @param value
* @return keyとして登録したtime:Date
* @throws ParseException
* @throws DOMException
*/
- public Date put(Element value) throws DOMException, ParseException {
- NodeList nodes3 = value.getChildNodes();
- for (int i3=0; i3 < nodes3.getLength(); i3++) {
- Node node4 = nodes3.item(i3);
- if (node4.getNodeName().equals("time")) {
- NodeList nodes4 = node4.getChildNodes(); // 子ノードを取得
- for (int i4=0; i4< nodes4.getLength(); i4++) {
- Node node5 = nodes4.item(i4);
- if (node5 != null) {
- if (node5.getNodeType() == Node.TEXT_NODE) {
- Date time = ImportPicture.dfuk.parse(node5.getNodeValue());
- this.put(time, value);
- return time;
- }
- }
- }
- }
- }
- return null;
+ public Date put(TagTrkpt tag) throws DOMException, ParseException {
+ this.put(tag.time, tag);
+ return tag.time;
}
/**
* @return エレメントTRKPT。指定時刻に対応するノードがないときはnullを返す。
* @throws ParseException
*/
- public Element getValue(Date jptime) throws ParseException {
- Element imaE = getTrkpt(jptime);
+ public TagTrkpt getValue(Date jptime) throws ParseException {
+ TagTrkpt imaE = getTrkpt(jptime);
if (imaE != null) {
- Element maeE = getMaeTrkpt((new TagTrkpt(imaE)).time);
+ TagTrkpt maeE = getMaeTrkpt(imaE.time);
if (maeE != null) {
Complementation comp = new Complementation(imaE, maeE);
if (Complementation.param_GpxOutputSpeed) {
comp.complementationSpeed();
}
-
- return (Element)(comp.imaTag.trkpt.cloneNode(true));
+ //return (TagTrkpt)(comp.imaTag.trkpt.cloneNode(true));
+ return (TagTrkpt)(comp.imaTag);
}
return imaE;
}
* @return <trkpt>エレメント。対象のエレメントが存在しなかった場合には null。
* @throws ParseException
*/
- private Element getTrkpt(Date jptime) throws ParseException {
+ private TagTrkpt getTrkpt(Date jptime) throws ParseException {
Date keyTime = null;
for (Date key : this.keySet()) {
int flag = jptime.compareTo(key);
*/
public static long OVER_TIME_LIMIT = 3000; // ミリ秒(msec)
- private Element getMaeTrkpt(Date time) throws ParseException {
+ private TagTrkpt getMaeTrkpt(Date time) throws ParseException {
Date maeTime = null;
for (Date key : this.keySet()) {
int flag = time.compareTo(key);
- if (flag < 0) {
+ if (flag > 0) {
maeTime = new Date(key.getTime());
}
else if (flag == 0) {
return this.get(maeTime);
}
else {
+ // time は key より古い
if (maeTime == null) {
return null;
}
}
lastTime = new Date(key.getTime());
}
- System.out.println(String.format("| <trkseg/> |%20s|%20s|", ImportPicture.dfuk.format(firstTime), ImportPicture.dfuk.format(lastTime)));
+ System.out.println(String.format("| <trkseg/> |%20s|%20s|", ImportPicture.toUTCString(firstTime), ImportPicture.toUTCString(lastTime)));
}
}