Changeset 3432 in josm for trunk/src/org
- Timestamp:
- 2010-08-13T22:37:52+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r3431 r3432 244 244 245 245 primitive.updatePosition(); // Set cached bbox for way and relation (required for reindexWay and reinexRelation to work properly) 246 boolean success = false; 246 247 if (primitive instanceof Node) { 247 nodes.add((Node) primitive);248 success = nodes.add((Node) primitive); 248 249 } else if (primitive instanceof Way) { 249 ways.add((Way) primitive);250 success = ways.add((Way) primitive); 250 251 } else if (primitive instanceof Relation) { 251 relations.add((Relation) primitive); 252 } 252 success = relations.add((Relation) primitive); 253 } 254 if (!success) 255 throw new RuntimeException("failed to add primitive: "+primitive); 253 256 allPrimitives.add(primitive); 254 257 primitive.setDataset(this); 255 258 firePrimitivesAdded(Collections.singletonList(primitive), false); 256 } finally {257 endUpdate();258 }259 }260 261 public OsmPrimitive addPrimitive(PrimitiveData data) {262 beginUpdate();263 try {264 OsmPrimitive result;265 if (data instanceof NodeData) {266 result = new Node();267 } else if (data instanceof WayData) {268 result = new Way();269 } else if (data instanceof RelationData) {270 result = new Relation();271 } else272 throw new AssertionError();273 result.setDataset(this);274 result.load(data);275 addPrimitive(result);276 return result;277 259 } finally { 278 260 endUpdate(); … … 295 277 if (primitive == null) 296 278 return; 279 boolean success = false; 297 280 if (primitive instanceof Node) { 298 nodes.remove(primitive);281 success = nodes.remove((Node) primitive); 299 282 } else if (primitive instanceof Way) { 300 ways.remove(primitive);283 success = ways.remove((Way) primitive); 301 284 } else if (primitive instanceof Relation) { 302 relations.remove(primitive); 303 } 285 success = relations.remove((Relation) primitive); 286 } 287 if (!success) 288 throw new RuntimeException("failed to remove primitive: "+primitive); 304 289 synchronized (selectionLock) { 305 290 selectedPrimitives.remove(primitive); … … 722 707 723 708 /** 724 * removes all references from from other primitivesto the709 * removes all references from other primitives to the 725 710 * referenced primitive 726 711 * … … 762 747 763 748 private void reindexNode(Node node, LatLon newCoor, EastNorth eastNorth) { 764 nodes.remove(node); 749 if (!nodes.remove(node)) 750 throw new RuntimeException("Reindexing node failed to remove"); 765 751 node.setCoorInternal(newCoor, eastNorth); 766 nodes.add(node); 752 if (!nodes.add(node)) 753 throw new RuntimeException("Reindexing node failed to add"); 767 754 for (OsmPrimitive primitive: node.getReferrers()) { 768 755 if (primitive instanceof Way) { … … 776 763 private void reindexWay(Way way) { 777 764 BBox before = way.getBBox(); 778 ways.remove(way); 765 if (!ways.remove(way)) 766 throw new RuntimeException("Reindexing way failed to remove"); 779 767 way.updatePosition(); 780 ways.add(way); 768 if (!ways.add(way)) 769 throw new RuntimeException("Reindexing way failed to add"); 781 770 if (!way.getBBox().equals(before)) { 782 771 for (OsmPrimitive primitive: way.getReferrers()) {
Note:
See TracChangeset
for help on using the changeset viewer.