FileDocCategorySizeDatePackage
GpxParser.javaAPI DocAndroid 1.5 API13446Wed May 06 22:41:08 BST 2009com.android.ddmuilib.location

GpxParser

public class GpxParser extends Object
A very basic GPX parser to meet the need of the emulator control panel.

It parses basic waypoint information, and tracks (merging segments).

Fields Summary
private static final String
NS_GPX
private static final String
NODE_WAYPOINT
private static final String
NODE_TRACK
private static final String
NODE_TRACK_SEGMENT
private static final String
NODE_TRACK_POINT
private static final String
NODE_NAME
private static final String
NODE_TIME
private static final String
NODE_ELEVATION
private static final String
NODE_DESCRIPTION
private static final String
ATTR_LONGITUDE
private static final String
ATTR_LATITUDE
private static SAXParserFactory
sParserFactory
private String
mFileName
private GpxHandler
mHandler
private static final Pattern
ISO8601_TIME
Pattern to parse time with optional sub-second precision, and optional Z indicating the time is in UTC.
Constructors Summary
public GpxParser(String fileName)
Creates a new GPX parser for a file specified by its full path.

param
fileName The full path of the GPX file to parse.

        mFileName = fileName;
    
Methods Summary
public com.android.ddmuilib.location.GpxParser$Track[]getTracks()
Returns the parsed {@link Track} objects, or null if none were found (or if the parsing failed.

        if (mHandler != null) {
            return mHandler.getTracks();
        }
        
        return null;
    
public WayPoint[]getWayPoints()
Returns the parsed {@link WayPoint} objects, or null if none were found (or if the parsing failed.

        if (mHandler != null) {
            return mHandler.getWayPoints();
        }
        
        return null;
    
public booleanparse()
Parses the GPX file.

return
true if success.

        try {
            SAXParser parser = sParserFactory.newSAXParser();

            mHandler = new GpxHandler();

            parser.parse(new InputSource(new FileReader(mFileName)), mHandler);
            
            return mHandler.getSuccess();
        } catch (ParserConfigurationException e) {
        } catch (SAXException e) {
        } catch (IOException e) {
        } finally {
        }

        return false;