Changeset 5381 in josm


Ignore:
Timestamp:
2012-07-30T02:38:20+02:00 (12 years ago)
Author:
Don-vip
Message:

fix #7910 - Wrong suggested imagery layer providers (use of shapes when defined)

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r5369 r5381  
    88import java.util.Collection;
    99import java.util.HashSet;
     10import java.util.Iterator;
    1011import java.util.List;
    1112import java.util.Set;
     
    2021import org.openstreetmap.josm.data.imagery.ImageryInfo;
    2122import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
     23import org.openstreetmap.josm.data.imagery.Shape;
    2224import org.openstreetmap.josm.data.osm.DataSet;
    2325import org.openstreetmap.josm.data.osm.DataSource;
     
    255257                }
    256258            }
     259            // Do not suggest layers already in use
    257260            layers.removeAll(ImageryLayerInfo.instance.getLayers());
     261            // For layers containing complex shapes, check that center is in one of its shapes (fix #7910)
     262            for (Iterator<ImageryInfo> iti = layers.iterator(); iti.hasNext(); ) {
     263                List<Shape> shapes = iti.next().getBounds().getShapes();
     264                if (shapes != null) {
     265                    boolean found = false;
     266                    for (Iterator<Shape> its = shapes.iterator(); its.hasNext() && !found; ) {
     267                        found = its.next().contains(center);
     268                    }
     269                    if (!found) {
     270                        iti.remove();
     271                    }
     272                }
     273            }
     274           
    258275            if (layers.isEmpty()) {
    259276                return;
  • trunk/src/org/openstreetmap/josm/data/imagery/Shape.java

    r4423 r5381  
    1010import org.openstreetmap.gui.jmapviewer.Coordinate;
    1111import org.openstreetmap.josm.data.coor.LatLon;
     12import org.openstreetmap.josm.data.osm.Node;
    1213import org.openstreetmap.josm.tools.CheckParameterUtil;
     14import org.openstreetmap.josm.tools.Geometry;
    1315
    1416/**
     
    2426        String[] components = asString.split(separator);
    2527        if (components.length % 2 != 0)
    26             throw new IllegalArgumentException(MessageFormat.format("Even number of doubles excpected in string, got {0}: {1}", components.length, asString));
     28            throw new IllegalArgumentException(MessageFormat.format("Even number of doubles expected in string, got {0}: {1}", components.length, asString));
    2729        for (int i=0; i<components.length; i+=2) {
    2830            addPoint(components[i], components[i+1]);
     
    4648    public List<Coordinate> getPoints() {
    4749        return coords;
     50    }
     51   
     52    public boolean contains(LatLon latlon) {
     53        if (latlon == null)
     54            return false;
     55        List<Node> nodes = new ArrayList<Node>(coords.size());
     56        for (Coordinate c : coords) {
     57            nodes.add(new Node(new LatLon(c.getLat(), c.getLon())));
     58        }
     59        return Geometry.nodeInsidePolygon(new Node(latlon), nodes);
    4860    }
    4961
Note: See TracChangeset for help on using the changeset viewer.