3 import java.text.ParseException;
6 import org.w3c.dom.Document;
7 import org.w3c.dom.Element;
8 import org.w3c.dom.NamedNodeMap;
9 import org.w3c.dom.Node;
10 import org.w3c.dom.NodeList;
14 * <trkpt lat="35.32123832" lon="139.56965631">
15 * <ele>47.20000076293945</ele>
16 * <time>2012-06-15T03:00:29Z</time>
23 public class TagTrkpt {
24 public Element trkpt = null;
25 public Double lat = null;
26 public Double lon = null;
27 public String eleStr = null;
28 public Date time = null;
29 public String magvarStr = null;
30 public String speedStr = null;
32 public TagTrkpt(Element trkpt) {
33 this.trkpt = (Element) trkpt.cloneNode(true);
35 NamedNodeMap nodeMap = trkpt.getAttributes();
36 for (int j=0; j < nodeMap.getLength(); j++ ) {
37 switch (nodeMap.item(j).getNodeName()) {
39 String latStr = nodeMap.item(j).getNodeValue();
40 this.lat = new Double(latStr);
43 String lonStr = nodeMap.item(j).getNodeValue();
44 this.lon = new Double(lonStr);
49 NodeList nodes1 = trkpt.getChildNodes();
50 for (int i1=0; i1 < nodes1.getLength(); i1++) {
51 Node node1 = nodes1.item(i1);
52 NodeList nodes2 = node1.getChildNodes();
53 switch (node1.getNodeName()) {
55 for (int i2=0; i2 < nodes2.getLength(); i2++) {
56 Node node2 = nodes2.item(i2);
58 if (node2.getNodeType() == Node.TEXT_NODE) {
59 this.eleStr = node2.getNodeValue();
65 for (int i2=0; i2 < nodes2.getLength(); i2++) {
66 Node node2 = nodes2.item(i2);
68 if (node2.getNodeType() == Node.TEXT_NODE) {
70 this.time = ImportPicture.toUTCDate(node2.getNodeValue());
71 } catch (ParseException e) {
79 for (int i2=0; i2 < nodes2.getLength(); i2++) {
80 Node node2 = nodes2.item(i2);
82 if (node2.getNodeType() == Node.TEXT_NODE) {
83 this.magvarStr = node2.getNodeValue();
89 for (int i2=0; i2 < nodes2.getLength(); i2++) {
90 Node node2 = nodes2.item(i2);
92 if (node2.getNodeType() == Node.TEXT_NODE) {
93 this.speedStr = node2.getNodeValue();
102 public void removeElement(String eleName) {
104 for (child = trkpt.getFirstChild(); child != null; child = child.getNextSibling()) {
105 NodeList nodeList = child.getChildNodes();
106 for(int i = 0; i < nodeList.getLength(); i++) {
107 Node grandChild = child.getChildNodes().item(i);
108 if (grandChild.getNodeName().equals(eleName)) {
109 child.removeChild(grandChild);
115 public void appendElement(String eleName, String valueStr) {
116 Document doc = trkpt.getOwnerDocument();
117 Element newElement = doc.createElement(eleName);
118 newElement.setTextContent(valueStr);
119 trkpt.appendChild(newElement);