Changeset 3440 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2010-08-15T17:31:20+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r3432 r3440 283 283 success = ways.remove((Way) primitive); 284 284 } else if (primitive instanceof Relation) { 285 success = relations.remove( (Relation)primitive);285 success = relations.remove(primitive); 286 286 } 287 287 if (!success) … … 609 609 */ 610 610 public OsmPrimitive getPrimitiveById(long id, OsmPrimitiveType type) { 611 return getPrimitiveById(new SimplePrimitiveId(id, type) , false);611 return getPrimitiveById(new SimplePrimitiveId(id, type)); 612 612 } 613 613 614 614 public OsmPrimitive getPrimitiveById(PrimitiveId primitiveId) { 615 return getPrimitiveById(primitiveId, false); 616 } 617 615 return primitivesMap.get(primitiveId); 616 } 617 618 /** 619 * 620 * @param primitiveId 621 * @param createNew 622 * @return 623 * @deprecated This method can created inconsistent dataset when called for node with id < 0 and createNew=true. That will add 624 * complete node without coordinates to dataset which is not allowed. 625 */ 626 @Deprecated 618 627 public OsmPrimitive getPrimitiveById(PrimitiveId primitiveId, boolean createNew) { 619 628 OsmPrimitive result = primitivesMap.get(primitiveId); … … 734 743 */ 735 744 public boolean isModified() { 736 for (Node n: nodes) { 737 if (n.isModified()) return true; 738 } 739 for (Way w: ways) { 740 if (w.isModified()) return true; 741 } 742 for (Relation r: relations) { 743 if (r.isModified()) return true; 745 for (OsmPrimitive p: allPrimitives) { 746 if (p.isModified()) 747 return true; 744 748 } 745 749 return false; -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitiveType.java
r3083 r3440 72 72 } 73 73 74 public OsmPrimitive newInstance(long uniqueId, boolean allowNegative) { 75 switch (this) { 76 case NODE: 77 return new Node(uniqueId, allowNegative); 78 case WAY: 79 return new Way(uniqueId, allowNegative); 80 case RELATION: 81 return new Relation(uniqueId, allowNegative); 82 default: 83 throw new AssertionError(); 84 } 85 } 86 74 87 @Override 75 88 public String toString() { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitor.java
r3265 r3440 163 163 // Create all primitives first 164 164 for (PrimitiveData primitive: mappedPrimitives.values()) { 165 hull.getPrimitiveById(primitive, true); 166 } 167 // Then fill nodes with data 168 for (PrimitiveData primitive : mappedPrimitives.values()) { 169 if (primitive instanceof NodeData) { 170 if (!primitive.isIncomplete()) { 171 hull.getPrimitiveById(primitive).load(primitive); 172 } 165 OsmPrimitive newPrimitive = hull.getPrimitiveById(primitive); 166 boolean created = newPrimitive == null; 167 if (created) { 168 newPrimitive = primitive.getType().newInstance(primitive.getUniqueId(), true); 169 } 170 if (newPrimitive instanceof Node && !primitive.isIncomplete()) { 171 newPrimitive.load(primitive); 172 } 173 if (created) { 174 hull.addPrimitive(newPrimitive); 173 175 } 174 176 } 175 177 // Then ways and relations 176 178 for (PrimitiveData primitive : mappedPrimitives.values()) { 177 if (!(primitive instanceof NodeData)) { 178 if (!primitive.isIncomplete()) { 179 hull.getPrimitiveById(primitive).load(primitive); 180 } 179 if (!(primitive instanceof NodeData) && !primitive.isIncomplete()) { 180 hull.getPrimitiveById(primitive).load(primitive); 181 181 } 182 182 }
Note:
See TracChangeset
for help on using the changeset viewer.