Class GpxReader

java.lang.Object
org.openstreetmap.josm.io.GpxReader
All Implemented Interfaces:
GpxConstants, IGpxReader

public class GpxReader extends Object implements GpxConstants, IGpxReader
Read a gpx file.

Bounds are read, even if we calculate them, see GpxData.recalculateBounds().
Both GPX version 1.0 and 1.1 are supported.

  • Field Details

  • Constructor Details

    • GpxReader

      public GpxReader(InputStream source) throws IOException
      Constructs a new GpxReader, which can later parse the input stream and store the result in trackData and markerData
      Parameters:
      source - the source input stream
      Throws:
      IOException - if an IO error occurs, e.g. the input stream is closed.
  • Method Details

    • parse

      public boolean parse(boolean tryToFinish) throws SAXException, IOException
      Parse the GPX data.
      Specified by:
      parse in interface IGpxReader
      Parameters:
      tryToFinish - true, if the reader should return at least part of the GPX data in case of an error.
      Returns:
      true if file was properly parsed, false if there was error during parsing but some data were parsed anyway
      Throws:
      SAXException - if any SAX parsing error occurs
      IOException - if any I/O error occurs
    • getGpxData

      public GpxData getGpxData()
      Description copied from interface: IGpxReader
      Replies the GPX data.
      Specified by:
      getGpxData in interface IGpxReader
      Returns:
      The GPX data