Class OsmReader

  • Direct Known Subclasses:
    OsmChangeReader, OverpassDownloadReader.OverpassOsmReader

    public class OsmReader
    extends AbstractReader
    Parser for the Osm API (XML output). Read from an input stream and construct a dataset out of it. For each xml element, there is a dedicated method. The XMLStreamReader cursor points to the start of the element, when the method is entered, and it must point to the end of the same element, when it is exited.
    • Method Detail

      • setParser

        protected void setParser​(javax.xml.stream.XMLStreamReader parser)
      • throwException

        protected void throwException​(java.lang.Throwable th)
                               throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • throwException

        protected void throwException​(java.lang.String msg,
                                      java.lang.Throwable th)
                               throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • throwException

        protected void throwException​(java.lang.String msg)
                               throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parse

        protected void parse()
                      throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseRoot

        protected void parseRoot()
                          throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseOsm

        private void parseOsm()
                       throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseError

        private void parseError()
                         throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseRemark

        private void parseRemark()
                          throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseBounds

        private void parseBounds​(java.lang.String generator)
                          throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseNode

        protected Node parseNode()
                          throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseWay

        protected Way parseWay()
                        throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseWayNode

        private long parseWayNode​(WayData w)
                           throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseRelation

        protected Relation parseRelation()
                                  throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseChangeset

        private void parseChangeset​(java.lang.Long uploadChangesetId)
                             throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseTag

        private void parseTag​(Tagged t)
                       throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseUnknown

        protected void parseUnknown​(boolean printWarning)
                             throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseUnknown

        protected void parseUnknown()
                             throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • jumpToEnd

        protected final void jumpToEnd​(boolean printWarning)
                                throws javax.xml.stream.XMLStreamException
        When cursor is at the start of an element, moves it to the end tag of that element. Nested content is skipped. This is basically the same code as parseUnknown(), except for the warnings, which are displayed for inner elements and not at top level.
        Parameters:
        printWarning - if true, a warning message will be printed if an unknown element is met
        Throws:
        javax.xml.stream.XMLStreamException - if there is an error processing the underlying XML source
      • jumpToEnd

        protected final void jumpToEnd()
                                throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getLong

        private long getLong​(java.lang.String name)
                      throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • parseDataSet

        public static DataSet parseDataSet​(java.io.InputStream source,
                                           ProgressMonitor progressMonitor)
                                    throws IllegalDataException
        Parse the given input source and return the dataset.
        Parameters:
        source - the source input stream. Must not be null.
        progressMonitor - the progress monitor. If null, NullProgressMonitor.INSTANCE is assumed
        Returns:
        the dataset with the parsed data
        Throws:
        IllegalDataException - if an error was found while parsing the data from the source
        java.lang.IllegalArgumentException - if source is null
      • parseDataSet

        public static DataSet parseDataSet​(java.io.InputStream source,
                                           ProgressMonitor progressMonitor,
                                           OsmReader.Options... options)
                                    throws IllegalDataException
        Parse the given input source and return the dataset.
        Parameters:
        source - the source input stream. Must not be null.
        progressMonitor - the progress monitor. If null, NullProgressMonitor.INSTANCE is assumed
        options - The options to use when parsing the dataset
        Returns:
        the dataset with the parsed data
        Throws:
        IllegalDataException - if an error was found while parsing the data from the source
        java.lang.IllegalArgumentException - if source is null
        Since:
        16641