Changeset 18248 in josm for trunk/src


Ignore:
Timestamp:
2021-10-05T20:46:07+02:00 (3 years ago)
Author:
Don-vip
Message:

fix #15498 - Load folders containing pictures in separate layers if geoimage.one-layer-per-folder advanced property is set to true

Location:
trunk/src/org/openstreetmap/josm/gui/layer/geoimage
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r18246 r18248  
    166166     */
    167167    public GeoImageLayer(final List<ImageEntry> data, GpxData gpxData, final String name, boolean useThumbs) {
    168         super(name != null ? name : tr("Geotagged Images"));
     168        super(!Utils.isBlank(name) ? name : tr("Geotagged Images"));
    169169        this.data = new ImageData(data);
    170170        this.gpxData = gpxData;
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoader.java

    r18051 r18248  
    1212import java.util.LinkedHashSet;
    1313import java.util.List;
     14import java.util.Map;
    1415import java.util.Set;
     16import java.util.TreeMap;
     17import java.util.stream.Collectors;
    1518
    1619import javax.swing.JOptionPane;
    1720
     21import org.openstreetmap.josm.data.preferences.BooleanProperty;
    1822import org.openstreetmap.josm.gui.MainApplication;
    1923import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     
    3438
    3539    private boolean canceled;
    36     private GeoImageLayer layer;
     40    private final List<GeoImageLayer> layers = new ArrayList<>();
    3741    private final Collection<File> selection;
    3842    private final Set<String> loadedDirectories = new HashSet<>();
    3943    private final Set<String> errorMessages;
    4044    private final GpxLayer gpxLayer;
     45
     46    private static final BooleanProperty PROP_ONE_LAYER_PER_FOLDER = new BooleanProperty("geoimage.one-layer-per-folder", false);
    4147
    4248    /**
     
    7379
    7480        // read the image files
    75         List<ImageEntry> entries = new ArrayList<>(files.size());
     81        Map<String, List<ImageEntry>> entries = new TreeMap<>();
    7682
    7783        for (File f : files) {
     
    8692            ImageEntry e = new ImageEntry(f);
    8793            e.extractExif();
    88             entries.add(e);
     94            File parentFile = f.getParentFile();
     95            entries.computeIfAbsent(parentFile != null ? parentFile.getName() : "", x -> new ArrayList<>()).add(e);
    8996        }
    90         layer = new GeoImageLayer(entries, gpxLayer);
     97        if (Boolean.TRUE.equals(PROP_ONE_LAYER_PER_FOLDER.get())) {
     98            entries.entrySet().stream().map(e -> new GeoImageLayer(e.getValue(), gpxLayer, e.getKey())).forEach(layers::add);
     99        } else {
     100            layers.add(new GeoImageLayer(entries.values().stream().flatMap(List<ImageEntry>::stream).collect(Collectors.toList()), gpxLayer));
     101        }
    91102        files.clear();
    92103    }
     
    160171                    );
    161172        }
    162         if (layer != null) {
     173        for (GeoImageLayer layer : layers) {
    163174            MainApplication.getLayerManager().addLayer(layer);
    164175
Note: See TracChangeset for help on using the changeset viewer.