Changeset 21675 in osm for applications/editors/josm/plugins/reverter
- Timestamp:
- 2010-06-12T22:01:26+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/reverter/src/reverter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java
r21664 r21675 13 13 import org.openstreetmap.josm.command.DeleteCommand; 14 14 import org.openstreetmap.josm.data.conflict.Conflict; 15 import org.openstreetmap.josm.data.coor.LatLon; 15 16 import org.openstreetmap.josm.data.osm.Changeset; 16 17 import org.openstreetmap.josm.data.osm.ChangesetDataSet; … … 25 26 import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetDataSetEntry; 26 27 import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType; 28 import org.openstreetmap.josm.data.osm.history.HistoryNode; 27 29 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 28 30 import org.openstreetmap.josm.data.osm.history.HistoryRelation; … … 129 131 } else throw new AssertionError(); 130 132 } 131 132 /* Create list of objects that created or modified my the changeset but 133 * doesn't present in the current dataset. 134 */ 135 missing.clear(); 133 } 134 public void checkMissingCreated() { 136 135 addMissingHistoryIds(created); 136 } 137 public void checkMissingUpdated() { 137 138 addMissingHistoryIds(updated); 139 } 140 public void checkMissingDeleted() { 141 addMissingHistoryIds(deleted); 138 142 } 139 143 … … 166 170 167 171 public void downloadMissingPrimitives(ProgressMonitor monitor) throws OsmTransferException { 172 if (!hasMissingObjects()) return; 168 173 MultiFetchServerObjectReader rdr = new MultiFetchServerObjectReader(); 169 174 for (PrimitiveId id : missing) { … … 204 209 } 205 210 211 private static boolean hasEqualSemanticAttributes(OsmPrimitive current,HistoryOsmPrimitive history) { 212 if (!current.getKeys().equals(history.getTags())) return false; 213 switch (current.getType()) { 214 case NODE: 215 return new LatLon(((Node)current).getCoor()).equals(((HistoryNode)history).getCoords()); 216 case WAY: 217 List<Node> currentNodes = ((Way)current).getNodes(); 218 List<Long> historyNodes = ((HistoryWay)history).getNodes(); 219 if (currentNodes.size() != historyNodes.size()) return false; 220 for (int i = 0; i < currentNodes.size(); i++) { 221 if (currentNodes.get(i).getId() != historyNodes.get(i)) return false; 222 } 223 return true; 224 case RELATION: 225 List<org.openstreetmap.josm.data.osm.RelationMember> currentMembers = 226 ((Relation)current).getMembers(); 227 List<RelationMember> historyMembers = ((HistoryRelation)history).getMembers(); 228 if (currentMembers.size() != historyMembers.size()) return false; 229 for (int i = 0; i < currentMembers.size(); i++) { 230 org.openstreetmap.josm.data.osm.RelationMember currentMember = 231 currentMembers.get(i); 232 RelationMember historyMember = historyMembers.get(i); 233 if (!currentMember.getRole().equals(historyMember.getRole())) return false; 234 if (currentMember.getMember().getPrimitiveId().equals(new SimplePrimitiveId( 235 historyMember.getPrimitiveId(),historyMember.getPrimitiveType()))) return false; 236 } 237 return true; 238 default: throw new AssertionError(); 239 } 240 } 241 206 242 /** 207 243 * Builds a list of commands that will revert the changeset … … 220 256 221 257 HashSet<OsmPrimitive> toDelete = new HashSet<OsmPrimitive>(); 222 // Mark objects that ha vevisible=false to be deleted258 // Mark objects that has visible=false to be deleted 223 259 for (OsmPrimitive p : nds.allPrimitives()) { 224 260 if (!p.isVisible()) { … … 249 285 HistoryOsmPrimitive hp = entry.getPrimitive(); 250 286 OsmPrimitive dp = ds.getPrimitiveById(hp.getPrimitiveId()); 251 if (dp == null )287 if (dp == null || dp.isIncomplete()) 252 288 throw new IllegalStateException(tr("Missing merge target for {0} with id {1}", 253 289 hp.getType(), hp.getId())); 290 254 291 if (hp.getVersion() != dp.getVersion() 255 && (hp.isVisible() || dp.isVisible())) { 292 && (hp.isVisible() || dp.isVisible()) && 293 /* Don't create conflict if changeset object and dataset object 294 * has same semantic attributes(but different versions) 295 */ 296 !hasEqualSemanticAttributes(dp,hp)) { 297 298 256 299 cmds.add(new ConflictAddCommand(layer,CreateConflict(dp, 257 300 entry.getModificationType() == ChangesetModificationType.CREATED))); … … 293 336 return cmds; 294 337 } 295 public boolean ha veMissingObjects() {338 public boolean hasMissingObjects() { 296 339 return !missing.isEmpty(); 297 340 } -
applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetAction.java
r21640 r21675 50 50 51 51 private boolean checkMissing() throws OsmTransferException { 52 if (!rev.ha veMissingObjects()) return true;52 if (!rev.hasMissingObjects()) return true; 53 53 if (!downloadConfirmed) { 54 54 downloadConfirmed = JOptionPane.showConfirmDialog(Main.parent, … … 73 73 rev = new ChangesetReverter(changesetId, NullProgressMonitor.INSTANCE); 74 74 if (progressMonitor.isCancelled()) return; 75 rev.checkMissingDeleted(); 76 // Don't ask user to download primitives going to be undeleted 77 rev.downloadMissingPrimitives(NullProgressMonitor.INSTANCE); 78 rev.checkMissingCreated(); 79 rev.checkMissingUpdated(); 75 80 if (!checkMissing()) return; 76 81 rev.downloadObjectsHistory(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
Note:
See TracChangeset
for help on using the changeset viewer.