Changeset 29553 in osm for applications/editors
- Timestamp:
- 2013-05-01T02:51:44+02:00 (12 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
r29551 r29553 5 5 import java.net.HttpURLConnection; 6 6 import java.util.Arrays; 7 import java.util.Collection; 7 8 import java.util.Collections; 8 9 import java.util.HashSet; … … 174 175 addMissingHistoryIds(deleted); 175 176 } 177 178 private void readObjectVersion(OsmServerMultiObjectReader rdr, PrimitiveId id, int version, ProgressMonitor progressMonitor) throws OsmTransferException { 179 boolean readOK = false; 180 while (!readOK && version >= 1) { 181 try { 182 rdr.readObject(id, version, progressMonitor.createSubTaskMonitor(1, true)); 183 readOK = true; 184 } catch (OsmApiException e) { 185 if (e.getResponseCode() != HttpURLConnection.HTTP_FORBIDDEN) { 186 throw e; 187 } 188 String message = "Version "+version+" of "+id+" is unauthorized"; 189 if (version > 1) { 190 message += ", requesting previous one"; 191 } 192 Main.info(message); 193 version--; 194 } 195 } 196 if (!readOK) { 197 Main.warn("Cannot retrieve any previous version of "+id); 198 } 199 } 176 200 177 201 /** … … 188 212 for (HistoryOsmPrimitive entry : collection) { 189 213 PrimitiveId id = entry.getPrimitiveId(); 190 int version = cds.getEarliestVersion(id)-1; 191 boolean readOK = false; 192 while (!readOK && version >= 1) { 193 try { 194 rdr.readObject(id, version, progressMonitor.createSubTaskMonitor(1, true)); 195 readOK = true; 196 } catch (OsmApiException e) { 197 if (e.getResponseCode() != HttpURLConnection.HTTP_FORBIDDEN) { 198 throw e; 199 } 200 String message = "Version "+version+" of "+id+" is unauthorized"; 201 if (version > 1) { 202 message += ", requesting previous one"; 203 } 204 Main.info(message); 205 version--; 206 } 207 } 208 if (!readOK) { 209 Main.warn("Cannot retrieve any previous version of "+id); 210 } 214 readObjectVersion(rdr, id, cds.getEarliestVersion(id)-1, progressMonitor); 211 215 if (progressMonitor.isCanceled()) return; 212 216 } … … 412 416 return !missing.isEmpty(); 413 417 } 418 419 public void fixNodesWithoutCoordinates(ProgressMonitor progressMonitor) throws OsmTransferException { 420 for (Node n : nds.getNodes()) { 421 if (!n.isDeleted() && n.getCoor() == null) { 422 PrimitiveId id = n.getPrimitiveId(); 423 OsmPrimitive p = ds.getPrimitiveById(id); 424 if (p instanceof Node && p.getVersion() > 1) { 425 final OsmServerMultiObjectReader rdr = new OsmServerMultiObjectReader(); 426 readObjectVersion(rdr, id, p.getVersion()-1, progressMonitor); 427 Collection<OsmPrimitive> result = rdr.parseOsm(progressMonitor.createSubTaskMonitor(1, true)).allPrimitives(); 428 if (!result.isEmpty()) { 429 n.setCoor(((Node)result.iterator().next()).getCoor()); 430 } 431 } 432 } 433 } 434 } 414 435 } -
applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetTask.java
r29359 r29553 85 85 if (progressMonitor.isCanceled()) return; 86 86 if (!checkAndDownloadMissing()) return; 87 rev.fixNodesWithoutCoordinates(progressMonitor); 87 88 List<Command> cmds = rev.getCommands(); 88 89 final Command cmd = new RevertChangesetCommand(tr(revertType == RevertType.FULL ? "Revert changeset #{0}" :
Note:
See TracChangeset
for help on using the changeset viewer.