Class OsmServerReader

    • Constructor Detail

      • OsmServerReader

        protected OsmServerReader()
        Constructs a new OsmServerReader.
      • OsmServerReader

        protected OsmServerReader​(OsmApi osmApi)
        Constructs a new OsmServerReader.
        Parameters:
        osmApi - The API to use for this call
        Since:
        18650
    • Method Detail

      • getInputStream

        protected java.io.InputStream getInputStream​(java.lang.String urlStr,
                                                     ProgressMonitor progressMonitor)
                                              throws OsmTransferException
        Open a connection to the given url and return a reader on the input stream from that connection. In case of user cancel, return null. Relative URL's are directed to API base URL.
        Parameters:
        urlStr - The url to connect to.
        progressMonitor - progress monitoring and abort handler
        Returns:
        A reader reading the input stream (servers answer) or null.
        Throws:
        OsmTransferException - if data transfer errors occur
      • getInputStream

        protected java.io.InputStream getInputStream​(java.lang.String urlStr,
                                                     ProgressMonitor progressMonitor,
                                                     java.lang.String reason)
                                              throws OsmTransferException
        Open a connection to the given url and return a reader on the input stream from that connection. In case of user cancel, return null. Relative URL's are directed to API base URL.
        Parameters:
        urlStr - The url to connect to.
        progressMonitor - progress monitoring and abort handler
        reason - The reason to show on console. Can be null if no reason is given
        Returns:
        A reader reading the input stream (servers answer) or null.
        Throws:
        OsmTransferException - if data transfer errors occur
      • getBaseUrl

        protected java.lang.String getBaseUrl()
        Return the base URL for relative URL requests
        Returns:
        base url of API
      • getInputStreamRaw

        protected java.io.InputStream getInputStreamRaw​(java.lang.String urlStr,
                                                        ProgressMonitor progressMonitor)
                                                 throws OsmTransferException
        Open a connection to the given url and return a reader on the input stream from that connection. In case of user cancel, return null.
        Parameters:
        urlStr - The exact url to connect to.
        progressMonitor - progress monitoring and abort handler
        Returns:
        An reader reading the input stream (servers answer) or null.
        Throws:
        OsmTransferException - if data transfer errors occur
      • getInputStreamRaw

        protected java.io.InputStream getInputStreamRaw​(java.lang.String urlStr,
                                                        ProgressMonitor progressMonitor,
                                                        java.lang.String reason)
                                                 throws OsmTransferException
        Open a connection to the given url and return a reader on the input stream from that connection. In case of user cancel, return null.
        Parameters:
        urlStr - The exact url to connect to.
        progressMonitor - progress monitoring and abort handler
        reason - The reason to show on console. Can be null if no reason is given
        Returns:
        An reader reading the input stream (servers answer) or null.
        Throws:
        OsmTransferException - if data transfer errors occur
      • getInputStreamRaw

        protected java.io.InputStream getInputStreamRaw​(java.lang.String urlStr,
                                                        ProgressMonitor progressMonitor,
                                                        java.lang.String reason,
                                                        boolean uncompressAccordingToContentDisposition)
                                                 throws OsmTransferException
        Open a connection to the given url (if HTTP, trough a GET request) and return a reader on the input stream from that connection. In case of user cancel, return null.
        Parameters:
        urlStr - The exact url to connect to.
        progressMonitor - progress monitoring and abort handler
        reason - The reason to show on console. Can be null if no reason is given
        uncompressAccordingToContentDisposition - Whether to inspect the HTTP header Content-Disposition for filename and uncompress a gzip/bzip2/xz/zip stream.
        Returns:
        An reader reading the input stream (servers answer) or null.
        Throws:
        OsmTransferException - if data transfer errors occur
      • getInputStreamRaw

        protected java.io.InputStream getInputStreamRaw​(java.lang.String urlStr,
                                                        ProgressMonitor progressMonitor,
                                                        java.lang.String reason,
                                                        boolean uncompressAccordingToContentDisposition,
                                                        java.lang.String httpMethod,
                                                        byte[] requestBody)
                                                 throws OsmTransferException
        Open a connection to the given url (if HTTP, with the specified method) and return a reader on the input stream from that connection. In case of user cancel, return null.
        Parameters:
        urlStr - The exact url to connect to.
        progressMonitor - progress monitoring and abort handler
        reason - The reason to show on console. Can be null if no reason is given
        uncompressAccordingToContentDisposition - Whether to inspect the HTTP header Content-Disposition for filename and uncompress a gzip/bzip2/xz/zip stream.
        httpMethod - HTTP method ("GET", "POST" or "PUT")
        requestBody - HTTP request body (for "POST" and "PUT" methods only). Must be null for "GET" method.
        Returns:
        An reader reading the input stream (servers answer) or null.
        Throws:
        OsmTransferException - if data transfer errors occur
        Since:
        12596
      • adaptRequest

        protected void adaptRequest​(HttpClient request)
        Allows subclasses to modify the request.
        Parameters:
        request - the prepared request
        Since:
        9308
      • isDoAuthenticate

        public boolean isDoAuthenticate()
        Returns true if this reader is adding authentication credentials to the read request sent to the server.
        Returns:
        true if this reader is adding authentication credentials to the read request sent to the server
      • setDoAuthenticate

        public void setDoAuthenticate​(boolean doAuthenticate)
        Sets whether this reader adds authentication credentials to the read request sent to the server.
        Parameters:
        doAuthenticate - true if this reader adds authentication credentials to the read request sent to the server
      • isGpxParsedProperly

        public final boolean isGpxParsedProperly()
        Determines if the GPX data has been parsed properly.
        Returns:
        true if the GPX data has been parsed properly, false otherwise
        See Also:
        GpxReader.parse(boolean)
      • parseNotes

        public java.util.List<NoteparseNotes​(int noteLimit,
                                               int daysClosed,
                                               ProgressMonitor progressMonitor)
                                        throws OsmTransferException
        Downloads notes from the API, given API limit parameters
        Parameters:
        noteLimit - How many notes to download.
        daysClosed - Return notes closed this many days in the past. -1 means all notes, ever. 0 means only unresolved notes.
        progressMonitor - Progress monitor for user feedback
        Returns:
        List of notes returned by the API
        Throws:
        OsmTransferException - if any errors happen
      • parseRawNotes

        public java.util.List<NoteparseRawNotes​(ProgressMonitor progressMonitor)
                                           throws OsmTransferException
        Downloads notes from a given raw URL. The URL is assumed to be complete and no API limits are added
        Parameters:
        progressMonitor - progress monitor
        Returns:
        A list of notes parsed from the URL
        Throws:
        OsmTransferException - if any error occurs during dialog with OSM API
      • parseRawNotes

        public java.util.List<NoteparseRawNotes​(ProgressMonitor progressMonitor,
                                                  Compression compression)
                                           throws OsmTransferException
        Download notes from a URL that contains a compressed notes dump file
        Parameters:
        progressMonitor - progress monitor
        compression - compression to use
        Returns:
        A list of notes parsed from the URL
        Throws:
        OsmTransferException - if any error occurs during dialog with OSM API
        Since:
        13352
      • getAttribute

        protected static java.lang.String getAttribute​(org.w3c.dom.Node node,
                                                       java.lang.String name)
        Returns an attribute from the given DOM node.
        Parameters:
        node - DOM node
        name - attribute name
        Returns:
        attribute value for the given attribute
        Since:
        12510
      • fetchData

        public <T> T fetchData​(java.lang.String api,
                               java.lang.String subtask,
                               OsmServerReader.DomParser<T> parser,
                               ProgressMonitor monitor,
                               java.lang.String reason)
                        throws OsmTransferException
        Fetches generic data from the DOM document resulting an API call.
        Type Parameters:
        T - data type
        Parameters:
        api - the OSM API call
        subtask - the subtask translated message
        parser - the parser converting the DOM document (OSM API result)
        monitor - The progress monitor
        reason - The reason to show on console. Can be null if no reason is given
        Returns:
        The converted data
        Throws:
        OsmTransferException - if something goes wrong
        Since:
        12510