Ticket #4142: 4142.3.patch

File 4142.3.patch, 27.6 KB (added by taylor.smock, 7 months ago)

Fix i18n, perform check in SplitWayAction

  • src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java

    Subject: [PATCH] 4142
    ---
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java b/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java
    a b  
    121121            return;
    122122        }
    123123
     124        this.children.stream().map(this.parents::getPrimitiveById).forEach(p -> p.setReferrersDownloaded(true));
    124125        DataSetMerger visitor = new DataSetMerger(targetLayer.getDataSet(), parents);
    125126        visitor.merge();
    126127        SwingUtilities.invokeLater(targetLayer::onPostDownloadFromServer);
  • src/org/openstreetmap/josm/actions/AlignInCircleAction.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/actions/AlignInCircleAction.java b/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.actions;
    33
     4import static java.util.function.Predicate.not;
    45import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    56import static org.openstreetmap.josm.tools.I18n.tr;
    67
     
    271272        }
    272273        fixNodes.addAll(collectNodesWithExternReferrers(ways));
    273274
    274         // Check if one or more nodes are outside of download area
    275         if (nodes.stream().anyMatch(Node::isOutsideDownloadArea))
    276             throw new InvalidSelection(tr("One or more nodes involved in this action is outside of the downloaded area."));
     275        // Check if one or more nodes does not have all parents available
     276        if (nodes.stream().anyMatch(not(Node::isReferrersDownloaded)))
     277            throw new InvalidSelection(tr("One or more nodes involved in this action may have additional referrers."));
    277278
    278279
    279280        if (center == null) {
  • src/org/openstreetmap/josm/actions/CombineWayAction.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/actions/CombineWayAction.java b/src/org/openstreetmap/josm/actions/CombineWayAction.java
    a b  
    284284        for (Way w : selectedWays) {
    285285            final Node[] endnodes = {w.firstNode(), w.lastNode()};
    286286            for (Node n : endnodes) {
    287                 if (!n.isNew() && n.isOutsideDownloadArea() && !endNodesOutside.add(n)) {
    288                     new Notification(tr("Combine ways refused<br>" + "(A shared node is outside of the download area)"))
     287                if (!n.isNew() && !n.isReferrersDownloaded() && !endNodesOutside.add(n)) {
     288                    new Notification(tr("Combine ways refused<br>" + "(A shared node may have additional referrers)"))
    289289                            .setIcon(JOptionPane.INFORMATION_MESSAGE).show();
    290290                    return;
    291291
  • src/org/openstreetmap/josm/actions/DeleteAction.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/actions/DeleteAction.java b/src/org/openstreetmap/josm/actions/DeleteAction.java
    a b  
    1616
    1717import org.openstreetmap.josm.command.DeleteCommand.DeletionCallback;
    1818import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
     19import org.openstreetmap.josm.data.osm.INode;
     20import org.openstreetmap.josm.data.osm.IRelation;
     21import org.openstreetmap.josm.data.osm.IWay;
    1922import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2023import org.openstreetmap.josm.data.osm.Relation;
    2124import org.openstreetmap.josm.data.osm.RelationToChildReference;
     
    103106     */
    104107    public static boolean checkAndConfirmOutlyingDelete(Collection<? extends OsmPrimitive> primitives,
    105108            Collection<? extends OsmPrimitive> ignore) {
     109        final boolean nodes = primitives.stream().anyMatch(INode.class::isInstance);
     110        final boolean ways = primitives.stream().anyMatch(IWay.class::isInstance);
     111        final boolean relations = primitives.stream().anyMatch(IRelation.class::isInstance);
     112        final String type;
     113        if (nodes && !ways && !relations) {
     114            type = tr("You are about to delete nodes which can have other referrers not yet downloaded.");
     115        } else if (!nodes && ways && !relations) {
     116            type = tr("You are about to delete ways which can have other referrers not yet downloaded.");
     117        } else if (!nodes && !ways && relations) {
     118            type = tr("You are about to delete relations which can have other referrers not yet downloaded.");
     119        } else {
     120            // OK. We have multiple types being deleted.
     121            type = tr("You are about to delete primitives which can have other referrers not yet downloaded.");
     122        }
    106123        return Boolean.TRUE.equals(GuiHelper.runInEDTAndWaitAndReturn(() -> checkAndConfirmOutlyingOperation("delete",
    107124                tr("Delete confirmation"),
    108                 tr("You are about to delete nodes which can have other referrers not yet downloaded."
     125                tr("{0}"
    109126                        + "<br>"
    110127                        + "This can cause problems because other objects (that you do not see) might use them."
    111128                        + "<br>"
    112                         + "Do you really want to delete?"),
     129                        + "Do you really want to delete?", type),
    113130                tr("You are about to delete incomplete objects."
    114131                        + "<br>"
    115132                        + "This will cause problems because you don''t see the real object."
  • src/org/openstreetmap/josm/actions/JoinAreasAction.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/actions/JoinAreasAction.java b/src/org/openstreetmap/josm/actions/JoinAreasAction.java
    a b  
    672672            commitCommands(marktr("Removed duplicate nodes"));
    673673            // remove now unconnected nodes without tags
    674674            List<Node> toRemove = oldNodes.stream().filter(
    675                     n -> (n.isNew() || !n.isOutsideDownloadArea()) && !n.hasKeys() && n.getReferrers().isEmpty())
     675                    n -> n.isReferrersDownloaded() && !n.hasKeys() && n.getReferrers().isEmpty())
    676676                    .collect(Collectors.toList());
    677677            if (!toRemove.isEmpty()) {
    678678                cmds.add(new DeleteCommand(toRemove));
  • src/org/openstreetmap/josm/actions/SplitWayAction.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/actions/SplitWayAction.java b/src/org/openstreetmap/josm/actions/SplitWayAction.java
    a b  
    143143                    .setIcon(JOptionPane.WARNING_MESSAGE)
    144144                    .show();
    145145            return;
     146        } else if (!checkAndConfirmOutlyingOperation("splitway", tr("Split way confirmation"),
     147                tr("You are about to split a way that may have referrers that are not yet downloaded.")
     148                        + "<br/>"
     149                        + tr("This can lead to broken relations.") + "<br/>"
     150                        + tr("Do you really want to split?"),
     151                tr("The selected area is incomplete. Continue?"),
     152                applicableWays, null)) {
     153            return;
    146154        }
    147155
    148156        // Finally, applicableWays contains only one perfect way
  • src/org/openstreetmap/josm/command/Command.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/command/Command.java b/src/org/openstreetmap/josm/command/Command.java
    a b  
    227227        for (OsmPrimitive osm : primitives) {
    228228            if (osm.isIncomplete()) {
    229229                res |= IS_INCOMPLETE;
    230             } else if ((res & IS_OUTSIDE) == 0 && (osm.isOutsideDownloadArea()
    231                     || (osm instanceof Node && !osm.isNew() && osm.getDataSet() != null && osm.getDataSet().getDataSourceBounds().isEmpty()))
    232                             && (ignore == null || !ignore.contains(osm))) {
     230            } else if ((res & IS_OUTSIDE) == 0 && !osm.isReferrersDownloaded() && (ignore == null || !ignore.contains(osm))) {
    233231                res |= IS_OUTSIDE;
    234232            }
    235233        }
  • src/org/openstreetmap/josm/command/DeleteCommand.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/command/DeleteCommand.java b/src/org/openstreetmap/josm/command/DeleteCommand.java
    a b  
    433433            primitivesToDelete.addAll(nodesToDelete);
    434434        }
    435435
    436         if (!silent && !callback.checkAndConfirmOutlyingDelete(
    437                 primitivesToDelete, Utils.filteredCollection(primitivesToDelete, Way.class)))
     436        if (!silent && !callback.checkAndConfirmOutlyingDelete(primitivesToDelete, null))
    438437            return null;
    439438
    440439        Collection<Way> waysToBeChanged = primitivesToDelete.stream()
  • src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java b/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
    a b  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.io.IOException;
     7import java.io.ObjectInputStream;
     8import java.io.ObjectOutputStream;
    69import java.text.MessageFormat;
    710import java.time.Instant;
    811import java.util.ArrayList;
     
    130133     */
    131134    protected static final short FLAG_PRESERVED = 1 << 13;
    132135
     136    /**
     137     * Determines if the primitive has all of its referrers
     138     */
     139    protected static final short FLAG_ALL_REFERRERS_DOWNLOADED = 1 << 14;
     140
    133141    /**
    134142     * Put several boolean flags to one short int field to save memory.
    135143     * Other bits of this field are used in subclasses.
    136144     */
    137     protected volatile short flags = FLAG_VISIBLE;   // visible per default
     145    private volatile short flags = FLAG_VISIBLE;   // visible per default
    138146
    139147    /**
    140148     * The mappaint cache index for this primitive.
     
    365373        return oldFlags != flags;
    366374    }
    367375
     376    protected void writeObjectCommon(ObjectOutputStream oos) throws IOException {
     377        oos.writeLong(id);
     378        oos.writeLong(user == null ? -1 : user.getId());
     379        oos.writeInt(version);
     380        oos.writeInt(changesetId);
     381        oos.writeInt(timestamp);
     382        oos.writeObject(keys);
     383        oos.writeShort(flags);
     384    }
     385
     386    protected void readObjectCommon(ObjectInputStream ois) throws ClassNotFoundException, IOException {
     387        id = ois.readLong();
     388        final long userId = ois.readLong();
     389        user = userId == -1 ? null : User.getById(userId);
     390        version = ois.readInt();
     391        changesetId = ois.readInt();
     392        timestamp = ois.readInt();
     393        keys = (String[]) ois.readObject();
     394        flags = ois.readShort();
     395    }
     396
    368397    @Override
    369398    public void setModified(boolean modified) {
    370399        updateFlags(FLAG_MODIFIED, modified);
     
    380409        return (flags & FLAG_DELETED) != 0;
    381410    }
    382411
     412    @Override
     413    public void setReferrersDownloaded(boolean referrersDownloaded) {
     414        this.updateFlags(FLAG_ALL_REFERRERS_DOWNLOADED, referrersDownloaded);
     415    }
     416
    383417    @Override
    384418    public boolean isUndeleted() {
    385419        return (flags & (FLAG_VISIBLE + FLAG_DELETED)) == 0;
     
    408442        setModified(deleted ^ !isVisible());
    409443    }
    410444
     445    @Override
     446    public boolean hasDirectionKeys() {
     447        return (flags & FLAG_HAS_DIRECTIONS) != 0;
     448    }
     449
     450    @Override
     451    public boolean reversedDirection() {
     452        return (flags & FLAG_DIRECTION_REVERSED) != 0;
     453    }
     454
     455    @Override
     456    public boolean isTagged() {
     457        return (flags & FLAG_TAGGED) != 0;
     458    }
     459
     460    @Override
     461    public boolean isAnnotated() {
     462        return (flags & FLAG_ANNOTATED) != 0;
     463    }
     464
     465    @Override
     466    public boolean isHighlighted() {
     467        return (flags & FLAG_HIGHLIGHTED) != 0;
     468    }
     469
     470    @Override
     471    public boolean isDisabled() {
     472        return (flags & FLAG_DISABLED) != 0;
     473    }
     474
     475    @Override
     476    public boolean isDisabledAndHidden() {
     477        return ((flags & FLAG_DISABLED) != 0) && ((flags & FLAG_HIDE_IF_DISABLED) != 0);
     478    }
     479
     480    @Override
     481    public boolean isPreserved() {
     482        return (flags & FLAG_PRESERVED) != 0;
     483    }
     484
     485    @Override
     486    public boolean isReferrersDownloaded() {
     487        return isNew() || (flags & FLAG_ALL_REFERRERS_DOWNLOADED) != 0;
     488    }
     489
    411490    /**
    412491     * If set to true, this object is incomplete, which means only the id
    413492     * and type is known (type is the objects instance class)
  • src/org/openstreetmap/josm/data/osm/IPrimitive.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/data/osm/IPrimitive.java b/src/org/openstreetmap/josm/data/osm/IPrimitive.java
    a b  
    3636     */
    3737    void setModified(boolean modified);
    3838
     39    /**
     40     * Set the status of the referrers
     41     * @param referrersDownloaded {@code true} if all referrers for this object have been downloaded
     42     * @since xxx
     43     */
     44    default void setReferrersDownloaded(boolean referrersDownloaded) {
     45        throw new UnsupportedOperationException(this.getClass().getName() + " does not support referrers status");
     46    }
     47
    3948    /**
    4049     * Checks if object is known to the server.
    4150     * Replies true if this primitive is either unknown to the server (i.e. its id
     
    7584     */
    7685    void setDeleted(boolean deleted);
    7786
     87    /**
     88     * Determines if this primitive is fully downloaded
     89     * @return {@code true} if the primitive is fully downloaded and all parents and children should be available.
     90     * {@code false} otherwise.
     91     * @since xxx
     92     */
     93    default boolean isReferrersDownloaded() {
     94        return false;
     95    }
     96
    7897    /**
    7998     * Determines if this primitive is incomplete.
    8099     * @return {@code true} if this primitive is incomplete, {@code false} otherwise
  • src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java b/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
    a b  
    363363        updateFlags(FLAG_PRESERVED, isPreserved);
    364364    }
    365365
    366     @Override
    367     public boolean isDisabled() {
    368         return (flags & FLAG_DISABLED) != 0;
    369     }
    370 
    371     @Override
    372     public boolean isDisabledAndHidden() {
    373         return ((flags & FLAG_DISABLED) != 0) && ((flags & FLAG_HIDE_IF_DISABLED) != 0);
    374     }
    375 
    376     @Override
    377     public boolean isPreserved() {
    378         return (flags & FLAG_PRESERVED) != 0;
    379     }
    380 
    381366    @Override
    382367    public boolean isSelectable() {
    383368        // not synchronized -> check disabled twice just to be sure we did not have a race condition.
     
    492477        }
    493478    }
    494479
    495     @Override
    496     public boolean isHighlighted() {
    497         return (flags & FLAG_HIGHLIGHTED) != 0;
    498     }
    499 
    500480    /*---------------
    501481     * DIRECTION KEYS
    502482     *---------------*/
     
    526506        updateFlagsNoLock(FLAG_ANNOTATED, hasKeys() && getWorkInProgressKeys().stream().anyMatch(this::hasKey));
    527507    }
    528508
    529     @Override
    530     public boolean isTagged() {
    531         return (flags & FLAG_TAGGED) != 0;
    532     }
    533 
    534     @Override
    535     public boolean isAnnotated() {
    536         return (flags & FLAG_ANNOTATED) != 0;
    537     }
    538 
    539509    protected void updateDirectionFlags() {
    540510        boolean hasDirections = false;
    541511        boolean directionReversed = false;
     
    551521        updateFlagsNoLock(FLAG_HAS_DIRECTIONS, hasDirections);
    552522    }
    553523
    554     @Override
    555     public boolean hasDirectionKeys() {
    556         return (flags & FLAG_HAS_DIRECTIONS) != 0;
    557     }
    558 
    559     @Override
    560     public boolean reversedDirection() {
    561         return (flags & FLAG_DIRECTION_REVERSED) != 0;
    562     }
    563 
    564524    /*------------
    565525     * Keys handling
    566526     ------------*/
     
    851811                throw new DataIntegrityProblemException(
    852812                        tr("Cannot merge primitives with different ids. This id is {0}, the other is {1}", id, other.getId()));
    853813
     814            setIncomplete(other.isIncomplete());
     815            super.cloneFrom(other);
    854816            setKeys(other.hasKeys() ? other.getKeys() : null);
    855             timestamp = other.timestamp;
    856817            version = other.version;
    857             setIncomplete(other.isIncomplete());
    858             flags = other.flags;
    859             user = other.user;
    860818            changesetId = other.changesetId;
    861819        } finally {
    862820            writeUnlock(locked);
  • src/org/openstreetmap/josm/data/osm/PrimitiveData.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/data/osm/PrimitiveData.java b/src/org/openstreetmap/josm/data/osm/PrimitiveData.java
    a b  
    8484
    8585    private void writeObject(ObjectOutputStream oos) throws IOException {
    8686        // since super class is not Serializable
    87         oos.writeLong(id);
    88         oos.writeLong(user == null ? -1 : user.getId());
    89         oos.writeInt(version);
    90         oos.writeInt(changesetId);
    91         oos.writeInt(timestamp);
    92         oos.writeObject(keys);
    93         oos.writeShort(flags);
     87        super.writeObjectCommon(oos);
    9488        oos.defaultWriteObject();
    9589    }
    9690
    9791    private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
    9892        // since super class is not Serializable
    99         id = ois.readLong();
    100         final long userId = ois.readLong();
    101         user = userId == -1 ? null : User.getById(userId);
    102         version = ois.readInt();
    103         changesetId = ois.readInt();
    104         timestamp = ois.readInt();
    105         keys = (String[]) ois.readObject();
    106         flags = ois.readShort();
     93        super.readObjectCommon(ois);
    10794        ois.defaultReadObject();
    10895    }
    10996
  • src/org/openstreetmap/josm/data/validation/tests/BarriersEntrances.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/data/validation/tests/BarriersEntrances.java b/src/org/openstreetmap/josm/data/validation/tests/BarriersEntrances.java
    a b  
    2626
    2727    @Override
    2828    public void visit(Node n) {
    29         if (n.hasTag("barrier", "entrance") && !n.isOutsideDownloadArea()) {
     29        if (n.hasTag("barrier", "entrance") && n.isReferrersDownloaded()) {
    3030            for (OsmPrimitive p : n.getReferrers()) {
    3131                if (p.hasKey("barrier")) {
    3232                    return;
  • src/org/openstreetmap/josm/data/vector/VectorPrimitive.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/data/vector/VectorPrimitive.java b/src/org/openstreetmap/josm/data/vector/VectorPrimitive.java
    a b  
    5858        this.highlighted = highlighted;
    5959    }
    6060
    61     @Override
    62     public boolean isTagged() {
    63         return (flags & FLAG_TAGGED) != 0;
    64     }
    65 
    6661    @Override
    6762    public boolean isAnnotated() {
    6863        return this.getInterestingTags().size() - this.getKeys().size() > 0;
  • src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java b/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
    a b  
    66import java.io.IOException;
    77import java.io.InputStream;
    88import java.net.SocketException;
     9import java.util.Collection;
     10import java.util.Collections;
    911import java.util.List;
    1012
    1113import org.openstreetmap.josm.data.Bounds;
     
    215217                    ds = parseDataSet(in, progressMonitor.createSubTaskMonitor(1, false));
    216218                }
    217219            }
     220            // From https://wiki.openstreetmap.org/wiki/API_v0.6#Retrieving_map_data_by_bounding_box:_GET_/api/0.6/map,
     221            // relations are not recursed up, so they *may* have parent relations.
     222            // Nodes inside the download area should have all relations and ways that refer to them.
     223            // Ways should have all relations that refer to them and all child nodes, but those child nodes may not
     224            //    have their parent referrers.
     225            // Relations will have the *first* parent relations downloaded, but those are not split out in the returns.
     226            // So we always assume that a relation has referrers that need to be downloaded unless it has no child relations.
     227            // Our "full" overpass query doesn't return the same data as a standard download, so we cannot
     228            // mark relations with no child relations as fully downloaded *yet*.
     229            if (this.considerAsFullDownload()) {
     230                final Collection<Bounds> bounds = this.getBounds();
     231                // We cannot use OsmPrimitive#isOutsideDownloadArea yet since some download methods haven't added
     232                // the download bounds to the dataset yet. This is specifically the case for overpass downloads.
     233                ds.getNodes().stream().filter(n -> bounds.stream().anyMatch(b -> b.contains(n)))
     234                        .forEach(i -> i.setReferrersDownloaded(true));
     235                ds.getWays().forEach(i -> i.setReferrersDownloaded(true));
     236            }
    218237            return ds;
    219238        } catch (OsmTransferException e) {
    220239            throw e;
     
    279298        return true;
    280299    }
    281300
     301    /**
     302     * Get the bounds for this downloader
     303     * @return The bounds for this downloader
     304     * @since xxx
     305     */
     306    protected Collection<Bounds> getBounds() {
     307        return Collections.singleton(new Bounds(this.lat1, this.lon1, this.lat2, this.lon2));
     308    }
    282309}
  • src/org/openstreetmap/josm/io/OverpassDownloadReader.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/io/OverpassDownloadReader.java b/src/org/openstreetmap/josm/io/OverpassDownloadReader.java
    a b  
    1313import java.time.ZoneOffset;
    1414import java.time.format.DateTimeParseException;
    1515import java.util.Arrays;
     16import java.util.Collection;
     17import java.util.Collections;
    1618import java.util.EnumMap;
    1719import java.util.List;
    1820import java.util.Locale;
    1921import java.util.Map;
    2022import java.util.NoSuchElementException;
    2123import java.util.Objects;
     24import java.util.Set;
    2225import java.util.concurrent.ConcurrentHashMap;
    2326import java.util.concurrent.TimeUnit;
    2427import java.util.regex.Matcher;
     
    406409        } else {
    407410            // add bounds if necessary (note that Overpass API does not return bounds in the response XML)
    408411            if (ds != null && ds.getDataSources().isEmpty() && overpassQuery.contains("{{bbox}}")) {
    409                 if (crosses180th) {
    410                     Bounds bounds = new Bounds(lat1, lon1, lat2, 180.0);
    411                     DataSource src = new DataSource(bounds, getBaseUrl());
    412                     ds.addDataSource(src);
    413 
    414                     bounds = new Bounds(lat1, -180.0, lat2, lon2);
    415                     src = new DataSource(bounds, getBaseUrl());
    416                     ds.addDataSource(src);
    417                 } else {
    418                     Bounds bounds = new Bounds(lat1, lon1, lat2, lon2);
    419                     DataSource src = new DataSource(bounds, getBaseUrl());
    420                     ds.addDataSource(src);
    421                 }
     412                getBounds().forEach(bounds -> ds.addDataSource(new DataSource(bounds, getBaseUrl())));
    422413            }
    423414            return ds;
    424415        }
     
    440431    public boolean considerAsFullDownload() {
    441432        return overpassQuery.equals(OverpassDownloadSource.FULL_DOWNLOAD_QUERY);
    442433    }
     434
     435    @Override
     436    protected Collection<Bounds> getBounds() {
     437        if (this.overpassQuery.contains("{{bbox}}")) {
     438            if (crosses180th) {
     439                return Set.of(new Bounds(lat1, lon1, lat2, 180.0),
     440                        new Bounds(lat1, -180.0, lat2, lon2));
     441            } else {
     442                return Collections.singleton(new Bounds(lat1, lon1, lat2, lon2));
     443            }
     444        }
     445        return Collections.emptySet();
     446    }
    443447}