|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.io.OsmConnection
org.openstreetmap.josm.io.OsmServerReader
org.openstreetmap.josm.io.MultiFetchServerObjectReader
public class MultiFetchServerObjectReader
Retrieves a set of OsmPrimitive
s from an OSM server using the so called
Multi Fetch API.
Usage:
MultiFetchServerObjectReader reader = MultiFetchServerObjectReader() .append(2345,2334,4444) .append(new Node(72343)); reader.parseOsm(); if (!reader.getMissingPrimitives().isEmpty()) { System.out.println("There are missing primitives: " + reader.getMissingPrimitives()); } if (!reader.getSkippedWays().isEmpty()) { System.out.println("There are skipped ways: " + reader.getMissingPrimitives()); }
Nested Class Summary | |
---|---|
protected static class |
MultiFetchServerObjectReader.Fetcher
The class that actually download data from OSM API. |
protected static class |
MultiFetchServerObjectReader.FetchResult
The class holding the results given by MultiFetchServerObjectReader.Fetcher . |
Field Summary | |
---|---|
private static int |
MAX_IDS_PER_REQUEST
the max. |
private java.util.Set<PrimitiveId> |
missingPrimitives
|
private java.util.Set<java.lang.Long> |
nodes
|
private DataSet |
outputDataSet
|
private java.util.Set<java.lang.Long> |
relations
|
private java.util.Set<java.lang.Long> |
ways
|
Fields inherited from class org.openstreetmap.josm.io.OsmConnection |
---|
activeConnection, cancel, oauthParameters |
Constructor Summary | |
---|---|
MultiFetchServerObjectReader()
Constructs a MultiFetchServerObjectReader . |
Method Summary | |
---|---|
MultiFetchServerObjectReader |
append(java.util.Collection<? extends OsmPrimitive> primitives)
appends a list of OsmPrimitive to the list of ids which will be fetched from the server. |
MultiFetchServerObjectReader |
append(DataSet ds,
long id,
OsmPrimitiveType type)
appends a OsmPrimitive id to the list of ids which will be fetched from the server. |
MultiFetchServerObjectReader |
append(OsmPrimitive primitive)
appends an OsmPrimitive to the list of ids which will be fetched from the server. |
MultiFetchServerObjectReader |
appendNode(Node node)
appends a Node id to the list of ids which will be fetched from the server. |
protected MultiFetchServerObjectReader |
appendRelation(Relation relation)
appends a Relation id to the list of ids which will be fetched from the server. |
MultiFetchServerObjectReader |
appendWay(Way way)
appends a Way id and the list of ids of nodes the way refers to the list of ids which will be fetched from the server. |
protected static java.lang.String |
buildRequestString(OsmPrimitiveType type,
long id)
builds the Multi Get request string for a single id and a given OsmPrimitiveType . |
protected static java.lang.String |
buildRequestString(OsmPrimitiveType type,
java.util.Set<java.lang.Long> idPackage)
builds the Multi Get request string for a set of ids and a given OsmPrimitiveType . |
protected java.util.Set<java.lang.Long> |
extractIdPackage(java.util.Set<java.lang.Long> ids)
extracts a subset of max MAX_IDS_PER_REQUEST ids from ids and
replies the subset. |
protected void |
fetchPrimitives(java.util.Set<java.lang.Long> ids,
OsmPrimitiveType type,
ProgressMonitor progressMonitor)
fetches a set of ids of a given OsmPrimitiveType from the server |
java.util.Set<PrimitiveId> |
getMissingPrimitives()
replies the set of ids of all primitives for which a fetch request to the server was submitted but which are not available from the server (the server replied a return code of 404) |
protected void |
merge(DataSet from)
merges the dataset from to outputDataSet . |
DataSet |
parseOsm(ProgressMonitor progressMonitor)
invokes one or more Multi Gets to fetch the OsmPrimitive s and replies
the dataset of retrieved primitives. |
protected void |
remember(DataSet ds,
long id,
OsmPrimitiveType type)
remembers an OsmPrimitive 's id. |
protected void |
remember(PrimitiveId id)
Remembers an OsmPrimitive 's id. |
protected void |
rememberNodesOfIncompleteWaysToLoad(DataSet from)
|
Methods inherited from class org.openstreetmap.josm.io.OsmServerReader |
---|
getBaseUrl, getInputStream, getInputStreamRaw, isDoAuthenticate, parseOsmBzip2, parseOsmChange, parseOsmChangeBzip2, parseOsmChangeGzip, parseOsmGzip, parseRawGps, setDoAuthenticate |
Methods inherited from class org.openstreetmap.josm.io.OsmConnection |
---|
addAuth, addBasicAuthorizationHeader, addOAuthAuthorizationHeader, cancel, isCanceled |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static int MAX_IDS_PER_REQUEST
private java.util.Set<java.lang.Long> nodes
private java.util.Set<java.lang.Long> ways
private java.util.Set<java.lang.Long> relations
private java.util.Set<PrimitiveId> missingPrimitives
private DataSet outputDataSet
Constructor Detail |
---|
public MultiFetchServerObjectReader()
MultiFetchServerObjectReader
.
Method Detail |
---|
protected void remember(PrimitiveId id)
OsmPrimitive
's id. The id will
later be fetched as part of a Multi Get request.
Ignore the id if it represents a new primitives.
id
- the idprotected void remember(DataSet ds, long id, OsmPrimitiveType type) throws java.lang.IllegalArgumentException, java.util.NoSuchElementException
OsmPrimitive
's id. ds
must include
an OsmPrimitive
with id=id
. The id will
later we fetched as part of a Multi Get request.
Ignore the id if it id <= 0.
ds
- the dataset (must not be null)id
- the primitive idtype
- The primitive type. Must be one of NODE
, WAY
, RELATION
java.lang.IllegalArgumentException
- if ds is null
java.util.NoSuchElementException
- if ds does not include an OsmPrimitive
with id=id
public MultiFetchServerObjectReader append(DataSet ds, long id, OsmPrimitiveType type)
OsmPrimitive
id to the list of ids which will be fetched from the server.
ds
- the DataSet
to which the primitive belongsid
- the primitive idtype
- The primitive type. Must be one of NODE
, WAY
, RELATION
public MultiFetchServerObjectReader appendNode(Node node)
Node
id to the list of ids which will be fetched from the server.
node
- the node (ignored, if null)
public MultiFetchServerObjectReader appendWay(Way way)
Way
id and the list of ids of nodes the way refers to the list of ids which will be fetched from the server.
way
- the way (ignored, if null)
protected MultiFetchServerObjectReader appendRelation(Relation relation)
Relation
id to the list of ids which will be fetched from the server.
relation
- the relation (ignored, if null)
public MultiFetchServerObjectReader append(OsmPrimitive primitive)
OsmPrimitive
to the list of ids which will be fetched from the server.
primitive
- the primitive
public MultiFetchServerObjectReader append(java.util.Collection<? extends OsmPrimitive> primitives)
OsmPrimitive
to the list of ids which will be fetched from the server.
primitives
- the list of primitives (ignored, if null)
append(OsmPrimitive)
protected java.util.Set<java.lang.Long> extractIdPackage(java.util.Set<java.lang.Long> ids)
MAX_IDS_PER_REQUEST
ids from ids
and
replies the subset. The extracted subset is removed from ids
.
ids
- a set of ids
protected static java.lang.String buildRequestString(OsmPrimitiveType type, java.util.Set<java.lang.Long> idPackage)
OsmPrimitiveType
.
type
- The primitive type. Must be one of NODE
, WAY
, RELATION
idPackage
- the package of ids
protected static java.lang.String buildRequestString(OsmPrimitiveType type, long id)
OsmPrimitiveType
.
type
- The primitive type. Must be one of NODE
, WAY
, RELATION
id
- the id
protected void rememberNodesOfIncompleteWaysToLoad(DataSet from)
protected void merge(DataSet from)
from
to outputDataSet
.
from
- the other datasetprotected void fetchPrimitives(java.util.Set<java.lang.Long> ids, OsmPrimitiveType type, ProgressMonitor progressMonitor) throws OsmTransferException
OsmPrimitiveType
from the server
ids
- the set of idstype
- The primitive type. Must be one of NODE
, WAY
, RELATION
OsmTransferException
- if an error occurs while communicating with the API serverpublic DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException
OsmPrimitive
s and replies
the dataset of retrieved primitives. Note that the dataset includes non visible primitives too!
In contrast to a simple Get for a node, a way, or a relation, a Multi Get always replies
the latest version of the primitive (if any), even if the primitive is not visible (i.e. if
visible==false).
Invoke getMissingPrimitives()
to get a list of primitives which have not been
found on the server (the server response code was 404)
parseOsm
in class OsmServerReader
OsmTransferException
- if an error occurs while communicating with the API servergetMissingPrimitives()
public java.util.Set<PrimitiveId> getMissingPrimitives()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |