org.openstreetmap.josm.io
Class OsmServerBackreferenceReader

java.lang.Object
  extended by org.openstreetmap.josm.io.OsmConnection
      extended by org.openstreetmap.josm.io.OsmServerReader
          extended by 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 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.


Field Summary
private  long id
          the id of the primitive whose referrers are to be read
private  OsmPrimitiveType primitiveType
          the type of the primitive
private  boolean readFull
          true if this reader should complete incomplete primitives
 
Fields inherited from class org.openstreetmap.josm.io.OsmConnection
activeConnection, cancel, oauthParameters
 
Constructor Summary
OsmServerBackreferenceReader(long id, OsmPrimitiveType type)
          constructor
OsmServerBackreferenceReader(long id, OsmPrimitiveType type, boolean readFull)
          constructor
OsmServerBackreferenceReader(OsmPrimitive primitive)
          constructor
OsmServerBackreferenceReader(OsmPrimitive primitive, boolean readFull)
          constructor
 
Method Summary
protected  DataSet getReferringRelations(ProgressMonitor progressMonitor)
          Reads referring relations from the API server and replies them in a DataSet
protected  DataSet getReferringWays(ProgressMonitor progressMonitor)
          Reads referring ways from the API server and replies them in a DataSet
 boolean isReadFull()
          Replies true if this reader also reads immediate children of referring primitives
 DataSet parseOsm(ProgressMonitor progressMonitor)
          Reads the referring primitives from the OSM server, parses them and replies them as DataSet
protected  DataSet readIncompletePrimitives(DataSet ds, ProgressMonitor progressMonitor)
          Scans a dataset for incomplete primitives.
 void 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
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

id

private long id
the id of the primitive whose referrers are to be read


primitiveType

private OsmPrimitiveType primitiveType
the type of the primitive


readFull

private boolean readFull
true if this reader should complete incomplete primitives

Constructor Detail

OsmServerBackreferenceReader

public OsmServerBackreferenceReader(OsmPrimitive primitive)
                             throws java.lang.IllegalArgumentException
constructor

Parameters:
primitive - the primitive to be read. Must not be null. primitive.id > 0 expected
Throws:
java.lang.IllegalArgumentException - thrown if primitive is null
java.lang.IllegalArgumentException - thrown if primitive.id <= 0

OsmServerBackreferenceReader

public OsmServerBackreferenceReader(long id,
                                    OsmPrimitiveType type)
                             throws java.lang.IllegalArgumentException
constructor

Parameters:
id - the id of the primitive. > 0 expected
type - the type of the primitive. Must not be null.
Throws:
java.lang.IllegalArgumentException - thrown if id <= 0
java.lang.IllegalArgumentException - thrown if type is null

OsmServerBackreferenceReader

public OsmServerBackreferenceReader(OsmPrimitive primitive,
                                    boolean readFull)
constructor

Parameters:
id - the id of the primitive. > 0 expected
readFull - true, if referers should be read fully (i.e. including their immediate children)

OsmServerBackreferenceReader

public OsmServerBackreferenceReader(long id,
                                    OsmPrimitiveType type,
                                    boolean readFull)
                             throws java.lang.IllegalArgumentException
constructor

Parameters:
primitive - the primitive whose referers are to be read
readFull - true, if referers should be read fully (i.e. including their immediate children)
Throws:
java.lang.IllegalArgumentException - thrown if id <= 0
java.lang.IllegalArgumentException - thrown 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 void setReadFull(boolean readFull)
Set true if this reader should reads immediate children of referring primitives too. False, otherweise.

Parameters:
readFull - true if this reader should reads immediate children of referring primitives too. False, otherweise.

getReferringWays

protected DataSet getReferringWays(ProgressMonitor progressMonitor)
                            throws OsmTransferException
Reads referring ways from the API server and replies them in a DataSet

Returns:
the data set
Throws:
OsmTransferException

getReferringRelations

protected DataSet getReferringRelations(ProgressMonitor progressMonitor)
                                 throws OsmTransferException
Reads referring relations from the API server and replies them in a DataSet

Parameters:
progressMonitor - the progress monitor
Returns:
the data set
Throws:
OsmTransferException

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. The method replies the modified dataset.

Parameters:
ds - the original dataset
progressMonitor - the progress monitor
Returns:
the modified dataset
Throws:
OsmTransferException - thrown if an exception occurs.

parseOsm

public DataSet parseOsm(ProgressMonitor progressMonitor)
                 throws OsmTransferException
Reads the referring primitives from the OSM server, parses them and replies them as DataSet

Specified by:
parseOsm in class OsmServerReader
Parameters:
progressMonitor - the progress monitor. Set to NullProgressMonitor.INSTANCE if null.
Returns:
the dataset with the referring primitives
Throws:
OsmTransferException - thrown if an error occurs while communicating with the server


JOSM