Ignore:
Timestamp:
2017-03-09T22:49:28+01:00 (3 years ago)
Author:
bastiK
Message:

fixed #12731 - Add an option to completely prevent upload of a layer : e.g. "never" to upload=true/false

to set this option, add XML attribute upload='never' to .osm file

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

Legend:

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

    r11627 r11709  
    2828import org.openstreetmap.josm.data.osm.Changeset;
    2929import org.openstreetmap.josm.data.osm.DataSet;
     30import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy;
    3031import org.openstreetmap.josm.data.osm.Node;
    3132import org.openstreetmap.josm.data.osm.NodeData;
     
    139140        String upload = parser.getAttributeValue(null, "upload");
    140141        if (upload != null) {
    141             ds.setUploadDiscouraged(!Boolean.parseBoolean(upload));
     142            for (UploadPolicy policy : UploadPolicy.values()) {
     143                if (policy.getXmlFlag().equalsIgnoreCase(upload)) {
     144                    ds.setUploadPolicy(policy);
     145                    break;
     146                }
     147            }
    142148        }
    143149        String generator = parser.getAttributeValue(null, "generator");
  • trunk/src/org/openstreetmap/josm/io/OsmWriter.java

    r11627 r11709  
    1717import org.openstreetmap.josm.data.osm.Changeset;
    1818import org.openstreetmap.josm.data.osm.DataSet;
     19import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy;
    1920import org.openstreetmap.josm.data.osm.INode;
    2021import org.openstreetmap.josm.data.osm.IPrimitive;
     
    7576
    7677    public void header() {
    77         header(null);
    78     }
    79 
    80     public void header(Boolean upload) {
     78        header(UploadPolicy.NORMAL);
     79    }
     80
     81    public void header(UploadPolicy upload) {
    8182        out.println("<?xml version='1.0' encoding='UTF-8'?>");
    8283        out.print("<osm version='");
    8384        out.print(version);
    84         if (upload != null) {
     85        if (upload != null && upload != UploadPolicy.NORMAL) {
    8586            out.print("' upload='");
    86             out.print(upload);
     87            out.print(upload.getXmlFlag());
    8788        }
    8889        out.println("' generator='JOSM'>");
     
    114115
    115116    public void writeLayer(OsmDataLayer layer) {
    116         header(!layer.isUploadDiscouraged());
     117        header(layer.data.getUploadPolicy());
    117118        writeDataSources(layer.data);
    118119        writeContent(layer.data);
Note: See TracChangeset for help on using the changeset viewer.