Changeset 13485 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2018-03-03T16:20:56+01:00 (7 years ago)
Author:
Don-vip
Message:

see #8039, see #10456 - keep layer download/upload/locked flags when saving to .osm file

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmWriter.java

    r13173 r13485  
    1818import org.openstreetmap.josm.data.osm.Changeset;
    1919import org.openstreetmap.josm.data.osm.DataSet;
     20import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
    2021import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy;
    2122import org.openstreetmap.josm.data.osm.INode;
     
    9091    }
    9192
     93    /**
     94     * Writes OSM header with normal download and upload policies.
     95     */
    9296    public void header() {
    93         header(UploadPolicy.NORMAL);
    94     }
    95 
     97        header(DownloadPolicy.NORMAL, UploadPolicy.NORMAL);
     98    }
     99
     100    /**
     101     * Writes OSM header with normal download policy and given upload policy.
     102     * @deprecated Use {@link #header(DownloadPolicy, UploadPolicy)} instead
     103     * @param upload upload policy
     104     */
     105    @Deprecated
    96106    public void header(UploadPolicy upload) {
     107        header(DownloadPolicy.NORMAL, upload);
     108    }
     109
     110    /**
     111     * Writes OSM header with given download upload policies.
     112     * @param download download policy
     113     * @param upload upload policy
     114     * @since 13485
     115     */
     116    public void header(DownloadPolicy download, UploadPolicy upload) {
     117        header(download, upload, false);
     118    }
     119
     120    private void header(DownloadPolicy download, UploadPolicy upload, boolean locked) {
    97121        out.println("<?xml version='1.0' encoding='UTF-8'?>");
    98122        out.print("<osm version='");
    99123        out.print(version);
     124        if (download != null && download != DownloadPolicy.NORMAL) {
     125            out.print("' download='");
     126            out.print(download.getXmlFlag());
     127        }
    100128        if (upload != null && upload != UploadPolicy.NORMAL) {
    101129            out.print("' upload='");
    102130            out.print(upload.getXmlFlag());
    103131        }
     132        if (locked) {
     133            out.print("' locked=true");
     134        }
    104135        out.println("' generator='JOSM'>");
    105136    }
    106137
     138    /**
     139     * Writes OSM footer.
     140     */
    107141    public void footer() {
    108142        out.println("</osm>");
     
    135169     */
    136170    public void write(DataSet data) {
    137         header(data.getUploadPolicy());
     171        header(data.getDownloadPolicy(), data.getUploadPolicy(), data.isLocked());
    138172        writeDataSources(data);
    139173        writeContent(data);
  • trunk/src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java

    r13204 r13485  
    2424import org.openstreetmap.josm.data.coor.LatLon;
    2525import org.openstreetmap.josm.data.osm.DataSet;
     26import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
     27import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy;
    2628import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2729import org.openstreetmap.josm.data.osm.Relation;
     
    158160             OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, ds.getVersion())
    159161            ) {
    160             w.header(DataSet.UploadPolicy.DISCOURAGED);
     162            w.header(DownloadPolicy.NORMAL, UploadPolicy.DISCOURAGED);
    161163            w.writeContent(ds);
    162164            w.footer();
Note: See TracChangeset for help on using the changeset viewer.