private boolean _insideName = false;
private boolean _insideElevation = false;
private boolean _insideTime = false;
-// private boolean _insideType = false;
+ private boolean _insideType = false;
private boolean _startSegment = true;
private String _name = null, _latitude = null, _longitude = null;
private String _elevation = null;
private String _time = null;
-// private String _type = null;
+ private String _type = null;
private ArrayList<String[]> _pointList = new ArrayList<String[]>();
- // FIXME: Read waypoint type too
-
/**
* Receive the start of a tag
* @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
Attributes attributes) throws SAXException
{
// Read the parameters for waypoints and track points
- if (qName.equalsIgnoreCase("wpt") || qName.equalsIgnoreCase("trkpt"))
+ if (qName.equalsIgnoreCase("wpt") || qName.equalsIgnoreCase("trkpt") || qName.equalsIgnoreCase("rtept"))
{
_insideWaypoint = qName.equalsIgnoreCase("wpt");
int numAttributes = attributes.getLength();
_elevation = null;
_name = null;
_time = null;
+ _type = null;
}
else if (qName.equalsIgnoreCase("ele"))
{
{
_insideTime = true;
}
-// else if (qName.equalsIgnoreCase("type"))
-// {
-// _insideType = true;
-// }
+ else if (qName.equalsIgnoreCase("type"))
+ {
+ _insideType = true;
+ }
else if (qName.equalsIgnoreCase("trkseg"))
{
_startSegment = true;
public void endElement(String uri, String localName, String qName)
throws SAXException
{
- if (qName.equalsIgnoreCase("wpt") || qName.equalsIgnoreCase("trkpt"))
+ if (qName.equalsIgnoreCase("wpt") || qName.equalsIgnoreCase("trkpt") || qName.equalsIgnoreCase("rtept"))
{
processPoint();
}
{
_insideTime = false;
}
+ else if (qName.equalsIgnoreCase("type"))
+ {
+ _insideType = false;
+ }
super.endElement(uri, localName, qName);
}
if (_insideName && _insideWaypoint) {_name = checkCharacters(_name, value);}
else if (_insideElevation) {_elevation = checkCharacters(_elevation, value);}
else if (_insideTime) {_time = checkCharacters(_time, value);}
+ else if (_insideType) {_type = checkCharacters(_type, value);}
super.characters(ch, start, length);
}
private void processPoint()
{
// Put the values into a String array matching the order in getFieldArray()
- String[] values = new String[6];
+ String[] values = new String[7];
values[0] = _latitude; values[1] = _longitude;
values[2] = _elevation; values[3] = _name;
values[4] = _time;
values[5] = "1";
_startSegment = false;
}
+ values[6] = _type;
_pointList.add(values);
}
public Field[] getFieldArray()
{
final Field[] fields = {Field.LATITUDE, Field.LONGITUDE, Field.ALTITUDE,
- Field.WAYPT_NAME, Field.TIMESTAMP, Field.NEW_SEGMENT};
+ Field.WAYPT_NAME, Field.TIMESTAMP, Field.NEW_SEGMENT, Field.WAYPT_TYPE};
return fields;
}