Package org.openstreetmap.josm.io
Class MultiFetchServerObjectReader.Fetcher
java.lang.Object
org.openstreetmap.josm.io.OsmConnection
org.openstreetmap.josm.io.OsmServerReader
org.openstreetmap.josm.io.MultiFetchServerObjectReader.Fetcher
- All Implemented Interfaces:
Callable<MultiFetchServerObjectReader.FetchResult>
- Enclosing class:
- MultiFetchServerObjectReader
protected class MultiFetchServerObjectReader.Fetcher
extends OsmServerReader
implements Callable<MultiFetchServerObjectReader.FetchResult>
The class that actually download data from OSM API.
Several instances of this class are used by
MultiFetchServerObjectReader (one per set of primitives to fetch).
The inheritance of OsmServerReader is only explained by the need to have a distinct OSM connection by Fetcher instance.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openstreetmap.josm.io.OsmServerReader
OsmServerReader.DomParser<R> -
Field Summary
FieldsFields inherited from class org.openstreetmap.josm.io.OsmServerReader
contentType, gpxParsedProperlyFields inherited from class org.openstreetmap.josm.io.OsmConnection
activeConnection, cancel, oAuth20Parameters -
Constructor Summary
ConstructorsConstructorDescriptionFetcher(OsmPrimitiveType type, Set<Long> idsPackage, ProgressMonitor progressMonitor) Constructs aFetcher -
Method Summary
Modifier and TypeMethodDescriptioncall()protected MultiFetchServerObjectReader.FetchResultfetch(ProgressMonitor progressMonitor) fetches the requested primitives and updates the specified progress monitor.protected StringReturn the base URL for relative URL requestsprotected MultiFetchServerObjectReader.FetchResultmultiGetIdPackage(OsmPrimitiveType type, Set<Long> pkg, ProgressMonitor progressMonitor) invokes a Multi Get for a set of ids and a givenOsmPrimitiveType.parseOsm(ProgressMonitor progressMonitor) Download OSM files from somewhereprotected DataSetsingleGetId(OsmPrimitiveType type, long id, ProgressMonitor progressMonitor) invokes a Multi Get for a single id and a givenOsmPrimitiveType.protected MultiFetchServerObjectReader.FetchResultsingleGetIdPackage(OsmPrimitiveType type, Set<Long> pkg, ProgressMonitor progressMonitor) invokes a sequence of Multi Gets for individual ids in a set of ids and a givenOsmPrimitiveType.Methods inherited from class org.openstreetmap.josm.io.OsmServerReader
adaptRequest, fetchData, getAttribute, getInputStream, getInputStream, getInputStreamRaw, getInputStreamRaw, getInputStreamRaw, getInputStreamRaw, isDoAuthenticate, isGpxParsedProperly, parseNotes, parseOsm, parseOsmChange, parseOsmChange, parseRawGps, parseRawGps, parseRawNotes, parseRawNotes, setDoAuthenticateMethods inherited from class org.openstreetmap.josm.io.OsmConnection
addAuth, addBasicAuthorizationHeader, addOAuth20AuthorizationHeader, cancel, isCanceled, retrieveBasicAuthorizationLogin
-
Field Details
-
pkg
-
type
-
progressMonitor
-
-
Constructor Details
-
Method Details
-
parseOsm
Description copied from class:OsmServerReaderDownload OSM files from somewhere- Specified by:
parseOsmin classOsmServerReader- Parameters:
progressMonitor- The progress monitor- Returns:
- The corresponding dataset
- Throws:
OsmTransferException- if any error occurs
-
call
- Specified by:
callin interfaceCallable<MultiFetchServerObjectReader.FetchResult>- Throws:
Exception
-
fetch
protected MultiFetchServerObjectReader.FetchResult fetch(ProgressMonitor progressMonitor) throws OsmTransferException fetches the requested primitives and updates the specified progress monitor.- Parameters:
progressMonitor- the progress monitor- Returns:
- the
MultiFetchServerObjectReader.FetchResultof this operation - Throws:
OsmTransferException- if an error occurs while communicating with the API server
-
getBaseUrl
Description copied from class:OsmServerReaderReturn the base URL for relative URL requests- Overrides:
getBaseUrlin classOsmServerReader- Returns:
- base url of API
-
multiGetIdPackage
protected MultiFetchServerObjectReader.FetchResult multiGetIdPackage(OsmPrimitiveType type, Set<Long> pkg, ProgressMonitor progressMonitor) throws OsmTransferException invokes a Multi Get for a set of ids and a givenOsmPrimitiveType. The retrieved primitives are merged toMultiFetchServerObjectReader.outputDataSet.- Parameters:
type- The primitive type. Must be one ofNODE,WAY,RELATIONpkg- the package of idsprogressMonitor- progress monitor- Returns:
- the
MultiFetchServerObjectReader.FetchResultof this operation - Throws:
OsmTransferException- if an error occurs while communicating with the API server
-
singleGetId
protected DataSet singleGetId(OsmPrimitiveType type, long id, ProgressMonitor progressMonitor) throws OsmTransferException invokes a Multi Get for a single id and a givenOsmPrimitiveType. The retrieved primitive is merged toMultiFetchServerObjectReader.outputDataSet.- Parameters:
type- The primitive type. Must be one ofNODE,WAY,RELATIONid- the idprogressMonitor- progress monitor- Returns:
- the
DataSetresulting of this operation - Throws:
OsmTransferException- if an error occurs while communicating with the API server
-
singleGetIdPackage
protected MultiFetchServerObjectReader.FetchResult singleGetIdPackage(OsmPrimitiveType type, Set<Long> pkg, ProgressMonitor progressMonitor) throws OsmTransferException invokes a sequence of Multi Gets for individual ids in a set of ids and a givenOsmPrimitiveType. The retrieved primitives are merged toMultiFetchServerObjectReader.outputDataSet.This method is used if one of the ids in pkg doesn't exist (the server replies with return code 404). If the set is fetched with this method it is possible to find out which of the ids doesn't exist. Unfortunately, the server does not provide an error header or an error body for a 404 reply.
- Parameters:
type- The primitive type. Must be one ofNODE,WAY,RELATIONpkg- the set of idsprogressMonitor- progress monitor- Returns:
- the
MultiFetchServerObjectReader.FetchResultof this operation - Throws:
OsmTransferException- if an error occurs while communicating with the API server
-