Ticket #7508: possible_fix_7508.patch

File possible_fix_7508.patch, 3.0 KB (added by xeen, 13 years ago)
  • src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java

     
    106106            GpxLayer layer = new GpxLayer(rawData, name);
    107107            Layer x = findMergeLayer();
    108108            if (newLayer || x == null) {
     109                final boolean isDisplayingMapView = Main.isDisplayingMapView();
    109110                Main.main.addLayer(layer);
     111                // if the GPX layer is the only one and no data is available, prevent
     112                // the MapView from zooming in on (0,0), which makes starting another
     113                // download unnecessarily difficult. See #7508.
     114                if(!isDisplayingMapView && rawData.isEmpty() && reader instanceof BoundingBoxDownloader) {
     115                    Bounds b = ((BoundingBoxDownloader) reader).getBounds();
     116                    Main.map.mapView.zoomTo(b);
     117                }
    110118            } else {
    111119                x.mergeFrom(layer);
    112120                Main.map.repaint();
  • src/org/openstreetmap/josm/gui/NavigatableComponent.java

     
    311311        EastNorth e1 = getProjection().latlon2eastNorth(l1);
    312312        EastNorth e2 = getProjection().latlon2eastNorth(l2);
    313313        double d = e2.north() - e1.north();
    314         if(d < height*newScale)
    315         {
    316             double newScaleH = d/height;
     314        if(d < height*newScale && height != 0 && width != 0) {
    317315            e1 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMin().lon()));
    318316            e2 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMax().lon()));
    319317            d = e2.east() - e1.east();
    320318            if(d < width*newScale) {
    321                 newScale = Math.max(newScaleH, d/width);
     319                newScale = Math.max(d/height, d/width);
    322320            }
    323         }
    324         else
    325         {
     321        } else if (height != 0) {
    326322            d = d/(l1.greatCircleDistance(l2)*height*10);
    327323            if(newScale < d) {
    328324                newScale = d;
  • src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

     
    3131        this.crosses180th = downloadArea.crosses180thMeridian();
    3232    }
    3333
     34    public Bounds getBounds() {
     35        return new Bounds(lat1, lon1, lat2, lon2);
     36    }
     37
    3438    private GpxData downloadRawGps(String url, ProgressMonitor progressMonitor) throws IOException, OsmTransferException, SAXException {
    3539        boolean done = false;
    3640        GpxData result = null;