Class OsmWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, PrimitiveVisitor

    public class OsmWriter
    extends XmlWriter
    implements PrimitiveVisitor
    Save the dataset into a stream as osm intern xml format. This is not using any xml library for storing.
    Since:
    59
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected OsmWriter​(java.io.PrintWriter out, boolean osmConform, java.lang.String version)
      Constructs a new OsmWriter.
    • Constructor Detail

      • OsmWriter

        protected OsmWriter​(java.io.PrintWriter out,
                            boolean osmConform,
                            java.lang.String version)
        Constructs a new OsmWriter. Do not call this directly. Use OsmWriterFactory instead.
        Parameters:
        out - print writer
        osmConform - if true, prevents modification attributes to be written to the common part
        version - OSM API version (0.6)
    • Method Detail

      • setWithBody

        public void setWithBody​(boolean wb)
        Sets whether body must be written.
        Parameters:
        wb - if true body will be written.
      • setWithVisible

        public void setWithVisible​(boolean wv)
        Sets whether 'visible' attribute must be written.
        Parameters:
        wv - if true 'visible' attribute will be written.
        Since:
        12019
      • setIsOsmChange

        public void setIsOsmChange​(boolean isOsmChange)
      • setVersion

        public void setVersion​(java.lang.String v)
      • header

        public void header()
        Writes OSM header with normal download and upload policies.
      • header

        public void header​(DownloadPolicy download,
                           UploadPolicy upload)
        Writes OSM header with given download upload policies.
        Parameters:
        download - download policy
        upload - upload policy
        Since:
        13485
      • footer

        public void footer()
        Writes OSM footer.
      • sortById

        protected <T extends OsmPrimitive> java.util.Collection<T> sortById​(java.util.Collection<T> primitives)
      • write

        public void write​(DataSet data)
        Writes the full OSM file for the given data set (header, data sources, osm data, footer).
        Parameters:
        data - OSM data set
        Since:
        12800
      • writeContent

        public void writeContent​(DataSet ds)
        Writes the contents of the given dataset (nodes, then ways, then relations)
        Parameters:
        ds - The dataset to write
      • writeNodes

        public void writeNodes​(java.util.Collection<Node> nodes)
        Writes the given nodes sorted by id
        Parameters:
        nodes - The nodes to write
        Since:
        5737
      • writeWays

        public void writeWays​(java.util.Collection<Way> ways)
        Writes the given ways sorted by id
        Parameters:
        ways - The ways to write
        Since:
        5737
      • writeRelations

        public void writeRelations​(java.util.Collection<Relation> relations)
        Writes the given relations sorted by id
        Parameters:
        relations - The relations to write
        Since:
        5737
      • writeDataSources

        public void writeDataSources​(DataSet ds)
        Writes data sources with their respective bounds.
        Parameters:
        ds - data set
      • visit

        public void visit​(Changeset cs)
        Visiting call for changesets.
        Parameters:
        cs - changeset
      • addTags

        protected void addTags​(Tagged osm,
                               java.lang.String tagname,
                               boolean tagOpen)
      • addCommon

        protected void addCommon​(IPrimitive osm,
                                 java.lang.String tagname)
        Add the common part as the form of the tag as well as the XML attributes id, action, user, and visible.
        Parameters:
        osm - osm primitive
        tagname - XML tag matching osm primitive (node, way, relation)