Changeset 34930 in osm for applications/editors/josm/plugins/reverter/src
- Timestamp:
- 2019-03-22T07:23:48+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java
r34917 r34930 5 5 6 6 import java.net.HttpURLConnection; 7 import java.util.ArrayList; 7 8 import java.util.Arrays; 8 9 import java.util.Collection; … … 24 25 import org.openstreetmap.josm.data.osm.PrimitiveId; 25 26 import org.openstreetmap.josm.data.osm.Relation; 26 import org.openstreetmap.josm.data.osm.RelationMember;27 27 import org.openstreetmap.josm.data.osm.RelationMemberData; 28 28 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; … … 92 92 for (HistoryOsmPrimitive p : primitives) { 93 93 addIfMissing(p.getPrimitiveId()); 94 if (p.getType() == OsmPrimitiveType.WAY) { 95 for (long nd : ((HistoryWay) p).getNodes()) { 96 addIfMissing(new SimplePrimitiveId(nd, OsmPrimitiveType.NODE)); 97 } 98 } 99 } 100 } 101 102 private void addMissingIds(Iterable<OsmPrimitive> primitives) { 103 for (OsmPrimitive p : primitives) { 104 addIfMissing(p); 105 if (p.getType() == OsmPrimitiveType.WAY) { 106 for (Node nd : ((Way) p).getNodes()) { 107 addIfMissing(nd); 108 } 94 } 95 } 96 97 private void addMissingId(OsmPrimitive p) { 98 addIfMissing(p); 99 if (p.getType() == OsmPrimitiveType.WAY) { 100 for (Node nd : ((Way) p).getNodes()) { 101 addIfMissing(nd); 109 102 } 110 103 } … … 233 226 for (OsmPrimitive p : nds.allPrimitives()) { 234 227 if (!p.isIncomplete()) { 235 addMissingId s(Collections.singleton(p));228 addMissingId(p); 236 229 } else { 237 230 if (ds.getPrimitiveById(p.getPrimitiveId()) == null) { … … 344 337 */ 345 338 public List<Command> getCommands() { 346 if (this.nds == null) return null; 339 List<Command> cmds = new ArrayList<>(); 340 if (this.nds == null) return cmds; 347 341 348 342 ////////////////////////////////////////////////////////////////////////// 349 343 // Create commands to restore/update all affected objects 350 344 DataSetCommandMerger merger = new DataSetCommandMerger(nds, ds); 351 List<Command> cmds = merger.getCommandList();345 cmds.addAll(merger.getCommandList()); 352 346 353 347 ////////////////////////////////////////////////////////////////////////// … … 444 438 PrimitiveId id = n.getPrimitiveId(); 445 439 OsmPrimitive p = ds.getPrimitiveById(id); 446 if (p instanceof Node && p.getVersion() > 1) { 447 LatLon coor = ((Node) p).getCoor(); 448 if (coor == null) { 440 if (p instanceof Node && !((Node) p).isLatLonKnown()) { 441 int version = p.getVersion(); 442 while (version > 1) { 443 // find the version that was in use when the current changeset was closed 444 --version; 449 445 final OsmServerMultiObjectReader rdr = new OsmServerMultiObjectReader(); 450 readObjectVersion(rdr, id, p.getVersion()-1, progressMonitor); 451 Collection<OsmPrimitive> result = rdr.parseOsm(progressMonitor.createSubTaskMonitor(1, true)).allPrimitives(); 452 if (!result.isEmpty()) { 453 coor = ((Node) result.iterator().next()).getCoor(); 446 readObjectVersion(rdr, id, version, progressMonitor); 447 DataSet history = rdr.parseOsm(progressMonitor.createSubTaskMonitor(1, true)); 448 if (!history.isEmpty()) { 449 Node historyNode = (Node) history.allPrimitives().iterator().next(); 450 if (historyNode.isLatLonKnown() && changeset.getClosedAt().after(historyNode.getTimestamp())) { 451 n.load(historyNode.save()); 452 break; 453 } 454 454 } 455 455 } 456 if (coor != null) {457 n.setCoor(coor);458 }459 456 } 460 457 }
Note:
See TracChangeset
for help on using the changeset viewer.