Package org.openstreetmap.josm.io
Class AbstractReader
- java.lang.Object
-
- org.openstreetmap.josm.io.AbstractReader
-
- Direct Known Subclasses:
GeoJSONReader
,OsmJsonReader
,OsmPbfReader
,OsmReader
public abstract class AbstractReader extends java.lang.Object
Abstract Reader, allowing other implementations than OsmReader (PbfReader in PBF plugin for example)- Since:
- 4490
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
AbstractReader.BinaryParserWorker
An interface for reading binary dataprotected static interface
AbstractReader.CommonReader
protected static interface
AbstractReader.NodeReader
protected static interface
AbstractReader.ParserWorker
protected static interface
AbstractReader.RelationReader
protected static interface
AbstractReader.WayReader
-
Field Summary
Fields Modifier and Type Field Description protected boolean
cancel
protected DataSet
ds
The dataset to add parsed objects to.protected java.util.Map<PrimitiveId,OsmPrimitive>
externalIdMap
the map from external ids to read OsmPrimitives.private static java.util.List<OsmServerReadPostprocessor>
postprocessors
Used by plugins to register themselves as data postprocessors.protected java.util.Map<java.lang.Long,java.util.Collection<RelationMemberData>>
relations
Data structure for relation objectsprivate java.util.Map<java.lang.String,java.lang.String>
tagMap
A lookup table to avoid callingString.intern()
unnecessarily.private java.util.Map<java.lang.String,java.lang.Integer>
timestampCache
protected Changeset
uploadChangeset
protected java.util.Map<java.lang.Long,java.util.Collection<java.lang.Long>>
ways
Data structure for the remaining way objects
-
Constructor Summary
Constructors Constructor Description AbstractReader()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private Node
addNode(NodeData nd, AbstractReader.NodeReader nodeReader)
private static boolean
areLatLonDefined(double lat, double lon)
private static boolean
areLatLonDefined(java.lang.String lat, java.lang.String lon)
protected OsmPrimitive
buildPrimitive(PrimitiveData pd)
protected void
callPostProcessors(ProgressMonitor progressMonitor)
Iterate over registered postprocessors and give them each a chance to modify the dataset we have just loaded.private static User
createUser(java.lang.String uid, java.lang.String name)
static void
deregisterPostprocessor(OsmServerReadPostprocessor pp)
Deregister a postprocessor previously registered withregisterPostprocessor(org.openstreetmap.josm.io.OsmServerReadPostprocessor)
.protected abstract DataSet
doParseDataSet(java.io.InputStream source, ProgressMonitor progressMonitor)
private DataSet
doParseDataSet(java.io.InputStream source, ProgressMonitor progressMonitor, java.lang.Object parserWorker)
protected DataSet
doParseDataSet(java.io.InputStream source, ProgressMonitor progressMonitor, AbstractReader.BinaryParserWorker parserWorker)
protected DataSet
doParseDataSet(java.io.InputStream source, ProgressMonitor progressMonitor, AbstractReader.ParserWorker parserWorker)
DataSet
getDataSet()
Replies the parsed data setprotected long
getLong(java.lang.String name, java.lang.String value)
private static void
handleIllegalChangeset(PrimitiveData current, java.lang.IllegalArgumentException e, java.lang.Object v)
protected void
parseAction(PrimitiveData current, java.lang.String action)
protected void
parseBounds(java.lang.String generator, java.lang.String minlon, java.lang.String minlat, java.lang.String maxlon, java.lang.String maxlat, java.lang.String origin)
protected void
parseChangeset(PrimitiveData current, int v)
protected void
parseChangeset(PrimitiveData current, java.lang.String v)
protected void
parseDownloadPolicy(java.lang.String key, java.lang.String downloadPolicy)
protected void
parseId(PrimitiveData current, long id)
protected void
parseLocked(java.lang.String locked)
protected Node
parseNode(double lat, double lon, AbstractReader.CommonReader commonReader, AbstractReader.NodeReader nodeReader)
protected Node
parseNode(java.lang.String lat, java.lang.String lon, AbstractReader.CommonReader commonReader, AbstractReader.NodeReader nodeReader)
private static void
parsePolicy(java.lang.String key, java.lang.String policy, java.util.function.Consumer<java.lang.String> consumer)
protected Relation
parseRelation(AbstractReader.CommonReader commonReader, AbstractReader.RelationReader relationReader)
protected RelationMemberData
parseRelationMember(RelationData r, long id, java.lang.String type, java.lang.String role)
protected RelationMemberData
parseRelationMember(RelationData r, java.lang.String ref, java.lang.String type, java.lang.String role)
protected void
parseTag(Tagged t, java.lang.String key, java.lang.String value)
protected void
parseTimestamp(PrimitiveData current, java.lang.String time)
protected void
parseUploadPolicy(java.lang.String key, java.lang.String uploadPolicy)
protected void
parseUser(PrimitiveData current, java.lang.String user, long uid)
protected void
parseUser(PrimitiveData current, java.lang.String user, java.lang.String uid)
protected void
parseVersion(java.lang.String version)
protected void
parseVersion(PrimitiveData current, int version)
protected void
parseVersion(PrimitiveData current, java.lang.String versionString)
protected void
parseVisible(PrimitiveData current, java.lang.String visible)
protected Way
parseWay(AbstractReader.CommonReader commonReader, AbstractReader.WayReader wayReader)
protected void
prepareDataSet()
protected void
processChangesetAfterParsing()
protected void
processNodesAfterParsing()
Processes the parsed nodes after parsing.protected void
processRelationsAfterParsing()
Completes the parsed relations with its members.protected void
processWaysAfterParsing()
Processes the ways after parsing.static void
registerPostprocessor(OsmServerReadPostprocessor pp)
Register a new postprocessor.private static void
validateVersion(java.lang.String version)
-
-
-
Field Detail
-
postprocessors
private static volatile java.util.List<OsmServerReadPostprocessor> postprocessors
Used by plugins to register themselves as data postprocessors.
-
cancel
protected boolean cancel
-
tagMap
private final java.util.Map<java.lang.String,java.lang.String> tagMap
A lookup table to avoid callingString.intern()
unnecessarily.
-
uploadChangeset
protected Changeset uploadChangeset
-
externalIdMap
protected final java.util.Map<PrimitiveId,OsmPrimitive> externalIdMap
the map from external ids to read OsmPrimitives. External ids are longs too, but in contrast to internal ids negative values are used to identify primitives unknown to the OSM server
-
ways
protected final java.util.Map<java.lang.Long,java.util.Collection<java.lang.Long>> ways
Data structure for the remaining way objects
-
relations
protected final java.util.Map<java.lang.Long,java.util.Collection<RelationMemberData>> relations
Data structure for relation objects
-
timestampCache
private final java.util.Map<java.lang.String,java.lang.Integer> timestampCache
-
-
Constructor Detail
-
AbstractReader
public AbstractReader()
-
-
Method Detail
-
registerPostprocessor
public static void registerPostprocessor(OsmServerReadPostprocessor pp)
Register a new postprocessor.- Parameters:
pp
- postprocessor- Since:
- 14119 (moved from OsmReader)
- See Also:
deregisterPostprocessor(org.openstreetmap.josm.io.OsmServerReadPostprocessor)
-
deregisterPostprocessor
public static void deregisterPostprocessor(OsmServerReadPostprocessor pp)
Deregister a postprocessor previously registered withregisterPostprocessor(org.openstreetmap.josm.io.OsmServerReadPostprocessor)
.- Parameters:
pp
- postprocessor- Since:
- 14119 (moved from OsmReader)
- See Also:
registerPostprocessor(org.openstreetmap.josm.io.OsmServerReadPostprocessor)
-
getDataSet
public DataSet getDataSet()
Replies the parsed data set- Returns:
- the parsed data set
-
callPostProcessors
protected void callPostProcessors(ProgressMonitor progressMonitor)
Iterate over registered postprocessors and give them each a chance to modify the dataset we have just loaded.- Parameters:
progressMonitor
- Progress monitor
-
processNodesAfterParsing
protected void processNodesAfterParsing()
Processes the parsed nodes after parsing. Just adds them to the dataset
-
processWaysAfterParsing
protected void processWaysAfterParsing() throws IllegalDataException
Processes the ways after parsing. Rebuilds the list of nodes of each way and adds the way to the dataset- Throws:
IllegalDataException
- if a data integrity problem is detected
-
processRelationsAfterParsing
protected void processRelationsAfterParsing() throws IllegalDataException
Completes the parsed relations with its members.- Throws:
IllegalDataException
- if a data integrity problem is detected, i.e. if a relation member refers to a local primitive which wasn't available in the data
-
processChangesetAfterParsing
protected void processChangesetAfterParsing()
-
prepareDataSet
protected final void prepareDataSet() throws IllegalDataException
- Throws:
IllegalDataException
-
doParseDataSet
protected abstract DataSet doParseDataSet(java.io.InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException
- Throws:
IllegalDataException
-
doParseDataSet
protected final DataSet doParseDataSet(java.io.InputStream source, ProgressMonitor progressMonitor, AbstractReader.BinaryParserWorker parserWorker) throws IllegalDataException
- Throws:
IllegalDataException
-
doParseDataSet
protected final DataSet doParseDataSet(java.io.InputStream source, ProgressMonitor progressMonitor, AbstractReader.ParserWorker parserWorker) throws IllegalDataException
- Throws:
IllegalDataException
-
doParseDataSet
private DataSet doParseDataSet(java.io.InputStream source, ProgressMonitor progressMonitor, java.lang.Object parserWorker) throws IllegalDataException
- Throws:
IllegalDataException
-
getLong
protected final long getLong(java.lang.String name, java.lang.String value) throws IllegalDataException
- Throws:
IllegalDataException
-
parseVersion
protected final void parseVersion(java.lang.String version) throws IllegalDataException
- Throws:
IllegalDataException
-
validateVersion
private static void validateVersion(java.lang.String version) throws IllegalDataException
- Throws:
IllegalDataException
-
parseDownloadPolicy
protected final void parseDownloadPolicy(java.lang.String key, java.lang.String downloadPolicy) throws IllegalDataException
- Throws:
IllegalDataException
-
parseUploadPolicy
protected final void parseUploadPolicy(java.lang.String key, java.lang.String uploadPolicy) throws IllegalDataException
- Throws:
IllegalDataException
-
parsePolicy
private static void parsePolicy(java.lang.String key, java.lang.String policy, java.util.function.Consumer<java.lang.String> consumer) throws IllegalDataException
- Throws:
IllegalDataException
-
parseLocked
protected final void parseLocked(java.lang.String locked)
-
parseBounds
protected final void parseBounds(java.lang.String generator, java.lang.String minlon, java.lang.String minlat, java.lang.String maxlon, java.lang.String maxlat, java.lang.String origin) throws IllegalDataException
- Throws:
IllegalDataException
-
parseId
protected final void parseId(PrimitiveData current, long id) throws IllegalDataException
- Throws:
IllegalDataException
-
parseTimestamp
protected final void parseTimestamp(PrimitiveData current, java.lang.String time)
-
createUser
private static User createUser(java.lang.String uid, java.lang.String name) throws IllegalDataException
- Throws:
IllegalDataException
-
parseUser
protected final void parseUser(PrimitiveData current, java.lang.String user, long uid)
-
parseUser
protected final void parseUser(PrimitiveData current, java.lang.String user, java.lang.String uid) throws IllegalDataException
- Throws:
IllegalDataException
-
parseVisible
protected final void parseVisible(PrimitiveData current, java.lang.String visible)
-
parseVersion
protected final void parseVersion(PrimitiveData current, java.lang.String versionString) throws IllegalDataException
- Throws:
IllegalDataException
-
parseVersion
protected final void parseVersion(PrimitiveData current, int version) throws IllegalDataException
- Throws:
IllegalDataException
-
parseAction
protected final void parseAction(PrimitiveData current, java.lang.String action)
-
handleIllegalChangeset
private static void handleIllegalChangeset(PrimitiveData current, java.lang.IllegalArgumentException e, java.lang.Object v) throws IllegalDataException
- Throws:
IllegalDataException
-
parseChangeset
protected final void parseChangeset(PrimitiveData current, java.lang.String v) throws IllegalDataException
- Throws:
IllegalDataException
-
parseChangeset
protected final void parseChangeset(PrimitiveData current, int v) throws IllegalDataException
- Throws:
IllegalDataException
-
parseTag
protected final void parseTag(Tagged t, java.lang.String key, java.lang.String value) throws IllegalDataException
- Throws:
IllegalDataException
-
areLatLonDefined
private static boolean areLatLonDefined(java.lang.String lat, java.lang.String lon)
-
areLatLonDefined
private static boolean areLatLonDefined(double lat, double lon)
-
buildPrimitive
protected OsmPrimitive buildPrimitive(PrimitiveData pd)
-
addNode
private Node addNode(NodeData nd, AbstractReader.NodeReader nodeReader) throws IllegalDataException
- Throws:
IllegalDataException
-
parseNode
protected final Node parseNode(double lat, double lon, AbstractReader.CommonReader commonReader, AbstractReader.NodeReader nodeReader) throws IllegalDataException
- Throws:
IllegalDataException
-
parseNode
protected final Node parseNode(java.lang.String lat, java.lang.String lon, AbstractReader.CommonReader commonReader, AbstractReader.NodeReader nodeReader) throws IllegalDataException
- Throws:
IllegalDataException
-
parseWay
protected final Way parseWay(AbstractReader.CommonReader commonReader, AbstractReader.WayReader wayReader) throws IllegalDataException
- Throws:
IllegalDataException
-
parseRelation
protected final Relation parseRelation(AbstractReader.CommonReader commonReader, AbstractReader.RelationReader relationReader) throws IllegalDataException
- Throws:
IllegalDataException
-
parseRelationMember
protected final RelationMemberData parseRelationMember(RelationData r, java.lang.String ref, java.lang.String type, java.lang.String role) throws IllegalDataException
- Throws:
IllegalDataException
-
parseRelationMember
protected final RelationMemberData parseRelationMember(RelationData r, long id, java.lang.String type, java.lang.String role) throws IllegalDataException
- Throws:
IllegalDataException
-
-