Package org.openstreetmap.josm.io
Class OsmServerBackreferenceReader
java.lang.Object
org.openstreetmap.josm.io.OsmConnection
org.openstreetmap.josm.io.OsmServerReader
org.openstreetmap.josm.io.OsmServerBackreferenceReader
OsmServerBackreferenceReader fetches the primitives from the OSM server which
refer to a specific primitive. For a
Node, ways and relations are retrieved
which refer to the node. For a Way or a Relation, only relations are read.
OsmServerBackreferenceReader uses the API calls [node|way|relation]/#id/relations
and node/#id/ways to retrieve the referring primitives. The default behaviour
of these calls is to reply incomplete primitives only.
If you set setReadFull(boolean) to true this reader uses a MultiFetchServerObjectReader
to complete incomplete primitives.- Since:
- 1806
-
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
FieldsModifier and TypeFieldDescriptionprivate booleantrue if this reader should allow incomplete parent waysprivate final longthe id of the primitive whose referrers are to be readprivate final OsmPrimitiveTypethe type of the primitiveprivate booleantrue if this reader should complete incomplete primitivesFields inherited from class org.openstreetmap.josm.io.OsmServerReader
contentType, gpxParsedProperlyFields inherited from class org.openstreetmap.josm.io.OsmConnection
activeConnection, cancel, fetcher, oAuth20Parameters -
Constructor Summary
ConstructorsConstructorDescriptionOsmServerBackreferenceReader(long id, OsmPrimitiveType type) constructorOsmServerBackreferenceReader(long id, OsmPrimitiveType type, boolean readFull) Creates a back reference reader for given primitive idOsmServerBackreferenceReader(OsmPrimitive primitive) constructorOsmServerBackreferenceReader(OsmPrimitive primitive, boolean readFull) Creates a back reference reader for given primitive -
Method Summary
Modifier and TypeMethodDescriptionprivate DataSetgetReferringPrimitives(ProgressMonitor progressMonitor, String type, String message) protected DataSetgetReferringRelations(ProgressMonitor progressMonitor) Reads referring relations from the API server and replies them in aDataSetprotected DataSetgetReferringWays(ProgressMonitor progressMonitor) Reads referring ways from the API server and replies them in aDataSetbooleanDetermines if this reader allows to return incomplete parent ways of a node.booleanReplies true if this reader also reads immediate children of referring primitivesparseOsm(ProgressMonitor progressMonitor) Reads the referring primitives from the OSM server, parses them and replies them asDataSetprotected DataSetreadIncompletePrimitives(DataSet ds, ProgressMonitor progressMonitor) Scans a dataset for incomplete primitives.setAllowIncompleteParentWays(boolean allowIncompleteWays) Sets whether this reader allows to return incomplete parent ways of a node.setReadFull(boolean readFull) Set true if this reader should reads immediate children of referring primitives too.Methods inherited from class org.openstreetmap.josm.io.OsmServerReader
adaptRequest, fetchData, getAttribute, getBaseUrl, 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, setOAuthAccessTokenFetcher
-
Field Details
-
id
the id of the primitive whose referrers are to be read -
primitiveType
the type of the primitive -
readFull
true if this reader should complete incomplete primitives -
allowIncompleteParentWays
true if this reader should allow incomplete parent ways
-
-
Constructor Details
-
OsmServerBackreferenceReader
constructor- Parameters:
primitive- the primitive to be read. Must not be null. primitive.id > 0 expected- Throws:
IllegalArgumentException- if primitive is nullIllegalArgumentException- if primitive.id <= 0
-
OsmServerBackreferenceReader
constructor- Parameters:
id- the id of the primitive. > 0 expectedtype- the type of the primitive. Must not be null.- Throws:
IllegalArgumentException- if id <= 0IllegalArgumentException- if type is null
-
OsmServerBackreferenceReader
Creates a back reference reader for given primitive- Parameters:
primitive- the primitivereadFull-true, if referrers should be read fully (i.e. including their immediate children)
-
OsmServerBackreferenceReader
Creates a back reference reader for given primitive id- Parameters:
id- the id of the primitive whose referrers are to be readtype- the type of the primitivereadFull- true, if referrers should be read fully (i.e. including their immediate children)- Throws:
IllegalArgumentException- if id <= 0IllegalArgumentException- if type is null
-
-
Method Details
-
isReadFull
Replies true if this reader also reads immediate children of referring primitives- Returns:
- true if this reader also reads immediate children of referring primitives
-
setReadFull
Set true if this reader should reads immediate children of referring primitives too. False, otherwise.- Parameters:
readFull- true if this reader should reads immediate children of referring primitives too. False, otherwise.- Returns:
this, for easy chaining- Since:
- 15426
-
isAllowIncompleteParentWays
Determines if this reader allows to return incomplete parent ways of a node.- Returns:
trueif this reader allows to return incomplete parent ways of a node- Since:
- 15426
-
setAllowIncompleteParentWays
Sets whether this reader allows to return incomplete parent ways of a node.- Parameters:
allowIncompleteWays-trueif this reader allows to return incomplete parent ways of a node- Returns:
this, for easy chaining- Since:
- 15426
-
getReferringPrimitives
private DataSet getReferringPrimitives(ProgressMonitor progressMonitor, String type, String message) throws OsmTransferException - Throws:
OsmTransferException
-
getReferringWays
Reads referring ways from the API server and replies them in aDataSet- Parameters:
progressMonitor- progress monitor- Returns:
- the data set
- Throws:
OsmTransferException- if any error occurs during dialog with OSM API
-
getReferringRelations
protected DataSet getReferringRelations(ProgressMonitor progressMonitor) throws OsmTransferException Reads referring relations from the API server and replies them in aDataSet- Parameters:
progressMonitor- the progress monitor- Returns:
- the data set
- Throws:
OsmTransferException- if any error occurs during dialog with OSM API
-
readIncompletePrimitives
protected DataSet readIncompletePrimitives(DataSet ds, ProgressMonitor progressMonitor) throws OsmTransferException Scans a dataset for incomplete primitives. Depending on the configuration of this reader incomplete primitives are read from the server with an individual/api/0.6/[way,relation]/#id/fullrequest.- if this reader reads referrers for a
Node, referring ways are always read fully, unlesssetAllowIncompleteParentWays(boolean)is set to true. - if this reader reads referrers for an
Wayor aRelation, referring relations are only read fully ifsetReadFull(boolean)is set to true.
- Parameters:
ds- the original datasetprogressMonitor- the progress monitor- Returns:
- the modified dataset
- Throws:
OsmTransferException- if an exception occurs.
- if this reader reads referrers for a
-
parseOsm
Reads the referring primitives from the OSM server, parses them and replies them asDataSet- Specified by:
parseOsmin classOsmServerReader- Parameters:
progressMonitor- the progress monitor. Set toNullProgressMonitor.INSTANCEif null.- Returns:
- the dataset with the referring primitives
- Throws:
OsmTransferException- if an error occurs while communicating with the server
-