- Timestamp:
- 2026-11-20T12:53:15+01:00 (4 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/vector/VectorDataSet.java
r19519 r19695 253 253 @Override 254 254 public <T extends VectorPrimitive> Collection<T> getPrimitives(Predicate<? super VectorPrimitive> predicate) { 255 Collection<VectorPrimitive> primitives = tryRead(this.readWriteLock, () -> { 255 final Collection<VectorPrimitive> primitives = tryRead(this.readWriteLock, () -> { 256 256 final Storage<MVTTile> dataStore = this.getBestZoomDataStore().orElse(null); 257 257 final Stream<VectorDataStore> dataStoreStream = dataStore != null ? dataStore.stream().map(MVTTile::getData) : Stream.empty(); … … 364 364 return tryRead(this.readWriteLock, () -> { 365 365 final Storage<MVTTile> dataStore = this.getBestZoomDataStore().orElse(null); 366 Stream<VectorDataStore> dataStoreStream = dataStore != null ? dataStore.stream().map(MVTTile::getData) : Stream.empty(); 367 return Stream.concat(dataStoreStream, Stream.of(this.customDataStore)).map(VectorDataStore::getPrimitivesMap) 368 .flatMap(dataMap -> { 369 // Synchronize on dataMap to avoid concurrent modification errors 370 synchronized (dataMap) { 371 return this.currentSelectedPrimitives.stream().map(dataMap::get).filter(Objects::nonNull); 372 } 373 }).collect(Collectors.toList()); 366 final Stream<VectorDataStore> dataStoreStream = dataStore != null 367 ? dataStore.stream().map(MVTTile::getData) 368 : Stream.empty(); 369 370 return Stream.concat(dataStoreStream, Stream.ofNullable(this.customDataStore)) 371 .map(VectorDataStore::getPrimitivesMap) 372 .filter(Objects::nonNull) 373 .flatMap(dataMap -> { 374 final Map<PrimitiveId, VectorPrimitive> lockObject = dataMap; 375 synchronized (lockObject) { 376 final List<VectorPrimitive> selectedInMap = new ArrayList<>(); 377 for (PrimitiveId id : this.currentSelectedPrimitives) { 378 final VectorPrimitive primitive = lockObject.get(id); 379 if (primitive != null) { 380 selectedInMap.add(primitive); 381 } 382 } 383 return selectedInMap.stream(); 384 } 385 }) 386 .collect(Collectors.toList()); 374 387 }).orElseGet(Collections::emptyList); 375 388 } … … 491 504 SelectionChangeEvent<VectorPrimitive, VectorNode, VectorWay, VectorRelation, VectorDataSet>> command) { 492 505 synchronized (this.selectionLock) { 493 SelectionChangeEvent<VectorPrimitive, VectorNode, VectorWay, VectorRelation, VectorDataSet> event = 506 final SelectionChangeEvent<VectorPrimitive, VectorNode, VectorWay, VectorRelation, VectorDataSet> event = 494 507 command.apply(currentSelectedPrimitives.stream().map(this::getPrimitiveById).collect(Collectors.toSet())); 495 508 if (event.isNop()) { … … 636 649 */ 637 650 public void setInvisibleLayers(Collection<String> invisibleLayers) { 638 String[] currentInvisibleLayers = invisibleLayers.stream().filter(Objects::nonNull).toArray(String[]::new); 639 List<String> temporaryList = Arrays.asList(currentInvisibleLayers); 651 final String[] currentInvisibleLayers = invisibleLayers.stream().filter(Objects::nonNull).toArray(String[]::new); 652 final List<String> temporaryList = Arrays.asList(currentInvisibleLayers); 640 653 this.dataStoreMap.values().stream().flatMap(Collection::stream).map(MVTTile::getData) 641 654 .forEach(dataStore -> dataStore.getAllPrimitives().parallelStream()
Note:
See TracChangeset
for help on using the changeset viewer.
