public class OsmWriter extends XmlWriter implements PrimitiveVisitor
Modifier and Type | Field and Description |
---|---|
protected static Comparator<AbstractPrimitive> |
byIdComparator
Sorts
-1 → -infinity , then +1 → +infinity |
protected static Comparator<Map.Entry<String,String>> |
byKeyComparator |
private Changeset |
changeset |
static String |
DEFAULT_API_VERSION
Default OSM API version
|
private boolean |
isOsmChange |
private boolean |
osmConform |
private String |
version |
private boolean |
withBody |
private boolean |
withVisible |
Modifier | Constructor and Description |
---|---|
protected |
OsmWriter(PrintWriter out,
boolean osmConform,
String version)
Constructs a new
OsmWriter . |
Modifier and Type | Method and Description |
---|---|
protected void |
addCommon(IPrimitive osm,
String tagname)
Add the common part as the form of the tag as well as the XML attributes
id, action, user, and visible.
|
protected void |
addTags(Tagged osm,
String tagname,
boolean tagOpen) |
void |
footer()
Writes OSM footer.
|
void |
header()
Writes OSM header with normal download and upload policies.
|
void |
header(DownloadPolicy download,
UploadPolicy upload)
Writes OSM header with given download upload policies.
|
private void |
header(DownloadPolicy download,
UploadPolicy upload,
boolean locked) |
void |
setChangeset(Changeset cs) |
void |
setIsOsmChange(boolean isOsmChange) |
void |
setVersion(String v) |
void |
setWithBody(boolean wb)
Sets whether body must be written.
|
void |
setWithVisible(boolean wv)
Sets whether 'visible' attribute must be written.
|
protected boolean |
shouldWrite(OsmPrimitive osm) |
protected <T extends OsmPrimitive> |
sortById(Collection<T> primitives) |
void |
visit(Changeset cs)
Visiting call for changesets.
|
void |
visit(INode n)
Visiting call for nodes.
|
void |
visit(IRelation<?> e)
Visiting call for relations.
|
void |
visit(IWay<?> w)
Visiting call for ways.
|
void |
write(DataSet data)
Writes the full OSM file for the given data set (header, data sources, osm data, footer).
|
void |
writeContent(DataSet ds)
Writes the contents of the given dataset (nodes, then ways, then relations)
|
void |
writeDataSources(DataSet ds)
Writes data sources with their respective bounds.
|
(package private) void |
writeLatLon(LatLon ll) |
void |
writeNodes(Collection<Node> nodes)
Writes the given nodes sorted by id
|
void |
writeRelations(Collection<Relation> relations)
Writes the given relations sorted by id
|
void |
writeWays(Collection<Way> ways)
Writes the given ways sorted by id
|
public static final String DEFAULT_API_VERSION
private final boolean osmConform
private boolean withBody
private boolean withVisible
private boolean isOsmChange
protected static final Comparator<AbstractPrimitive> byIdComparator
-1
→ -infinity
, then +1
→ +infinity
protected static final Comparator<Map.Entry<String,String>> byKeyComparator
protected OsmWriter(PrintWriter out, boolean osmConform, String version)
OsmWriter
.
Do not call this directly. Use OsmWriterFactory
instead.out
- print writerosmConform
- if true
, prevents modification attributes to be written to the common partversion
- OSM API version (0.6)public void setWithBody(boolean wb)
wb
- if true
body will be written.public void setWithVisible(boolean wv)
wv
- if true
'visible' attribute will be written.public void setIsOsmChange(boolean isOsmChange)
public void setChangeset(Changeset cs)
public void setVersion(String v)
public void header()
public void header(DownloadPolicy download, UploadPolicy upload)
download
- download policyupload
- upload policyprivate void header(DownloadPolicy download, UploadPolicy upload, boolean locked)
public void footer()
protected <T extends OsmPrimitive> Collection<T> sortById(Collection<T> primitives)
public void write(DataSet data)
data
- OSM data setpublic void writeContent(DataSet ds)
ds
- The dataset to writepublic void writeNodes(Collection<Node> nodes)
nodes
- The nodes to writepublic void writeWays(Collection<Way> ways)
ways
- The ways to writepublic void writeRelations(Collection<Relation> relations)
relations
- The relations to writeprotected boolean shouldWrite(OsmPrimitive osm)
public void writeDataSources(DataSet ds)
ds
- data setvoid writeLatLon(LatLon ll)
public void visit(INode n)
PrimitiveVisitor
visit
in interface PrimitiveVisitor
n
- The node to inspect.public void visit(IWay<?> w)
PrimitiveVisitor
visit
in interface PrimitiveVisitor
w
- The way to inspect.public void visit(IRelation<?> e)
PrimitiveVisitor
visit
in interface PrimitiveVisitor
e
- The relation to inspect.protected void addCommon(IPrimitive osm, String tagname)
osm
- osm primitivetagname
- XML tag matching osm primitive (node, way, relation)