Package org.openstreetmap.josm.io
Class OsmWriter
java.lang.Object
org.openstreetmap.josm.io.XmlWriter
org.openstreetmap.josm.io.OsmWriter
- All Implemented Interfaces:
Closeable,AutoCloseable,PrimitiveVisitor
Save the dataset into a stream as osm intern xml format. This is not using any xml library for storing.
- Since:
- 59
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Comparator<AbstractPrimitive>Sorts-1→-infinity, then+1→+infinityprotected static final Comparator<Map.Entry<String,String>> private Changesetstatic final StringDefault OSM API versionprivate booleanprivate final booleanprivate Stringprivate booleanprivate boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOsmWriter(PrintWriter out, boolean osmConform, String version) Constructs a newOsmWriter. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCommon(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 voidvoidfooter()Writes OSM footer.voidheader()Writes OSM header with normal download and upload policies.voidheader(DownloadPolicy download, UploadPolicy upload) Writes OSM header with given download upload policies.private voidheader(DownloadPolicy download, UploadPolicy upload, boolean locked) voidvoidsetIsOsmChange(boolean isOsmChange) voidsetVersion(String v) voidsetWithBody(boolean wb) Sets whether body must be written.voidsetWithVisible(boolean wv) Sets whether 'visible' attribute must be written.protected booleanshouldWrite(OsmPrimitive osm) protected <T extends OsmPrimitive>
Collection<T>sortById(Collection<T> primitives) voidVisiting call for changesets.voidVisiting call for nodes.voidVisiting call for relations.voidVisiting call for ways.voidWrites the full OSM file for the given data set (header, data sources, osm data, footer).voidwriteContent(DataSet ds) Writes the contents of the given dataset (nodes, then ways, then relations)voidWrites data sources with their respective bounds.(package private) voidwriteLatLon(LatLon ll) voidwriteNodes(Collection<Node> nodes) Writes the given nodes sorted by idvoidwriteRelations(Collection<Relation> relations) Writes the given relations sorted by idvoidwriteWays(Collection<Way> ways) Writes the given ways sorted by id
-
Field Details
-
DEFAULT_API_VERSION
Default OSM API version- See Also:
-
osmConform
-
withBody
-
withVisible
-
isOsmChange
-
version
-
changeset
-
byIdComparator
Sorts-1→-infinity, then+1→+infinity -
byKeyComparator
-
-
Constructor Details
-
OsmWriter
Constructs a newOsmWriter. Do not call this directly. UseOsmWriterFactoryinstead.- Parameters:
out- print writerosmConform- iftrue, prevents modification attributes to be written to the common partversion- OSM API version (0.6)
-
-
Method Details
-
setWithBody
Sets whether body must be written.- Parameters:
wb- iftruebody will be written.
-
setWithVisible
Sets whether 'visible' attribute must be written.- Parameters:
wv- iftrue'visible' attribute will be written.- Since:
- 12019
-
setIsOsmChange
-
setChangeset
-
setVersion
-
header
Writes OSM header with normal download and upload policies. -
header
Writes OSM header with given download upload policies.- Parameters:
download- download policyupload- upload policy- Since:
- 13485
-
header
-
sortById
-
write
Writes the full OSM file for the given data set (header, data sources, osm data, footer).- Parameters:
data- OSM data set- Since:
- 12800
-
writeContent
Writes the contents of the given dataset (nodes, then ways, then relations)- Parameters:
ds- The dataset to write
-
writeNodes
Writes the given nodes sorted by id- Parameters:
nodes- The nodes to write- Since:
- 5737
-
writeWays
Writes the given ways sorted by id- Parameters:
ways- The ways to write- Since:
- 5737
-
writeRelations
Writes the given relations sorted by id- Parameters:
relations- The relations to write- Since:
- 5737
-
shouldWrite
-
writeDataSources
Writes data sources with their respective bounds.- Parameters:
ds- data set
-
writeLatLon
-
visit
Description copied from interface:PrimitiveVisitorVisiting call for nodes.- Specified by:
visitin interfacePrimitiveVisitor- Parameters:
n- The node to inspect.
-
visit
Description copied from interface:PrimitiveVisitorVisiting call for ways.- Specified by:
visitin interfacePrimitiveVisitor- Parameters:
w- The way to inspect.
-
visit
Description copied from interface:PrimitiveVisitorVisiting call for relations.- Specified by:
visitin interfacePrimitiveVisitor- Parameters:
e- The relation to inspect.
-
visit
Visiting call for changesets.- Parameters:
cs- changeset
-
addTags
-
addCommon
Add the common part as the form of the tag as well as the XML attributes id, action, user, and visible.- Parameters:
osm- osm primitivetagname- XML tag matching osm primitive (node, way, relation)
-