Changeset 2250 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2009-10-05T21:39:15+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/APIDataSet.java
r2188 r2250 66 66 } 67 67 } 68 } 69 68 sortDeleted(); 69 } 70 71 /** 72 * Ensures that primitives are deleted in the following order: Relations, then Ways, 73 * then Nodes. 74 * 75 */ 76 protected void sortDeleted() { 77 Collections.sort( 78 toDelete, 79 new Comparator<OsmPrimitive>() { 80 public int compare(OsmPrimitive o1, OsmPrimitive o2) { 81 if (o1 instanceof Node && o2 instanceof Node) 82 return 0; 83 else if (o1 instanceof Node) 84 return 1; 85 else if (o2 instanceof Node) 86 return -1; 87 88 if (o1 instanceof Way && o2 instanceof Way) 89 return 0; 90 else if (o1 instanceof Way && o2 instanceof Relation) 91 return 1; 92 else if (o2 instanceof Way && o1 instanceof Relation) 93 return -1; 94 95 return 0; 96 } 97 } 98 ); 99 } 70 100 /** 71 101 * initializes the API data set with the modified primitives in <code>ds</code> … … 76 106 this(); 77 107 init(ds); 108 } 109 110 /** 111 * initializes the API data set with the primitives in <code>primitives</code> 112 * 113 * @param primitives the collection of primitives 114 */ 115 public APIDataSet(Collection<OsmPrimitive> primitives) { 116 this(); 117 toAdd.clear(); 118 toUpdate.clear(); 119 toDelete.clear(); 120 for (OsmPrimitive osm: primitives) { 121 if (osm.getId() == 0 && !osm.isDeleted()) { 122 toAdd.addLast(osm); 123 } else if (osm.isModified() && !osm.isDeleted()) { 124 toUpdate.addLast(osm); 125 } else if (osm.isDeleted() && osm.getId() != 0 && osm.isModified()) { 126 toDelete.addFirst(osm); 127 } 128 } 129 sortDeleted(); 78 130 } 79 131
Note:
See TracChangeset
for help on using the changeset viewer.