Changeset 9021 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2015-11-18T01:39:10+01:00 (8 years ago)
Author:
Don-vip
Message:

fix #11150 - fix wrong bounds computation for multiple data sources in .osm file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r8979 r9021  
    1010import java.util.Arrays;
    1111import java.util.Collection;
     12import java.util.Collections;
    1213import java.util.HashMap;
    1314import java.util.List;
     
    2223import org.openstreetmap.josm.actions.search.PushbackTokenizer.Token;
    2324import org.openstreetmap.josm.data.Bounds;
     25import org.openstreetmap.josm.data.coor.LatLon;
    2426import org.openstreetmap.josm.data.osm.Node;
    2527import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    14221424        }
    14231425
    1424         protected abstract Bounds getBounds();
     1426        protected abstract Collection<Bounds> getBounds();
    14251427
    14261428        @Override
     
    14291431                return false;
    14301432            else if (osm instanceof Node) {
    1431                 Bounds bounds = getBounds();
    1432                 return bounds != null && bounds.contains(((Node) osm).getCoor());
     1433                Collection<Bounds> allBounds = getBounds();
     1434                if (allBounds != null) {
     1435                    LatLon coor = ((Node) osm).getCoor();
     1436                    for (Bounds bounds: allBounds) {
     1437                        if (bounds.contains(coor)) {
     1438                            return true;
     1439                        }
     1440                    }
     1441                }
     1442                return false;
    14331443            } else if (osm instanceof Way) {
    14341444                Collection<Node> nodes = ((Way) osm).getNodes();
     
    14471457    public static class InDataSourceArea extends InArea {
    14481458
     1459        /**
     1460         * Constructs a new {@code InDataSourceArea}.
     1461         * @param all if true, all way nodes or relation members have to be within source area; if false, one suffices.
     1462         */
    14491463        public InDataSourceArea(boolean all) {
    14501464            super(all);
     
    14521466
    14531467        @Override
    1454         protected Bounds getBounds() {
     1468        protected Collection<Bounds> getBounds() {
    14551469            return Main.main.getCurrentDataSet() == null || Main.main.getCurrentDataSet().getDataSourceArea() == null
    1456                     ? null : new Bounds(Main.main.getCurrentDataSet().getDataSourceArea().getBounds2D());
     1470                    ? null : Main.main.getCurrentDataSet().getDataSourceBounds();
    14571471        }
    14581472
     
    14731487
    14741488        @Override
    1475         protected Bounds getBounds() {
     1489        protected Collection<Bounds> getBounds() {
    14761490            if (!Main.isDisplayingMapView()) {
    14771491                return null;
    14781492            }
    1479             return Main.map.mapView.getRealBounds();
     1493            return Collections.singleton(Main.map.mapView.getRealBounds());
    14801494        }
    14811495
Note: See TracChangeset for help on using the changeset viewer.