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
-
public class OsmServerBackreferenceReader extends OsmServerReader
OsmServerBackreferenceReader fetches the primitives from the OSM server which refer to a specific primitive. For aNode
, ways and relations are retrieved which refer to the node. For aWay
or aRelation
, only relations are read. OsmServerBackreferenceReader uses the API calls[node|way|relation]/#id/relations
andnode/#id/ways
to retrieve the referring primitives. The default behaviour of these calls is to reply incomplete primitives only. If you setsetReadFull(boolean)
to true this reader uses aMultiFetchServerObjectReader
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
Fields Modifier and Type Field Description private boolean
allowIncompleteParentWays
true if this reader should allow incomplete parent waysprivate long
id
the id of the primitive whose referrers are to be readprivate OsmPrimitiveType
primitiveType
the type of the primitiveprivate boolean
readFull
true if this reader should complete incomplete primitives-
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 OsmServerBackreferenceReader(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private DataSet
getReferringPrimitives(ProgressMonitor progressMonitor, java.lang.String type, java.lang.String message)
protected DataSet
getReferringRelations(ProgressMonitor progressMonitor)
Reads referring relations from the API server and replies them in aDataSet
protected DataSet
getReferringWays(ProgressMonitor progressMonitor)
Reads referring ways from the API server and replies them in aDataSet
boolean
isAllowIncompleteParentWays()
Determines if this reader allows to return incomplete parent ways of a node.boolean
isReadFull()
Replies true if this reader also reads immediate children of referring primitivesDataSet
parseOsm(ProgressMonitor progressMonitor)
Reads the referring primitives from the OSM server, parses them and replies them asDataSet
protected DataSet
readIncompletePrimitives(DataSet ds, ProgressMonitor progressMonitor)
Scans a dataset for incomplete primitives.OsmServerBackreferenceReader
setAllowIncompleteParentWays(boolean allowIncompleteWays)
Sets whether this reader allows to return incomplete parent ways of a node.OsmServerBackreferenceReader
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, setDoAuthenticate
-
Methods inherited from class org.openstreetmap.josm.io.OsmConnection
addAuth, addBasicAuthorizationHeader, addOAuth20AuthorizationHeader, cancel, isCanceled, retrieveBasicAuthorizationLogin, setOAuthAccessTokenFetcher
-
-
-
-
Field Detail
-
id
private final long id
the id of the primitive whose referrers are to be read
-
primitiveType
private final OsmPrimitiveType primitiveType
the type of the primitive
-
readFull
private boolean readFull
true if this reader should complete incomplete primitives
-
allowIncompleteParentWays
private boolean allowIncompleteParentWays
true if this reader should allow incomplete parent ways
-
-
Constructor Detail
-
OsmServerBackreferenceReader
public OsmServerBackreferenceReader(OsmPrimitive primitive)
constructor- Parameters:
primitive
- the primitive to be read. Must not be null. primitive.id > 0 expected- Throws:
java.lang.IllegalArgumentException
- if primitive is nulljava.lang.IllegalArgumentException
- if primitive.id <= 0
-
OsmServerBackreferenceReader
public OsmServerBackreferenceReader(long id, OsmPrimitiveType type)
constructor- Parameters:
id
- the id of the primitive. > 0 expectedtype
- the type of the primitive. Must not be null.- Throws:
java.lang.IllegalArgumentException
- if id <= 0java.lang.IllegalArgumentException
- if type is null
-
OsmServerBackreferenceReader
public OsmServerBackreferenceReader(OsmPrimitive primitive, boolean readFull)
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
public OsmServerBackreferenceReader(long id, OsmPrimitiveType type, boolean readFull)
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:
java.lang.IllegalArgumentException
- if id <= 0java.lang.IllegalArgumentException
- if type is null
-
-
Method Detail
-
isReadFull
public boolean 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
public OsmServerBackreferenceReader setReadFull(boolean readFull)
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
public boolean isAllowIncompleteParentWays()
Determines if this reader allows to return incomplete parent ways of a node.- Returns:
true
if this reader allows to return incomplete parent ways of a node- Since:
- 15426
-
setAllowIncompleteParentWays
public OsmServerBackreferenceReader setAllowIncompleteParentWays(boolean allowIncompleteWays)
Sets whether this reader allows to return incomplete parent ways of a node.- Parameters:
allowIncompleteWays
-true
if this reader allows to return incomplete parent ways of a node- Returns:
this
, for easy chaining- Since:
- 15426
-
getReferringPrimitives
private DataSet getReferringPrimitives(ProgressMonitor progressMonitor, java.lang.String type, java.lang.String message) throws OsmTransferException
- Throws:
OsmTransferException
-
getReferringWays
protected DataSet getReferringWays(ProgressMonitor progressMonitor) throws OsmTransferException
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/full
request.- 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
Way
or 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
public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException
Reads the referring primitives from the OSM server, parses them and replies them asDataSet
- Specified by:
parseOsm
in classOsmServerReader
- Parameters:
progressMonitor
- the progress monitor. Set toNullProgressMonitor.INSTANCE
if null.- Returns:
- the dataset with the referring primitives
- Throws:
OsmTransferException
- if an error occurs while communicating with the server
-
-