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 aWayor aRelation, only relations are read. OsmServerBackreferenceReader uses the API calls[node|way|relation]/#id/relationsandnode/#id/waysto 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 aMultiFetchServerObjectReaderto 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 booleanallowIncompleteParentWaystrue if this reader should allow incomplete parent waysprivate longidthe id of the primitive whose referrers are to be readprivate OsmPrimitiveTypeprimitiveTypethe type of the primitiveprivate booleanreadFulltrue 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 DataSetgetReferringPrimitives(ProgressMonitor progressMonitor, java.lang.String type, java.lang.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 aDataSetbooleanisAllowIncompleteParentWays()Determines if this reader allows to return incomplete parent ways of a node.booleanisReadFull()Replies true if this reader also reads immediate children of referring primitivesDataSetparseOsm(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.OsmServerBackreferenceReadersetAllowIncompleteParentWays(boolean allowIncompleteWays)Sets whether this reader allows to return incomplete parent ways of a node.OsmServerBackreferenceReadersetReadFull(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:
trueif 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-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, 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/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
public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException
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
-
-