Changeset 5589 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-11-18T13:57:36+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/APIDataSet.java
r5266 r5589 55 55 public void init(DataSet ds) { 56 56 if (ds == null) return; 57 init(ds.allPrimitives()); 58 } 59 60 public void init(Collection<OsmPrimitive> primitives) { 57 61 toAdd.clear(); 58 62 toUpdate.clear(); 59 63 toDelete.clear(); 60 64 61 for (OsmPrimitive osm : ds.allPrimitives()) {65 for (OsmPrimitive osm :primitives) { 62 66 if (osm.get("josm/ignore") != null) { 63 67 continue; … … 140 144 public APIDataSet(Collection<OsmPrimitive> primitives) { 141 145 this(); 142 toAdd.clear(); 143 toUpdate.clear(); 144 toDelete.clear(); 145 for (OsmPrimitive osm: primitives) { 146 if (osm.isNewOrUndeleted() && !osm.isDeleted()) { 147 toAdd.addLast(osm); 148 } else if (osm.isModified() && !osm.isDeleted()) { 149 toUpdate.addLast(osm); 150 } else if (osm.isDeleted() && !osm.isNew() && osm.isModified() && osm.isVisible()) { 151 toDelete.addFirst(osm); 152 } 153 } 154 OsmPrimitiveComparator c = new OsmPrimitiveComparator(); 155 c.relationsFirst = true; 156 Collections.sort(toDelete, c); 157 Collections.sort(toAdd, c); 158 Collections.sort(toUpdate, c); 146 init(primitives); 159 147 } 160 148 -
trunk/src/org/openstreetmap/josm/data/osm/IPrimitive.java
r4431 r5589 7 7 8 8 /** 9 * IPrimitive captures the common functions of OsmPrimitive and PrimitiveData.9 * IPrimitive captures the common functions of {@link OsmPrimitive} and {@link PrimitiveData}. 10 10 */ 11 11 public interface IPrimitive extends Tagged, PrimitiveId { -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r5531 r5589 28 28 29 29 /** 30 * An OSM primitive can be associated with a key/value pair. It can be created, deleted 31 * and updated within the OSM-Server. 30 * The base class for OSM objects ({@link Node}, {@link Way}, {@link Relation}). 31 * 32 * It can be created, deleted and uploaded to the OSM-Server. 32 33 * 33 34 * Although OsmPrimitive is designed as a base class, it is not to be meant to subclass -
trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java
r5170 r5589 9 9 10 10 /** 11 * This class can be used to save properties of OsmPrimitive. 11 12 * 12 * Th is class can be used to save properties of OsmPrimitive. The main difference between PrimitiveData13 * The main difference between PrimitiveData 13 14 * and OsmPrimitive is that PrimitiveData is not part of the dataset and changes in PrimitiveData are not 14 15 * reported by events 15 *16 16 */ 17 17 public abstract class PrimitiveData extends AbstractPrimitive { -
trunk/src/org/openstreetmap/josm/io/OsmChangeBuilder.java
r4645 r5589 36 36 osmwriter = OsmWriterFactory.createOsmWriter(writer, false, apiVersion); 37 37 osmwriter.setChangeset(changeset); 38 osmwriter.setIsOsmChange(true); 38 39 } 39 40 -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r5497 r5589 40 40 private boolean osmConform; 41 41 private boolean withBody = true; 42 private boolean isOsmChange; 42 43 private String version; 43 44 private Changeset changeset; … … 55 56 this.withBody = wb; 56 57 } 58 59 public void setIsOsmChange(boolean isOsmChange) { 60 this.isOsmChange = isOsmChange; 61 } 62 57 63 public void setChangeset(Changeset cs) { 58 64 this.changeset = cs; … … 136 142 if (n.isIncomplete()) return; 137 143 addCommon(n, "node"); 138 if (n.getCoor() != null) {139 out.print(" lat='"+n.getCoor().lat()+"' lon='"+n.getCoor().lon()+"'");140 }141 144 if (!withBody) { 142 145 out.println("/>"); 143 146 } else { 147 if (n.getCoor() != null) { 148 out.print(" lat='"+n.getCoor().lat()+"' lon='"+n.getCoor().lon()+"'"); 149 } 144 150 addTags(n, "node", true); 145 151 } … … 240 246 } else 241 247 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 } 267 275 if (osm.getVersion() != 0) { 268 276 out.print(" version='"+osm.getVersion()+"'"); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r5587 r5589 362 362 /** 363 363 * Calculate MD5 hash of a string and output in hexadecimal format. 364 * Output has length 32 with characters in range [0-9a-f] 364 * @param data arbitrary String 365 * @return MD5 hash of data, string of length 32 with characters in range [0-9a-f] 365 366 */ 366 367 public static String md5Hex(String data) { … … 382 383 383 384 /** 384 * Converts a byte array to a string of hexadecimal characters. Preserves leading zeros, so the 385 * size of the output string is always twice the number of input bytes. 385 * Converts a byte array to a string of hexadecimal characters. 386 * Preserves leading zeros, so the size of the output string is always twice 387 * the number of input bytes. 388 * @param bytes the byte array 389 * @return hexadecimal representation 386 390 */ 387 391 public static String toHexString(byte[] bytes) {
Note:
See TracChangeset
for help on using the changeset viewer.