Changeset 2077 in josm for trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
- Timestamp:
- 2009-09-07T23:06:19+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2070 r2077 313 313 * 314 314 * @param id the id, > 0 required 315 * @param type the type of the primitive. Must not be null. 315 316 * @return the primitive 316 317 * @exception IllegalArgumentException thrown, if id <= 0 317 */ 318 public OsmPrimitive getPrimitiveById(long id) { 318 * @exception IllegalArgumentException thrown, if type is null 319 * @exception IllegalArgumentException thrown, if type is neither NODE, or WAY or RELATION 320 */ 321 public OsmPrimitive getPrimitiveById(long id, OsmPrimitiveType type) { 319 322 if (id <= 0) 320 323 throw new IllegalArgumentException(tr("parameter {0} > 0 required. Got {1}.", "id", id)); 321 for (OsmPrimitive primitive : nodes) { 322 if (primitive.getId() == id) return primitive; 323 } 324 for (OsmPrimitive primitive : ways) { 325 if (primitive.getId() == id) return primitive; 326 } 327 for (OsmPrimitive primitive : relations) { 324 if (id <= 0) 325 throw new IllegalArgumentException(tr("paramete''{0}'' must not be null", "type")); 326 Collection<? extends OsmPrimitive> primitives = null; 327 switch(type) { 328 case NODE: primitives = nodes; break; 329 case WAY: primitives = ways; break; 330 case RELATION: primitives = relations; break; 331 case CHANGESET: throw new IllegalArgumentException(tr("unsupported value ''{0}'' or parameter ''{1}''", type, "type")); 332 } 333 for (OsmPrimitive primitive : primitives) { 328 334 if (primitive.getId() == id) return primitive; 329 335 } … … 341 347 for (OsmPrimitive primitive : relations) { 342 348 ret.add(primitive.getId()); 343 }344 return ret;345 }346 347 /**348 * Replies the set of ids of all complete primitives (i.e. those with349 * ! primitive.incomplete)350 *351 * @return the set of ids of all complete primitives352 */353 public Set<Long> getCompletePrimitiveIds() {354 HashSet<Long> ret = new HashSet<Long>();355 for (OsmPrimitive primitive : nodes) {356 if (!primitive.incomplete) {357 ret.add(primitive.getId());358 }359 }360 for (OsmPrimitive primitive : ways) {361 if (! primitive.incomplete) {362 ret.add(primitive.getId());363 }364 }365 for (OsmPrimitive primitive : relations) {366 if (! primitive.incomplete) {367 ret.add(primitive.getId());368 }369 349 } 370 350 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.