Ticket #4083: CopyIncompleteNodesException.patch

File CopyIncompleteNodesException.patch, 4.9 KB (added by mjulius, 14 years ago)
  • src/org/openstreetmap/josm/data/osm/Node.java

     
    135135    @Override public NodeData save() {
    136136        NodeData data = new NodeData();
    137137        saveCommonAttributes(data);
    138         data.setCoor(getCoor());
     138        if (!isIncomplete()) {
     139            data.setCoor(getCoor());
     140        }
    139141        return data;
    140142    }
    141143
  • src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

     
    102102    private static final int FLAG_FILTERED = 1 << 4;
    103103    private static final int FLAG_HAS_DIRECTIONS = 1 << 5;
    104104    private static final int FLAG_TAGGED = 1 << 6;
     105    private static final int FLAG_INCOMPLETE = 1 << 7;
    105106
    106107    /**
    107108     * Replies the sub-collection of {@see OsmPrimitive}s of type <code>type</code> present in
     
    225226    private User user = null;
    226227
    227228    /**
    228      * If set to true, this object is incomplete, which means only the id
    229      * and type is known (type is the objects instance class)
    230      */
    231     private boolean incomplete = false;
    232 
    233     /**
    234229     * Contains the version number as returned by the API. Needed to
    235230     * ensure update consistency
    236231     */
     
    390385    }
    391386
    392387    /**
     388     * Sets whether this primitive is incomplete (e.g. only id and type are known) or not.
     389     *
     390     * @param incomplete true, if this primitive is incomplete; false, otherwise
     391     */
     392    public void setIncomplete(boolean incomplete) {
     393        if (incomplete) {
     394            flags |= FLAG_INCOMPLETE;
     395        } else {
     396            flags &= ~FLAG_INCOMPLETE;
     397        }
     398    }
     399
     400    /**
     401     * Returns <code>true</code>, if the object is incomplete (e.g. only id and type are known).
     402     *
     403     * @return <code>true</code>, if the object is incomplete.
     404     * @see #setDeleted(boolean)
     405     */
     406    public boolean isIncomplete() {
     407        return (flags & FLAG_INCOMPLETE) != 0;
     408    }
     409
     410    /**
    393411     * Replies the version number as returned by the API. The version is 0 if the id is 0 or
    394412     * if this primitive is incomplete.
    395413     *
     
    915933        id = osm.id;
    916934        timestamp = osm.timestamp;
    917935        version = osm.version;
    918         setIncomplete(osm.isIncomplete());
    919936        flags = osm.flags;
    920937        user= osm.user;
    921938        clearCached();
     
    942959        setKeys(other.getKeys());
    943960        timestamp = other.timestamp;
    944961        version = other.version;
    945         setIncomplete(other.isIncomplete());
    946962        flags = other.flags;
    947963        user= other.user;
    948964    }
     
    10951111        setDeleted(data.isDeleted());
    10961112        setModified(data.isModified());
    10971113        setVisible(data.isVisible());
     1114        setIncomplete(data.isIncomplete());
    10981115    }
    10991116
    11001117    /**
     
    11121129        data.setDeleted(isDeleted());
    11131130        data.setModified(isModified());
    11141131        data.setVisible(isVisible());
     1132        data.setIncomplete(isIncomplete());
    11151133    }
    11161134
    11171135    protected String getFlagsAsString() {
     
    11571175        return new SimplePrimitiveId(getUniqueId(), getType());
    11581176    }
    11591177
    1160     //TODO This method should not be necessary, incomplete state should be handled internally by OsmPrimitive
    1161     public void setIncomplete(boolean incomplete) {
    1162         this.incomplete = incomplete;
    1163     }
    11641178
    1165     public boolean isIncomplete() {
    1166         return incomplete;
    1167     }
     1179
     1180
     1181
     1182
     1183
     1184
     1185
    11681186}
  • src/org/openstreetmap/josm/data/osm/PrimitiveData.java

     
    3535        this.user = data.user;
    3636        this.version = data.version;
    3737        this.timestamp = data.timestamp;
     38        this.incomplete = data.incomplete;
    3839    }
    3940
    4041    private final Map<String, String> keys = new HashMap<String, String>();
    4142    private boolean modified;
    4243    private boolean visible = true;
    4344    private boolean deleted;
     45    private boolean incomplete;
    4446    private long id;
    4547    private User user;
    4648    private int version;
     
    9193    public Map<String, String> getKeys() {
    9294        return keys;
    9395    }
     96    public boolean isIncomplete() {
     97        return incomplete;
     98    }
     99    public void setIncomplete(boolean incomplete) {
     100        this.incomplete = incomplete;
     101    }
    94102
    95103    public void clearOsmId() {
    96104        id = OsmPrimitive.generateUniqueId();
     
    112120        if (deleted) {
    113121            builder.append("D");
    114122        }
     123        if (incomplete) {
     124            builder.append("I");
     125        }
    115126
    116127        return builder.toString();
    117128    }