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:
java.util.concurrent.Callable<MultiFetchServerObjectReader.FetchResult>
- Enclosing class:
- MultiFetchServerObjectReader
protected class MultiFetchServerObjectReader.Fetcher extends OsmServerReader implements java.util.concurrent.Callable<MultiFetchServerObjectReader.FetchResult>
The class that actually download data from OSM API. Several instances of this class are used byMultiFetchServerObjectReader
(one per set of primitives to fetch). The inheritance ofOsmServerReader
is only explained by the need to have a distinct OSM connection byFetcher
instance.- See Also:
MultiFetchServerObjectReader.FetchResult
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.io.OsmServerReader
OsmServerReader.DomParser<R>
-
Nested classes/interfaces inherited from class org.openstreetmap.josm.io.OsmConnection
OsmConnection.OAuthAccessTokenFetcher
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.lang.Long>
pkg
private ProgressMonitor
progressMonitor
private OsmPrimitiveType
type
-
Fields inherited from class org.openstreetmap.josm.io.OsmServerReader
contentType, gpxParsedProperly
-
Fields inherited from class org.openstreetmap.josm.io.OsmConnection
activeConnection, cancel, fetcher, oAuth20Parameters
-
-
Constructor Summary
Constructors Constructor Description Fetcher(OsmPrimitiveType type, java.util.Set<java.lang.Long> idsPackage, ProgressMonitor progressMonitor)
Constructs aFetcher
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MultiFetchServerObjectReader.FetchResult
call()
protected MultiFetchServerObjectReader.FetchResult
fetch(ProgressMonitor progressMonitor)
fetches the requested primitives and updates the specified progress monitor.protected java.lang.String
getBaseUrl()
Return the base URL for relative URL requestsprotected MultiFetchServerObjectReader.FetchResult
multiGetIdPackage(OsmPrimitiveType type, java.util.Set<java.lang.Long> pkg, ProgressMonitor progressMonitor)
invokes a Multi Get for a set of ids and a givenOsmPrimitiveType
.DataSet
parseOsm(ProgressMonitor progressMonitor)
Download OSM files from somewhereprotected DataSet
singleGetId(OsmPrimitiveType type, long id, ProgressMonitor progressMonitor)
invokes a Multi Get for a single id and a givenOsmPrimitiveType
.protected MultiFetchServerObjectReader.FetchResult
singleGetIdPackage(OsmPrimitiveType type, java.util.Set<java.lang.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, setDoAuthenticate
-
Methods inherited from class org.openstreetmap.josm.io.OsmConnection
addAuth, addBasicAuthorizationHeader, addOAuth20AuthorizationHeader, cancel, isCanceled, retrieveBasicAuthorizationLogin, setOAuthAccessTokenFetcher
-
-
-
-
Field Detail
-
pkg
private final java.util.Set<java.lang.Long> pkg
-
type
private final OsmPrimitiveType type
-
progressMonitor
private final ProgressMonitor progressMonitor
-
-
Constructor Detail
-
Fetcher
public Fetcher(OsmPrimitiveType type, java.util.Set<java.lang.Long> idsPackage, ProgressMonitor progressMonitor)
Constructs aFetcher
-
-
Method Detail
-
parseOsm
public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException
Description copied from class:OsmServerReader
Download OSM files from somewhere- Specified by:
parseOsm
in classOsmServerReader
- Parameters:
progressMonitor
- The progress monitor- Returns:
- The corresponding dataset
- Throws:
OsmTransferException
- if any error occurs
-
call
public MultiFetchServerObjectReader.FetchResult call() throws java.lang.Exception
- Specified by:
call
in interfacejava.util.concurrent.Callable<MultiFetchServerObjectReader.FetchResult>
- Throws:
java.lang.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.FetchResult
of this operation - Throws:
OsmTransferException
- if an error occurs while communicating with the API server
-
getBaseUrl
protected java.lang.String getBaseUrl()
Description copied from class:OsmServerReader
Return the base URL for relative URL requests- Overrides:
getBaseUrl
in classOsmServerReader
- Returns:
- base url of API
-
multiGetIdPackage
protected MultiFetchServerObjectReader.FetchResult multiGetIdPackage(OsmPrimitiveType type, java.util.Set<java.lang.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
,RELATION
pkg
- the package of idsprogressMonitor
- progress monitor- Returns:
- the
MultiFetchServerObjectReader.FetchResult
of 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
,RELATION
id
- the idprogressMonitor
- progress monitor- Returns:
- the
DataSet
resulting of this operation - Throws:
OsmTransferException
- if an error occurs while communicating with the API server
-
singleGetIdPackage
protected MultiFetchServerObjectReader.FetchResult singleGetIdPackage(OsmPrimitiveType type, java.util.Set<java.lang.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
,RELATION
pkg
- the set of idsprogressMonitor
- progress monitor- Returns:
- the
MultiFetchServerObjectReader.FetchResult
of this operation - Throws:
OsmTransferException
- if an error occurs while communicating with the API server
-
-