]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/load/xml/GpxHandler.java
Version 13, August 2011
[GpsPrune.git] / tim / prune / load / xml / GpxHandler.java
index ec52f8b5b4b81c54cadb5976a0ed4633d528f494..4208014e44c1e9e8c9df262c0caa3083f3bd76f3 100644 (file)
@@ -22,7 +22,8 @@ public class GpxHandler extends XmlHandler
        private GpxTag _name = new GpxTag(), _trackName = new GpxTag();
        private String _latitude = null, _longitude = null;
        private GpxTag _elevation = new GpxTag(), _time = new GpxTag();
-       private GpxTag _type = new GpxTag(), _link = new GpxTag();
+       private GpxTag _type = new GpxTag(), _description = new GpxTag();
+       private GpxTag _link = new GpxTag();
        private GpxTag _currentTag = null;
        private ArrayList<String[]> _pointList = new ArrayList<String[]>();
        private ArrayList<String> _linkList = new ArrayList<String>();
@@ -55,6 +56,7 @@ public class GpxHandler extends XmlHandler
                        _time.setValue(null);
                        _type.setValue(null);
                        _link.setValue(null);
+                       _description.setValue(null);
                }
                else if (tag.equals("ele")) {
                        _currentTag = _elevation;
@@ -68,6 +70,9 @@ public class GpxHandler extends XmlHandler
                else if (tag.equals("type")) {
                        _currentTag = _type;
                }
+               else if (tag.equals("description")) {
+                       _currentTag = _description;
+               }
                else if (tag.equals("link")) {
                        _link.setValue(attributes.getValue("href"));
                }
@@ -137,17 +142,19 @@ public class GpxHandler extends XmlHandler
        private void processPoint()
        {
                // Put the values into a String array matching the order in getFieldArray()
-               String[] values = new String[7];
+               String[] values = new String[8];
                values[0] = _latitude;
                values[1] = _longitude;
                values[2] = _elevation.getValue();
                if (_insideWaypoint) {values[3] = _name.getValue();}
                values[4] = _time.getValue();
-               if (_startSegment && !_insideWaypoint) {
+               if (_startSegment && !_insideWaypoint)
+               {
                        values[5] = "1";
                        _startSegment = false;
                }
                values[6] = _type.getValue();
+               values[7] = _description.getValue();
                _pointList.add(values);
                _trackNameList.addPoint(_trackNum, _trackName.getValue(), _isTrackPoint);
                _linkList.add(_link.getValue());
@@ -160,7 +167,8 @@ public class GpxHandler extends XmlHandler
        public Field[] getFieldArray()
        {
                final Field[] fields = {Field.LATITUDE, Field.LONGITUDE, Field.ALTITUDE,
-                       Field.WAYPT_NAME, Field.TIMESTAMP, Field.NEW_SEGMENT, Field.WAYPT_TYPE};
+                       Field.WAYPT_NAME, Field.TIMESTAMP, Field.NEW_SEGMENT,
+                       Field.WAYPT_TYPE, Field.DESCRIPTION};
                return fields;
        }