it = rte.getRoutePoints().iterator();
+ while (it.hasNext()) {
+ this.addWaypointToNode(GPXConstants.NODE_RTEPT, it.next(), rteNode, doc);
+ }
+ }
+ gpxNode.appendChild(rteNode);
+ }
+
+ private void addWaypointToNode(String tag, Waypoint wpt, Node n, Document doc) {
+ Node wptNode = doc.createElement(tag);
+ NamedNodeMap attrs = wptNode.getAttributes();
+ if (wpt.getLatitude() != 0) {
+ Node latNode = doc.createAttribute(GPXConstants.ATTR_LAT);
+ latNode.setNodeValue(String.valueOf(wpt.getLatitude()));
+ attrs.setNamedItem(latNode);
+ }
+ if (wpt.getLongitude() != 0) {
+ Node longNode = doc.createAttribute(GPXConstants.ATTR_LON);
+ longNode.setNodeValue(String.valueOf(wpt.getLongitude()));
+ attrs.setNamedItem(longNode);
+ }
+ if (wpt.getElevation() != 0) {
+ Node node = doc.createElement(GPXConstants.NODE_ELE);
+ node.appendChild(doc.createTextNode(String.valueOf(wpt.getElevation())));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getTime() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_TIME);
+ node.appendChild(doc.createTextNode(xmlDateFormat.format(wpt.getTime())));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getMagneticVariation() != 0) {
+ Node node = doc.createElement(GPXConstants.NODE_MAGVAR);
+ node.appendChild(doc.createTextNode(String.valueOf(wpt.getMagneticVariation())));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getGeoIdHeight() != 0) {
+ Node node = doc.createElement(GPXConstants.NODE_GEOIDHEIGHT);
+ node.appendChild(doc.createTextNode(String.valueOf(wpt.getGeoIdHeight())));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getName() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_NAME);
+ node.appendChild(doc.createTextNode(wpt.getName()));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getComment() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_CMT);
+ node.appendChild(doc.createTextNode(wpt.getComment()));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getDescription() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_DESC);
+ node.appendChild(doc.createTextNode(wpt.getDescription()));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getSrc() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_SRC);
+ node.appendChild(doc.createTextNode(wpt.getSrc()));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getLinks() != null) {
+ for (Link l : wpt.getLinks()) {
+ this.addLinkToNode(l, wptNode, doc);
+ }
+ }
+ if (wpt.getSym() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_SYM);
+ node.appendChild(doc.createTextNode(wpt.getSym()));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getType() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_TYPE);
+ node.appendChild(doc.createTextNode(wpt.getType()));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getFix() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_FIX);
+ node.appendChild(doc.createTextNode(wpt.getFix().toString()));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getSat() != 0) {
+ Node node = doc.createElement(GPXConstants.NODE_SAT);
+ node.appendChild(doc.createTextNode(String.valueOf(wpt.getSat())));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getHdop() != 0) {
+ Node node = doc.createElement(GPXConstants.NODE_HDOP);
+ node.appendChild(doc.createTextNode(String.valueOf(wpt.getHdop())));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getVdop() != 0) {
+ Node node = doc.createElement(GPXConstants.NODE_VDOP);
+ node.appendChild(doc.createTextNode(String.valueOf(wpt.getVdop())));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getPdop() != 0) {
+ Node node = doc.createElement(GPXConstants.NODE_PDOP);
+ node.appendChild(doc.createTextNode(String.valueOf(wpt.getPdop())));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getAgeOfGPSData() != 0) {
+ Node node = doc.createElement(GPXConstants.NODE_AGEOFGPSDATA);
+ node.appendChild(doc.createTextNode(String.valueOf(wpt.getAgeOfGPSData())));
+ wptNode.appendChild(node);
+ }
+ if (wpt.getdGpsStationId() != 0) {
+ Node node = doc.createElement(GPXConstants.NODE_DGPSID);
+ node.appendChild(doc.createTextNode(String.valueOf(wpt.getdGpsStationId())));
+ wptNode.appendChild(node);
+ }
+ this.addExtensionToNode(wpt, wptNode, doc);
+ n.appendChild(wptNode);
+ }
+
+ private void addMetadataToNode(Metadata m, Node n, Document doc) {
+ Node matadataNode = doc.createElement(GPXConstants.NODE_METADATA);
+
+ if (m.getName() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_NAME);
+ node.appendChild(doc.createTextNode(m.getName()));
+ matadataNode.appendChild(node);
+ }
+
+ if (m.getDesc() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_DESC);
+ node.appendChild(doc.createTextNode(m.getDesc()));
+ matadataNode.appendChild(node);
+ }
+
+ if (m.getAuthor() != null) {
+ this.addAuthorToNode(m.getAuthor(), matadataNode, doc);
+ }
+
+ if (m.getCopyright() != null) {
+ this.addCopyrightToNode(m.getCopyright(), matadataNode, doc);
+ }
+
+ if (m.getLinks() != null) {
+ for (Link l : m.getLinks()) {
+ this.addLinkToNode(l, matadataNode, doc);
+ }
+ }
+
+ if (m.getTime() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_TIME);
+ node.appendChild(doc.createTextNode(xmlDateFormat.format(m.getTime())));
+ matadataNode.appendChild(node);
+ }
+
+ if (m.getKeywords() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_KEYWORDS);
+ node.appendChild(doc.createTextNode(m.getKeywords()));
+ matadataNode.appendChild(node);
+ }
+
+ if (m.getBounds() != null) {
+ this.addBoundsToNode(m.getBounds(), matadataNode, doc);
+ }
+
+ this.addExtensionToNode(m, matadataNode, doc);
+
+ n.appendChild(matadataNode);
+ }
+
+ private void addBoundsToNode(Bounds bounds, Node n, Document doc) {
+ Node bonundsNode = doc.createElement(GPXConstants.NODE_BOUNDS);
+ NamedNodeMap attributes = bonundsNode.getAttributes();
+
+ Node node = doc.createAttribute(GPXConstants.ATTR_MINLAT);
+ node.setNodeValue(String.valueOf(bounds.getMinLat()));
+ attributes.setNamedItem(node);
+
+ node = doc.createAttribute(GPXConstants.ATTR_MINLON);
+ node.setNodeValue(String.valueOf(bounds.getMinLon()));
+ attributes.setNamedItem(node);
+
+ node = doc.createAttribute(GPXConstants.ATTR_MAXLAT);
+ node.setNodeValue(String.valueOf(bounds.getMaxLat()));
+ attributes.setNamedItem(node);
+
+ node = doc.createAttribute(GPXConstants.ATTR_MAXLON);
+ node.setNodeValue(String.valueOf(bounds.getMaxLon()));
+ attributes.setNamedItem(node);
+ }
+
+ private void addCopyrightToNode(Copyright copyright, Node n, Document doc) {
+ Node copyrightNode = doc.createElement(GPXConstants.NODE_COPYRIGHT);
+ NamedNodeMap attributes = copyrightNode.getAttributes();
+ if (copyright.getAuthor() != null) {
+ Node node = doc.createAttribute(GPXConstants.ATTR_AUTHOR);
+ node.setNodeValue(copyright.getAuthor());
+ attributes.setNamedItem(node);
+ }
+
+ if (copyright.getYear() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_YEAR);
+ node.appendChild(doc.createTextNode(copyright.getYear()));
+ n.appendChild(node);
+ }
+ if (copyright.getLicense() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_LICENSE);
+ node.appendChild(doc.createTextNode(copyright.getLicense()));
+ n.appendChild(node);
+ }
+
+ n.appendChild(copyrightNode);
+
+ }
+
+ private void addAuthorToNode(Person author, Node n, Document doc) {
+ Node authorNode = doc.createElement(GPXConstants.NODE_AUTHOR);
+ if (author.getName() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_NAME);
+ node.appendChild(doc.createTextNode(author.getName()));
+ n.appendChild(node);
+ }
+ if (author.getEmail() != null) {
+ this.addEmailToNode(author.getEmail(), authorNode, doc);
+ }
+
+ if (author.getLink() != null) {
+ this.addLinkToNode(author.getLink(), authorNode, doc);
+ }
+ n.appendChild(authorNode);
+ }
+
+ private void addLinkToNode(Link link, Node n, Document doc) {
+ Node linkNode = doc.createElement(GPXConstants.NODE_LINK);
+ NamedNodeMap attributes = linkNode.getAttributes();
+ if (link.getHref() != null) {
+ Node node = doc.createAttribute(GPXConstants.ATTR_HREF);
+ node.setNodeValue(link.getHref());
+ attributes.setNamedItem(node);
+ }
+
+ if (link.getText() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_TEXT);
+ node.appendChild(doc.createTextNode(link.getText()));
+ n.appendChild(node);
+ }
+ if (link.getType() != null) {
+ Node node = doc.createElement(GPXConstants.NODE_TYPE);
+ node.appendChild(doc.createTextNode(link.getType()));
+ n.appendChild(node);
+ }
+
+ n.appendChild(linkNode);
+ }
+
+ private void addEmailToNode(Email email, Node n, Document doc) {
+ Node emailNode = doc.createElement(GPXConstants.NODE_EMAIL);
+ NamedNodeMap attributes = emailNode.getAttributes();
+ if (email.getId() != null) {
+ Node node = doc.createAttribute(GPXConstants.ATTR_ID);
+ node.setNodeValue(email.getId());
+ attributes.setNamedItem(node);
+ }
+ if (email.getDomain() != null) {
+ Node node = doc.createAttribute(GPXConstants.ATTR_DOMAIN);
+ node.setNodeValue(email.getDomain());
+ attributes.setNamedItem(node);
+ }
+
+ }
+
+ private void addExtensionToNode(Extension e, Node n, Document doc) {
+ if (e.getExtensionsParsed() > 0) {
+ Node node = doc.createElement(GPXConstants.NODE_EXTENSIONS);
+ for (IExtensionParser parser : this.extensionParsers) {
+ parser.writeExtensions(node, doc);
+ }
+ n.appendChild(node);
+ }
+ }
+}
diff --git a/src/com/hs/gpxparser/extension/DummyExtensionParser.java b/src/com/hs/gpxparser/extension/DummyExtensionParser.java
new file mode 100644
index 0000000..3b3f582
--- /dev/null
+++ b/src/com/hs/gpxparser/extension/DummyExtensionParser.java
@@ -0,0 +1,23 @@
+package com.hs.gpxparser.extension;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+public class DummyExtensionParser implements IExtensionParser {
+
+ @Override
+ public String getId() {
+ return "Basic Extension Parser";
+ }
+
+ @Override
+ public Object parseExtensions(Node node) {
+ // TODO get your object from the node
+ return null;
+ }
+
+ @Override
+ public void writeExtensions(Node node, Document doc) {
+ // TODO write your object to node
+ }
+}
diff --git a/src/com/hs/gpxparser/extension/IExtensionParser.java b/src/com/hs/gpxparser/extension/IExtensionParser.java
new file mode 100644
index 0000000..3282a6c
--- /dev/null
+++ b/src/com/hs/gpxparser/extension/IExtensionParser.java
@@ -0,0 +1,14 @@
+package com.hs.gpxparser.extension;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+public interface IExtensionParser {
+
+ public String getId();
+
+ public Object parseExtensions(Node node);
+
+ public void writeExtensions(Node node, Document doc);
+
+}
diff --git a/src/com/hs/gpxparser/modal/Bounds.java b/src/com/hs/gpxparser/modal/Bounds.java
new file mode 100644
index 0000000..ff83933
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/Bounds.java
@@ -0,0 +1,50 @@
+package com.hs.gpxparser.modal;
+
+/**
+ * Created by Himanshu on 7/5/2015.
+ */
+public class Bounds {
+ private double minLat;
+ private double minLon;
+ private double maxLat;
+ private double maxLon;
+
+ public Bounds(double minlat, double maxlat, double minlon, double maxlon) {
+ this.minLat = minlat;
+ this.maxLat = maxlat;
+ this.minLon = minlon;
+ this.maxLon = maxlon;
+ }
+
+ public double getMinLat() {
+ return minLat;
+ }
+
+ public void setMinLat(double minLat) {
+ this.minLat = minLat;
+ }
+
+ public double getMinLon() {
+ return minLon;
+ }
+
+ public void setMinLon(double minLon) {
+ this.minLon = minLon;
+ }
+
+ public double getMaxLat() {
+ return maxLat;
+ }
+
+ public void setMaxLat(double maxLat) {
+ this.maxLat = maxLat;
+ }
+
+ public double getMaxLon() {
+ return maxLon;
+ }
+
+ public void setMaxLon(double maxLon) {
+ this.maxLon = maxLon;
+ }
+}
diff --git a/src/com/hs/gpxparser/modal/Copyright.java b/src/com/hs/gpxparser/modal/Copyright.java
new file mode 100644
index 0000000..e47988e
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/Copyright.java
@@ -0,0 +1,38 @@
+package com.hs.gpxparser.modal;
+
+/**
+ * Created by Himanshu on 7/5/2015.
+ */
+public class Copyright {
+ private String year;
+ private String license;
+ private String author;
+
+ public Copyright(String author) {
+ this.author = author;
+ }
+
+ public String getYear() {
+ return year;
+ }
+
+ public void setYear(String year) {
+ this.year = year;
+ }
+
+ public String getLicense() {
+ return license;
+ }
+
+ public void setLicense(String license) {
+ this.license = license;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+}
diff --git a/src/com/hs/gpxparser/modal/Email.java b/src/com/hs/gpxparser/modal/Email.java
new file mode 100644
index 0000000..936e44a
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/Email.java
@@ -0,0 +1,36 @@
+package com.hs.gpxparser.modal;
+
+/**
+ * Created by Himanshu on 7/5/2015.
+ */
+public class Email {
+ private String id;
+ private String domain;
+
+ public Email(String id, String domain) {
+ this.id = id;
+ this.domain = domain;
+ }
+
+ public Email(String emailId) {
+ String[] split = emailId.split("@");
+ this.id = split[0];
+ this.domain = split[1];
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getDomain() {
+ return domain;
+ }
+
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
+}
diff --git a/src/com/hs/gpxparser/modal/Extension.java b/src/com/hs/gpxparser/modal/Extension.java
new file mode 100644
index 0000000..e23550b
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/Extension.java
@@ -0,0 +1,69 @@
+
+package com.hs.gpxparser.modal;
+
+import java.util.HashMap;
+
+/**
+ * This class holds generic extension information from any node that can have extensions defined.
+ *
+ * Any custom extension parser used when parsing a gpx file will return a custom object
+ * instance that will be kept in properties defined in this class.
+ *
+ * Multiple extension parsers can be used when parsing. Every extension parser defines
+ * an unique id that will be used as a HashMap key for the parsed object values.
+ */
+public class Extension {
+ protected HashMap extensionData;
+
+ public HashMap getExtensionData() {
+ return extensionData;
+ }
+
+ /**
+ * Setter for extension HashMap.
+ * @param extensionData - A HashMap with extensions parser ids as keys and parsed objects as values.
+ */
+ public void setExtensionData(HashMap extensionData) {
+ this.extensionData = extensionData;
+ }
+
+
+ /**
+ * Adds a new parsed extension object into the extension data with the key set by parserId.
+ *
+ * @param parserId a unique key representing the id of he extension parser used.
+ * @param data an object holding the parsed information. This can be any object type and it is
+ * the extension parser's job to set it properly.
+ */
+ public void addExtensionData(String parserId, Object data) {
+ if(extensionData == null) {
+ extensionData = new HashMap();
+ }
+ extensionData.put(parserId, data);
+ }
+
+ /**
+ * Returns the extension data parsed by the extension parser with id parserId
+ * @param parserId a String representing the id of an extension parser
+ * @return the extension data parsed by the extension parser with id parserId
+ */
+ public Object getExtensionData(String parserId) {
+ if(extensionData != null) {
+ return extensionData.get(parserId);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns the number of extension data objects that are currently set.
+ * @return the number of extension data objects that are currently set.
+ */
+ public int getExtensionsParsed() {
+ if(extensionData != null) {
+ return extensionData.size();
+ } else {
+ return 0;
+ }
+ }
+}
diff --git a/src/com/hs/gpxparser/modal/GPX.java b/src/com/hs/gpxparser/modal/GPX.java
new file mode 100644
index 0000000..0e6569c
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/GPX.java
@@ -0,0 +1,175 @@
+package com.hs.gpxparser.modal;
+
+import java.util.HashSet;
+
+/**
+ * This class holds gpx information from a <gpx> node.
+ *
+ * GPX specification for this tag:
+ *
+ *
+ * <gpx version="1.1" creator=""xsd:string [1]">
+ * <metadata> xsd:string </metadata> [0..1]
+ * <wpt> xsd:string </wpt> [0..1]
+ * <rte> xsd:string </rte> [0..1]
+ * <trk> xsd:string </trk> [0..1]
+ * <extensions> extensionsType </extensions> [0..1]
+ * </gpx>
+ *
+ */
+public class GPX extends Extension {
+
+ // Attributes
+ private String creator;
+ private String version = "1.1";
+
+ // Nodes
+ private Metadata metadata;
+ private HashSet routes;
+ private HashSet tracks;
+ private HashSet waypoints;
+
+ public GPX() {
+ this.waypoints = new HashSet();
+ this.tracks = new HashSet();
+ this.routes = new HashSet();
+ }
+
+ /**
+ * Adds a new Route to a gpx object
+ *
+ * @param route
+ * a {@link Route}
+ */
+ public void addRoute(Route route) {
+ if (this.routes == null) {
+ this.routes = new HashSet();
+ }
+ this.routes.add(route);
+ }
+
+ /**
+ * Adds a new track to a gpx object
+ *
+ * @param track
+ * a {@link Track}
+ */
+ public void addTrack(Track track) {
+ if (this.tracks == null) {
+ this.tracks = new HashSet();
+ }
+ this.tracks.add(track);
+ }
+
+ /**
+ * Adds a new waypoint to a gpx object
+ *
+ * @param waypoint
+ * a {@link Waypoint}
+ */
+ public void addWaypoint(Waypoint waypoint) {
+ if (this.waypoints == null) {
+ this.waypoints = new HashSet();
+ }
+ this.waypoints.add(waypoint);
+
+ }
+
+ /**
+ * Returns the creator of this gpx object
+ *
+ * @return A String representing the creator of a gpx object
+ */
+ public String getCreator() {
+ return this.creator;
+ }
+
+ /**
+ * Getter for the list of routes from a gpx object
+ *
+ * @return a HashSet of {@link Route}
+ */
+ public HashSet getRoutes() {
+ return this.routes;
+ }
+
+ /**
+ * Getter for the list of Tracks from a gpx objecty
+ *
+ * @return a HashSet of {@link Track}
+ */
+ public HashSet getTracks() {
+ return this.tracks;
+ }
+
+ /**
+ * Returns the version of a gpx object
+ *
+ * @return A String representing the version of this gpx object
+ */
+ public String getVersion() {
+ return this.version;
+ }
+
+ /**
+ * Getter for the list of waypoints from a gpx objecty
+ *
+ * @return a HashSet of {@link Waypoint}
+ */
+ public HashSet getWaypoints() {
+ return this.waypoints;
+ }
+
+ /**
+ * Setter for gpx creator property. This maps to creator attribute
+ * value.
+ *
+ * @param creator
+ * A String representing the creator of a gpx file.
+ */
+ public void setCreator(String creator) {
+ this.creator = creator;
+ }
+
+ /**
+ * Setter for the list of routes from a gpx object
+ *
+ * @param routes
+ * a HashSet of {@link Route}
+ */
+ public void setRoutes(HashSet routes) {
+ this.routes = routes;
+ }
+
+ /**
+ * Setter for the list of tracks from a gpx object
+ *
+ * @param tracks
+ * a HashSet of {@link Track}
+ */
+ public void setTracks(HashSet tracks) {
+ this.tracks = tracks;
+ }
+
+ /**
+ * Setter for the list of waypoints from a gpx object
+ *
+ * @param waypoints
+ * a HashSet of {@link Waypoint}
+ */
+ public void setWaypoints(HashSet waypoints) {
+ this.waypoints = waypoints;
+ }
+
+ public Metadata getMetadata() {
+ return metadata;
+ }
+
+ public void setMetadata(Metadata metadata) {
+ this.metadata = metadata;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+}
diff --git a/src/com/hs/gpxparser/modal/Link.java b/src/com/hs/gpxparser/modal/Link.java
new file mode 100644
index 0000000..d866627
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/Link.java
@@ -0,0 +1,40 @@
+package com.hs.gpxparser.modal;
+
+/**
+ * Created by Himanshu on 7/5/2015.
+ */
+public class Link {
+
+ private String href;
+
+ private String text;
+ private String type;
+
+ public Link(String href) {
+ this.href = href;
+ }
+
+ public String getHref() {
+ return href;
+ }
+
+ public void setHref(String href) {
+ this.href = href;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+}
diff --git a/src/com/hs/gpxparser/modal/Metadata.java b/src/com/hs/gpxparser/modal/Metadata.java
new file mode 100644
index 0000000..596f9ff
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/Metadata.java
@@ -0,0 +1,100 @@
+package com.hs.gpxparser.modal;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashSet;
+
+/**
+ * Created by Himanshu on 7/5/2015.
+ */
+public class Metadata extends Extension {
+ private String name;
+ private String desc;
+ private Person author;
+ private Copyright copyright;
+ private HashSet links;
+ private Date time;
+ private String keywords;
+ private Bounds bounds;
+
+ public Metadata() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+
+ public String getKeywords() {
+ return keywords;
+ }
+
+ public void setKeywords(String keywords) {
+ this.keywords = keywords;
+ }
+
+ public Date getTime() {
+ return time;
+ }
+
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+ public void setTime(long timeMillis) throws ParseException {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+ String date = sdf.format(new Date(timeMillis));
+ this.time = sdf.parse(date);
+ }
+
+ public Person getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(Person author) {
+ this.author = author;
+ }
+
+ public Copyright getCopyright() {
+ return copyright;
+ }
+
+ public void setCopyright(Copyright copyright) {
+ this.copyright = copyright;
+ }
+
+ public HashSet getLinks() {
+ return links;
+ }
+
+ public void setLinks(HashSet links) {
+ this.links = links;
+ }
+
+ public void addLink(Link link) {
+ if (links == null) {
+ links = new HashSet<>();
+ }
+ links.add(link);
+ }
+
+ public Bounds getBounds() {
+ return bounds;
+ }
+
+ public void setBounds(Bounds bounds) {
+ this.bounds = bounds;
+ }
+}
diff --git a/src/com/hs/gpxparser/modal/Person.java b/src/com/hs/gpxparser/modal/Person.java
new file mode 100644
index 0000000..e5835f4
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/Person.java
@@ -0,0 +1,34 @@
+package com.hs.gpxparser.modal;
+
+/**
+ * Created by Himanshu on 7/5/2015.
+ */
+public class Person {
+ private String name;
+ private Email email;
+ private Link link;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Email getEmail() {
+ return email;
+ }
+
+ public void setEmail(Email email) {
+ this.email = email;
+ }
+
+ public Link getLink() {
+ return link;
+ }
+
+ public void setLink(Link link) {
+ this.link = link;
+ }
+}
diff --git a/src/com/hs/gpxparser/modal/Point.java b/src/com/hs/gpxparser/modal/Point.java
new file mode 100644
index 0000000..27b4893
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/Point.java
@@ -0,0 +1,51 @@
+
+package com.hs.gpxparser.modal;
+
+import java.util.Date;
+
+public class Point {
+
+ private double latitude;
+ private double longitude;
+
+ private double elevation;
+ private Date time;
+
+ public Point(double latitude, double longitude) {
+ this.latitude = latitude;
+ this.longitude = longitude;
+ }
+
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+
+ public double getElevation() {
+ return elevation;
+ }
+
+ public void setElevation(double elevation) {
+ this.elevation = elevation;
+ }
+
+ public Date getTime() {
+ return time;
+ }
+
+ public void setTime(Date time) {
+ this.time = time;
+ }
+}
diff --git a/src/com/hs/gpxparser/modal/PointSegment.java b/src/com/hs/gpxparser/modal/PointSegment.java
new file mode 100644
index 0000000..486ca36
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/PointSegment.java
@@ -0,0 +1,28 @@
+package com.hs.gpxparser.modal;
+
+import java.util.ArrayList;
+
+/**
+ * Created by Himanshu on 7/5/2015.
+ */
+public class PointSegment {
+ private ArrayList points;
+
+ public PointSegment() {
+ }
+
+ public ArrayList getPoints() {
+ return points;
+ }
+
+ public void setPoints(ArrayList points) {
+ this.points = points;
+ }
+
+ public void addPoint(Point point) {
+ if (points == null) {
+ points = new ArrayList<>();
+ }
+ points.add(point);
+ }
+}
diff --git a/src/com/hs/gpxparser/modal/Route.java b/src/com/hs/gpxparser/modal/Route.java
new file mode 100644
index 0000000..cf5952f
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/Route.java
@@ -0,0 +1,186 @@
+
+package com.hs.gpxparser.modal;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+
+public class Route extends Extension {
+ private String name;
+ private String comment;
+ private String description;
+ private String src;
+ private HashSet links;
+ private int number;
+
+ private String type;
+ private ArrayList routePoints;
+
+ /**
+ * Returns the name of this route.
+ *
+ * @return A String representing the name of this route.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Setter for route name property. This maps to <name> tag value.
+ *
+ * @param name A String representing the name of this route.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the comment of this route.
+ *
+ * @return A String representing the comment of this route.
+ */
+ public String getComment() {
+ return comment;
+ }
+
+ /**
+ * Setter for route comment property. This maps to <comment> tag value.
+ *
+ * @param comment A String representing the comment of this route.
+ */
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ /**
+ * Returns the description of this route.
+ *
+ * @return A String representing the description of this route.
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Setter for route description property. This maps to <description> tag value.
+ *
+ * @param description A String representing the description of this route.
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Returns the src of this route.
+ *
+ * @return A String representing the src of this route.
+ */
+ public String getSrc() {
+ return src;
+ }
+
+ /**
+ * Setter for src type property. This maps to <src> tag value.
+ *
+ * @param src A String representing the src of this route.
+ */
+ public void setSrc(String src) {
+ this.src = src;
+ }
+
+ /**
+ * Returns the number of this route.
+ *
+ * @return A String representing the number of this route.
+ */
+ public Integer getNumber() {
+ return number;
+ }
+
+ /**
+ * Setter for route number property. This maps to <number> tag value.
+ *
+ * @param number An Integer representing the number of this route.
+ */
+ public void setNumber(Integer number) {
+ this.number = number;
+ }
+
+ /**
+ * Returns the type of this route.
+ *
+ * @return A String representing the type of this route.
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Setter for route type property. This maps to <type> tag value.
+ *
+ * @param type A String representing the type of this route.
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Getter for the list of waypoints of this route.
+ *
+ * @return an ArrayList of {@link Waypoint} representing the points of the route.
+ */
+ public ArrayList getRoutePoints() {
+ return routePoints;
+ }
+
+ /**
+ * Setter for the list of waypoints of this route.
+ *
+ * @param routePoints an ArrayList of {@link Waypoint} representing the points of the route.
+ */
+ public void setRoutePoints(ArrayList routePoints) {
+ this.routePoints = routePoints;
+ }
+
+ /**
+ * Adds this new waypoint to this route.
+ *
+ * @param waypoint a {@link Waypoint}.
+ */
+ public void addRoutePoint(Waypoint waypoint) {
+ if (routePoints == null) {
+ routePoints = new ArrayList();
+ }
+ routePoints.add(waypoint);
+ }
+
+ public HashSet getLinks() {
+ return links;
+ }
+
+ public void setLinks(HashSet links) {
+ this.links = links;
+ }
+
+ public void addLink(Link link) {
+ if (links == null) {
+ links = new HashSet<>();
+ }
+ links.add(link);
+ }
+
+ /**
+ * Returns a String representation of this track.
+ */
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("rte[");
+ sb.append("name:" + name + " ");
+ int points = 0;
+ if (routePoints != null) {
+ points = routePoints.size();
+ }
+ sb.append("rtepts:" + points + " ");
+ sb.append("]");
+ return sb.toString();
+ }
+}
diff --git a/src/com/hs/gpxparser/modal/Track.java b/src/com/hs/gpxparser/modal/Track.java
new file mode 100644
index 0000000..5124c1c
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/Track.java
@@ -0,0 +1,165 @@
+
+package com.hs.gpxparser.modal;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+
+public class Track extends Extension {
+ private String name;
+ private String comment;
+ private String description;
+ private String src;
+ private HashSet links;
+ private int number;
+ private String type;
+ private ArrayList trackSegments;
+
+ /**
+ * Returns the name of this track.
+ *
+ * @return A String representing the name of this track.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Setter for track name property. This maps to <name> tag value.
+ *
+ * @param name A String representing the name of this track.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the comment of this track.
+ *
+ * @return A String representing the comment of this track.
+ */
+ public String getComment() {
+ return comment;
+ }
+
+ /**
+ * Setter for track comment property. This maps to <comment> tag value.
+ *
+ * @param comment A String representing the comment of this track.
+ */
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ /**
+ * Returns the description of this track.
+ *
+ * @return A String representing the description of this track.
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Setter for track description property. This maps to <description> tag value.
+ *
+ * @param description A String representing the description of this track.
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Returns the src of this track.
+ *
+ * @return A String representing the src of this track.
+ */
+ public String getSrc() {
+ return src;
+ }
+
+ /**
+ * Setter for src type property. This maps to <src> tag value.
+ *
+ * @param src A String representing the src of this track.
+ */
+ public void setSrc(String src) {
+ this.src = src;
+ }
+
+ /**
+ * Returns the number of this track.
+ *
+ * @return A String representing the number of this track.
+ */
+ public Integer getNumber() {
+ return number;
+ }
+
+ /**
+ * Setter for track number property. This maps to <number> tag value.
+ *
+ * @param number An Integer representing the number of this track.
+ */
+ public void setNumber(Integer number) {
+ this.number = number;
+ }
+
+ /**
+ * Returns the type of this track.
+ *
+ * @return A String representing the type of this track.
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Setter for track type property. This maps to <type> tag value.
+ *
+ * @param type A String representing the type of this track.
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public HashSet getLinks() {
+ return links;
+ }
+
+ public void setLinks(HashSet links) {
+ this.links = links;
+ }
+
+ public void addLink(Link link) {
+ if (links == null) {
+ links = new HashSet<>();
+ }
+ links.add(link);
+ }
+
+ /**
+ * Returns a String representation of this track.
+ */
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ sb.append("trk[");
+ sb.append("name:" + name + " ");
+ sb.append("]");
+ return sb.toString();
+ }
+
+ public ArrayList getTrackSegments() {
+ return trackSegments;
+ }
+
+ public void setTrackSegments(ArrayList trackSegments) {
+ this.trackSegments = trackSegments;
+ }
+
+ public void addTrackSegment(TrackSegment trackSegment) {
+ if (trackSegments == null) {
+ trackSegments = new ArrayList<>();
+ }
+ trackSegments.add(trackSegment);
+ }
+}
diff --git a/src/com/hs/gpxparser/modal/TrackSegment.java b/src/com/hs/gpxparser/modal/TrackSegment.java
new file mode 100644
index 0000000..3e6ecde
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/TrackSegment.java
@@ -0,0 +1,26 @@
+package com.hs.gpxparser.modal;
+
+import java.util.ArrayList;
+
+/**
+ * Created by Himanshu on 7/5/2015.
+ */
+public class TrackSegment extends Extension {
+ private ArrayList waypoints;
+
+ public ArrayList getWaypoints() {
+ return waypoints;
+ }
+
+ public void setWaypoints(ArrayList waypoints) {
+ this.waypoints = waypoints;
+ }
+
+ public void addWaypoint(Waypoint wp) {
+ if (waypoints == null) {
+ waypoints = new ArrayList<>();
+ }
+ waypoints.add(wp);
+ }
+
+}
diff --git a/src/com/hs/gpxparser/modal/Waypoint.java b/src/com/hs/gpxparser/modal/Waypoint.java
new file mode 100644
index 0000000..52414e1
--- /dev/null
+++ b/src/com/hs/gpxparser/modal/Waypoint.java
@@ -0,0 +1,469 @@
+package com.hs.gpxparser.modal;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import com.hs.gpxparser.type.Fix;
+
+public class Waypoint extends Extension {
+
+ private double latitude;
+ private double longitude;
+
+ private double elevation;
+ private Date time;
+ private double magneticVariation;
+ private double geoIdHeight;
+ private String name;
+ private String comment;
+ private String description;
+ private String src;
+ private HashSet links;
+ /**
+ * Symbol
+ */
+ private String sym;
+ private String type;
+ private Fix fix;
+ private int sat;
+ /**
+ * Horizontal dilution of precision.
+ */
+ private double hdop;
+ /**
+ * Vertical dilution of precision.
+ */
+ private double vdop;
+ /**
+ * Position dilution of precision.
+ */
+ private double pdop;
+
+ private double ageOfGpsData;
+ private int dGpsStationId;
+
+ public Waypoint(double latitude, double longitude) {
+ this.latitude = latitude;
+ this.longitude = longitude;
+ }
+
+ /**
+ * Returns the ageOfGPSData of this waypoint.
+ *
+ * @return a Double representing the ageOfGPSData of this waypoint.
+ */
+ public double getAgeOfGPSData() {
+ return this.ageOfGpsData;
+ }
+
+ /**
+ * Returns the comment of this waypoint.
+ *
+ * @return a String representing the comment of this waypoint.
+ */
+ public String getComment() {
+ return this.comment;
+ }
+
+ /**
+ * Returns the description of this waypoint.
+ *
+ * @return a String representing the description of this waypoint.
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * Returns the dGpsStationId of this waypoint.
+ *
+ * @return an Integer representing the dGpsStationId of this waypoint.
+ */
+ public int getdGpsStationId() {
+ return this.dGpsStationId;
+ }
+
+ /**
+ * Returns the elevation of this waypoint.
+ *
+ * @return A Double representing the elevation of this waypoint.
+ */
+ public double getElevation() {
+ return this.elevation;
+ }
+
+ /**
+ * Returns the fix of this waypoint.
+ *
+ * @return A {@link Fix} representing the fix of this waypoint.
+ */
+ public Fix getFix() {
+ return this.fix;
+ }
+
+ /**
+ * Returns the geoid height of this waypoint.
+ *
+ * @return A String representing the geoid height of this waypoint.
+ */
+ public double getGeoIdHeight() {
+ return this.geoIdHeight;
+ }
+
+ /**
+ * Returns the hdop of this waypoint.
+ *
+ * @return a Double representing the hdop of this waypoint.
+ */
+ public double getHdop() {
+ return this.hdop;
+ }
+
+ /**
+ * Returns the latitude of this waypoint.
+ *
+ * @return a Double value representing the latitude of this waypoint.
+ */
+ public double getLatitude() {
+ return this.latitude;
+ }
+
+ /**
+ * Returns the longitude of this waypoint.
+ *
+ * @return a Double value representing the longitude of this waypoint.
+ */
+ public double getLongitude() {
+ return this.longitude;
+ }
+
+ /**
+ * Returns the magnetic declination of this waypoint.
+ *
+ * @return A Double representing the magnetic declination of this waypoint.
+ */
+ public double getMagneticVariation() {
+ return this.magneticVariation;
+ }
+
+ /**
+ * Returns the name of this waypoint.
+ *
+ * @return A String representing the name of this waypoint.
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Returns the pdop of this waypoint.
+ *
+ * @return a Double representing the pdop of this waypoint.
+ */
+ public double getPdop() {
+ return this.pdop;
+ }
+
+ /**
+ * Returns the sat of this waypoint.
+ *
+ * @return an Integer representing the sat of this waypoint.
+ */
+ public int getSat() {
+ return this.sat;
+ }
+
+ /**
+ * Returns the src of this waypoint.
+ *
+ * @return A String representing the src of this waypoint.
+ */
+ public String getSrc() {
+ return this.src;
+ }
+
+ /**
+ * Returns the sym of this waypoint.
+ *
+ * @return A String representing the sym of this waypoint.
+ */
+ public String getSym() {
+ return this.sym;
+ }
+
+ /**
+ * Returns the time of this waypoint.
+ *
+ * @return a Date representing the name of this waypoint.
+ */
+ public Date getTime() {
+ return this.time;
+ }
+
+ /**
+ * Returns the type of this waypoint.
+ *
+ * @return A String representing the type of this waypoint.
+ */
+ public String getType() {
+ return this.type;
+ }
+
+ /**
+ * Returns the vdop of this waypoint.
+ *
+ * @return a Double representing the vdop of this waypoint.
+ */
+ public double getVdop() {
+ return this.vdop;
+ }
+
+ /**
+ * Setter for waypoint ageOfGPSData property. This maps to
+ * <ageOfGPSData> tag value.
+ *
+ * @param ageOfGPSData
+ * A String representing the ageOfGPSData of this waypoint.
+ */
+ public void setAgeOfGPSData(double ageOfGPSData) {
+ this.ageOfGpsData = ageOfGPSData;
+ }
+
+ /**
+ * Setter for waypoint comment property. This maps to <cmt> tag value.
+ *
+ * @param comment
+ * A String representing the comment of this waypoint.
+ */
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ /**
+ * Setter for waypoint description property. This maps to <desc> tag
+ * value.
+ *
+ * @param description
+ * A String representing the description of this waypoint.
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Setter for waypoint dGpsStationId property. This maps to
+ * <dGpsStationId> tag value.
+ *
+ * @param dGpsStationId
+ * an Integer representing the dGpsStationId of this waypoint.
+ */
+ public void setdGpsStationId(int dGpsStationId) {
+ this.dGpsStationId = dGpsStationId;
+ }
+
+ /**
+ * Setter for waypoint elevation property. This maps to <ele> tag
+ * value.
+ *
+ * @param elevation
+ * a Double value representing the elevation of this waypoint.
+ */
+ public void setElevation(double elevation) {
+ this.elevation = elevation;
+ }
+
+ /**
+ * Setter for waypoint fix property. This maps to <fix> tag value.
+ *
+ * @param fix
+ * a {@link Fix} representing the fix of this waypoint.
+ */
+ public void setFix(Fix fix) {
+ this.fix = fix;
+ }
+
+ /**
+ * Setter for waypoint geoid height property. This maps to
+ * <geoidheight> tag value.
+ *
+ * @param geoIdHeight
+ * A String representing the geoid height of this waypoint.
+ */
+ public void setGeoIdHeight(double geoIdHeight) {
+ this.geoIdHeight = geoIdHeight;
+ }
+
+ /**
+ * Setter for waypoint hdop property. This maps to <hdop> tag value.
+ *
+ * @param hdop
+ * a Double representing the name of this waypoint.
+ */
+ public void setHdop(double hdop) {
+ this.hdop = hdop;
+ }
+
+ /**
+ * Setter for waypoint latitude property. This maps to "lat" attribute
+ * value.
+ *
+ * @param latitude
+ * a Doube value representing the latitude of this waypoint.
+ */
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ /**
+ * Setter for waypoint longitude property. This maps to "long" attribute
+ * value.
+ *
+ * @param longitude
+ * a Doube value representing the longitude of this waypoint.
+ */
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+
+ /**
+ * Setter for waypoint magnetic declination property. This maps to
+ * <magvar> tag value.
+ *
+ * @param magVar
+ * A String representing the magnetic declination of this
+ * waypoint.
+ */
+ public void setMagneticVariation(double magVar) {
+ this.magneticVariation = magVar;
+ }
+
+ /**
+ * Setter for waypoint name property. This maps to <name> tag value.
+ *
+ * @param name
+ * A String representing the name of this waypoint.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Setter for waypoint pdop property. This maps to <pdop> tag value.
+ *
+ * @param pdop
+ * a Double representing the pdop of this waypoint.
+ */
+ public void setPdop(double pdop) {
+ this.pdop = pdop;
+ }
+
+ /**
+ * Setter for waypoint sat property. This maps to <sat> tag value.
+ *
+ * @param sat
+ * an Integer representing the sat of this waypoint.
+ */
+ public void setSat(int sat) {
+ this.sat = sat;
+ }
+
+ /**
+ * Setter for waypoint src property. This maps to <src> tag value.
+ *
+ * @param src
+ * a String representing the src of this waypoint.
+ */
+ public void setSrc(String src) {
+ this.src = src;
+ }
+
+ /**
+ * Setter for waypoint sym property. This maps to <sym> tag value.
+ *
+ * @param sym
+ * a String representing the sym of this waypoint.
+ */
+ public void setSym(String sym) {
+ this.sym = sym;
+ }
+
+ /**
+ * Setter for waypoint time property. This maps to <time> tag value.
+ *
+ * @param time
+ * a Date representing the time of this waypoint.
+ */
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+ /**
+ * Setter for waypoint type property. This maps to <type> tag value.
+ *
+ * @param type
+ * a String representing the type of this waypoint.
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Setter for waypoint vdop property. This maps to <vdop> tag value.
+ *
+ * @param vdop
+ * A String representing the vdop of this waypoint.
+ */
+ public void setVdop(double vdop) {
+ this.vdop = vdop;
+ }
+
+ /**
+ * Returns a String representation of this waypoint.
+ */
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+ String date = "";
+ if (this.time != null) {
+ date = sdf.format(this.time);
+ }
+ sb.append("[");
+ sb.append("name:'" + this.name + "' ");
+ sb.append("lat:" + this.latitude + " ");
+ sb.append("lon:" + this.longitude + " ");
+ sb.append("elv:" + this.elevation + " ");
+ sb.append("time:" + date + " ");
+ sb.append("fix:" + this.fix + " ");
+ if (this.extensionData != null) {
+ sb.append("extensions:{");
+ Iterator it = this.extensionData.keySet().iterator();
+ while (it.hasNext()) {
+ sb.append(it.next());
+ if (it.hasNext()) {
+ sb.append(",");
+ }
+ }
+ sb.append("}");
+ }
+ sb.append("]");
+ return sb.toString();
+ }
+
+ public HashSet getLinks() {
+ return links;
+ }
+
+ public void setLinks(HashSet links) {
+ this.links = links;
+ }
+
+ public void addLink(Link link) {
+ if (links == null) {
+ links = new HashSet<>();
+ }
+ links.add(link);
+ }
+}
diff --git a/src/com/hs/gpxparser/type/Fix.java b/src/com/hs/gpxparser/type/Fix.java
new file mode 100644
index 0000000..24e4582
--- /dev/null
+++ b/src/com/hs/gpxparser/type/Fix.java
@@ -0,0 +1,65 @@
+
+package com.hs.gpxparser.type;
+
+/**
+ * Type of GPS fix. Value comes from list: {'none'|'2d'|'3d'|'dgps'|'pps'}
+ *
+ *
+ * none = GPS had no fix.
+ * pps = military signal used
+ *
+ * To signify "the fix info is unknown", leave out fixType entirely.
+ */
+public class Fix {
+
+ /**
+ * Constant that defines 'none' Fix type
+ */
+ public static Fix NONE = new Fix("none");
+ /**
+ * Constant that defines '2d' Fix type
+ */
+ public static Fix TWO_D = new Fix("2d");
+ /**
+ * Constant that defines '3d' Fix type
+ */
+ public static Fix THREE_D = new Fix("3d");
+ /**
+ * Constant that defines 'dgps' Fix type
+ */
+ public static Fix DGPS = new Fix("dgps");
+
+ //'none'|'2d'|'3d'|'dgps'|'pps'
+ /**
+ * Constant that defines 'pps' Fix type
+ */
+ public static Fix PPS = new Fix("pps");
+ private String value;
+
+ private Fix(String value) {
+ this.value = value;
+ }
+
+ public static Fix returnType(String value) {
+ if (NONE.getValue().equals(value)) {
+ return NONE;
+ } else if (TWO_D.getValue().equals(value)) {
+ return TWO_D;
+ } else if (THREE_D.getValue().equals(value)) {
+ return THREE_D;
+ } else if (DGPS.getValue().equals(value)) {
+ return DGPS;
+ } else if (PPS.getValue().equals(value)) {
+ return PPS;
+ }
+ return null;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String toString() {
+ return value;
+ }
+}