Ticket #4083: CopyIncompleteNodesException.patch
File CopyIncompleteNodesException.patch, 4.9 KB (added by , 14 years ago) |
---|
-
src/org/openstreetmap/josm/data/osm/Node.java
135 135 @Override public NodeData save() { 136 136 NodeData data = new NodeData(); 137 137 saveCommonAttributes(data); 138 data.setCoor(getCoor()); 138 if (!isIncomplete()) { 139 data.setCoor(getCoor()); 140 } 139 141 return data; 140 142 } 141 143 -
src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
102 102 private static final int FLAG_FILTERED = 1 << 4; 103 103 private static final int FLAG_HAS_DIRECTIONS = 1 << 5; 104 104 private static final int FLAG_TAGGED = 1 << 6; 105 private static final int FLAG_INCOMPLETE = 1 << 7; 105 106 106 107 /** 107 108 * Replies the sub-collection of {@see OsmPrimitive}s of type <code>type</code> present in … … 225 226 private User user = null; 226 227 227 228 /** 228 * If set to true, this object is incomplete, which means only the id229 * and type is known (type is the objects instance class)230 */231 private boolean incomplete = false;232 233 /**234 229 * Contains the version number as returned by the API. Needed to 235 230 * ensure update consistency 236 231 */ … … 390 385 } 391 386 392 387 /** 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 /** 393 411 * Replies the version number as returned by the API. The version is 0 if the id is 0 or 394 412 * if this primitive is incomplete. 395 413 * … … 915 933 id = osm.id; 916 934 timestamp = osm.timestamp; 917 935 version = osm.version; 918 setIncomplete(osm.isIncomplete());919 936 flags = osm.flags; 920 937 user= osm.user; 921 938 clearCached(); … … 942 959 setKeys(other.getKeys()); 943 960 timestamp = other.timestamp; 944 961 version = other.version; 945 setIncomplete(other.isIncomplete());946 962 flags = other.flags; 947 963 user= other.user; 948 964 } … … 1095 1111 setDeleted(data.isDeleted()); 1096 1112 setModified(data.isModified()); 1097 1113 setVisible(data.isVisible()); 1114 setIncomplete(data.isIncomplete()); 1098 1115 } 1099 1116 1100 1117 /** … … 1112 1129 data.setDeleted(isDeleted()); 1113 1130 data.setModified(isModified()); 1114 1131 data.setVisible(isVisible()); 1132 data.setIncomplete(isIncomplete()); 1115 1133 } 1116 1134 1117 1135 protected String getFlagsAsString() { … … 1157 1175 return new SimplePrimitiveId(getUniqueId(), getType()); 1158 1176 } 1159 1177 1160 //TODO This method should not be necessary, incomplete state should be handled internally by OsmPrimitive1161 public void setIncomplete(boolean incomplete) {1162 this.incomplete = incomplete;1163 }1164 1178 1165 public boolean isIncomplete() { 1166 return incomplete; 1167 } 1179 1180 1181 1182 1183 1184 1185 1168 1186 } -
src/org/openstreetmap/josm/data/osm/PrimitiveData.java
35 35 this.user = data.user; 36 36 this.version = data.version; 37 37 this.timestamp = data.timestamp; 38 this.incomplete = data.incomplete; 38 39 } 39 40 40 41 private final Map<String, String> keys = new HashMap<String, String>(); 41 42 private boolean modified; 42 43 private boolean visible = true; 43 44 private boolean deleted; 45 private boolean incomplete; 44 46 private long id; 45 47 private User user; 46 48 private int version; … … 91 93 public Map<String, String> getKeys() { 92 94 return keys; 93 95 } 96 public boolean isIncomplete() { 97 return incomplete; 98 } 99 public void setIncomplete(boolean incomplete) { 100 this.incomplete = incomplete; 101 } 94 102 95 103 public void clearOsmId() { 96 104 id = OsmPrimitive.generateUniqueId(); … … 112 120 if (deleted) { 113 121 builder.append("D"); 114 122 } 123 if (incomplete) { 124 builder.append("I"); 125 } 115 126 116 127 return builder.toString(); 117 128 }