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 |
private boolean |
isOsmChange |
private boolean |
osmConform |
private String |
version |
private boolean |
withBody |
| 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() |
void |
header() |
void |
header(Boolean upload) |
void |
setChangeset(Changeset cs) |
void |
setIsOsmChange(boolean isOsmChange) |
void |
setVersion(String v) |
void |
setWithBody(boolean wb) |
protected boolean |
shouldWrite(OsmPrimitive osm) |
protected <T extends OsmPrimitive> |
sortById(Collection<T> primitives) |
void |
visit(Changeset cs) |
void |
visit(INode n)
Visiting call for points.
|
void |
visit(IRelation e)
Visiting call for relations.
|
void |
visit(IWay w)
Visiting call for lines.
|
void |
writeContent(DataSet ds)
Writes the contents of the given dataset (nodes, then ways, then relations)
|
void |
writeDataSources(DataSet ds) |
void |
writeLayer(OsmDataLayer layer) |
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 isOsmChange
protected static final Comparator<AbstractPrimitive> byIdComparator
-1 → -infinity, then +1 → +infinityprotected 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)
public void setIsOsmChange(boolean isOsmChange)
public void setChangeset(Changeset cs)
public void setVersion(String v)
public void header()
public void footer()
protected <T extends OsmPrimitive> Collection<T> sortById(Collection<T> primitives)
public void writeLayer(OsmDataLayer layer)
public 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)
public void visit(INode n)
PrimitiveVisitorvisit in interface PrimitiveVisitorn - The node to inspect.public void visit(IWay w)
PrimitiveVisitorvisit in interface PrimitiveVisitorw - The way to inspect.public void visit(IRelation e)
PrimitiveVisitorvisit in interface PrimitiveVisitore - The relation to inspect.protected void addCommon(IPrimitive osm, String tagname)
osm - osm primitivetagname - XML tag matching osm primitive (node, way, relation)