Ignore:
Timestamp:
2012-11-18T13:57:36+01:00 (11 years ago)
Author:
bastiK
Message:

drop unnecessary properties for upload to the OSM API in order to save bandwidth

The properties are: user, uid, visible, action and timestamp. In addition drop lat & lon for deleted nodes. (To undelete a primitive, it suffices to include it in a <modify> section, the 'visible' property is ignored by the server.)

File:
1 edited

Legend:

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

    r5497 r5589  
    4040    private boolean osmConform;
    4141    private boolean withBody = true;
     42    private boolean isOsmChange;
    4243    private String version;
    4344    private Changeset changeset;
     
    5556        this.withBody = wb;
    5657    }
     58
     59    public void setIsOsmChange(boolean isOsmChange) {
     60        this.isOsmChange = isOsmChange;
     61    }
     62
    5763    public void setChangeset(Changeset cs) {
    5864        this.changeset = cs;
     
    136142        if (n.isIncomplete()) return;
    137143        addCommon(n, "node");
    138         if (n.getCoor() != null) {
    139             out.print(" lat='"+n.getCoor().lat()+"' lon='"+n.getCoor().lon()+"'");
    140         }
    141144        if (!withBody) {
    142145            out.println("/>");
    143146        } else {
     147            if (n.getCoor() != null) {
     148                out.print(" lat='"+n.getCoor().lat()+"' lon='"+n.getCoor().lon()+"'");
     149            }
    144150            addTags(n, "node", true);
    145151        }
     
    240246        } else
    241247            throw new IllegalStateException(tr("Unexpected id 0 for osm primitive found"));
    242         if (!osmConform) {
    243             String action = null;
    244             if (osm.isDeleted()) {
    245                 action = "delete";
    246             } else if (osm.isModified()) {
    247                 action = "modify";
    248             }
    249             if (action != null) {
    250                 out.print(" action='"+action+"'");
    251             }
    252         }
    253         if (!osm.isTimestampEmpty()) {
    254             out.print(" timestamp='"+DateUtils.fromDate(osm.getTimestamp())+"'");
    255         }
    256         // user and visible added with 0.4 API
    257         if (osm.getUser() != null) {
    258             if(osm.getUser().isLocalUser()) {
    259                 out.print(" user='"+XmlWriter.encode(osm.getUser().getName())+"'");
    260             } else if (osm.getUser().isOsmUser()) {
    261                 // uid added with 0.6
    262                 out.print(" uid='"+ osm.getUser().getId()+"'");
    263                 out.print(" user='"+XmlWriter.encode(osm.getUser().getName())+"'");
    264             }
    265         }
    266         out.print(" visible='"+osm.isVisible()+"'");
     248        if (!isOsmChange) {
     249            if (!osmConform) {
     250                String action = null;
     251                if (osm.isDeleted()) {
     252                    action = "delete";
     253                } else if (osm.isModified()) {
     254                    action = "modify";
     255                }
     256                if (action != null) {
     257                    out.print(" action='"+action+"'");
     258                }
     259            }
     260            if (!osm.isTimestampEmpty()) {
     261                out.print(" timestamp='"+DateUtils.fromDate(osm.getTimestamp())+"'");
     262            }
     263            // user and visible added with 0.4 API
     264            if (osm.getUser() != null) {
     265                if(osm.getUser().isLocalUser()) {
     266                    out.print(" user='"+XmlWriter.encode(osm.getUser().getName())+"'");
     267                } else if (osm.getUser().isOsmUser()) {
     268                    // uid added with 0.6
     269                    out.print(" uid='"+ osm.getUser().getId()+"'");
     270                    out.print(" user='"+XmlWriter.encode(osm.getUser().getName())+"'");
     271                }
     272            }
     273            out.print(" visible='"+osm.isVisible()+"'");
     274        }
    267275        if (osm.getVersion() != 0) {
    268276            out.print(" version='"+osm.getVersion()+"'");
Note: See TracChangeset for help on using the changeset viewer.