Ignore:
Timestamp:
2012-02-02T18:51:49+01:00 (13 years ago)
Author:
roland
Message:

Fallback bounds for downloads. Made server selection box editable.

Location:
applications/editors/josm/plugins/mirrored_download/src/mirrored_download
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mirrored_download/src/mirrored_download/BoundingBoxDownloader2.java

    r27679 r27692  
    1414import org.openstreetmap.josm.data.gpx.GpxData;
    1515import org.openstreetmap.josm.data.osm.DataSet;
     16import org.openstreetmap.josm.data.osm.DataSource;
    1617import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1718import org.xml.sax.SAXException;
     
    1920public class BoundingBoxDownloader2 extends BoundingBoxDownloader {
    2021
     22    /**
     23     * The boundings of the desired map data.
     24     */
     25    private final double lat1;
     26    private final double lon1;
     27    private final double lat2;
     28    private final double lon2;
     29    private final boolean crosses180th;
     30
    2131    public BoundingBoxDownloader2(Bounds downloadArea) {
    2232        super(downloadArea);
     33
     34        this.lat1 = downloadArea.getMin().lat();
     35        this.lon1 = downloadArea.getMin().lon();
     36        this.lat2 = downloadArea.getMax().lat();
     37        this.lon2 = downloadArea.getMax().lon();
     38        this.crosses180th = downloadArea.crosses180thMeridian();
    2339    }
    2440
    25     protected InputStream getInputStream(String urlStr, ProgressMonitor progressMonitor) throws OsmTransferException  {
     41    protected InputStream getInputStream(String urlStr, ProgressMonitor progressMonitor)
     42        throws OsmTransferException  {
     43
    2644        try {
    2745            OsmApi.getOsmApi().initialize(progressMonitor);
     
    3351    }
    3452
     53    public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException {
     54
     55        DataSet ds = super.parseOsm(progressMonitor);
     56
     57        System.out.println(ds.dataSources.toString());
     58        if (ds != null && ds.dataSources.size() == 0)
     59        {
     60            if (crosses180th)
     61            {
     62                Bounds bounds = new Bounds(lat1, lon1, lat2, 180.0);
     63                DataSource src = new DataSource(bounds, MirroredDownloadPlugin.getDownloadUrl());
     64                ds.dataSources.add(src);
     65
     66                bounds = new Bounds(lat1, -180.0, lat2, lon2);
     67                src = new DataSource(bounds, MirroredDownloadPlugin.getDownloadUrl());
     68                ds.dataSources.add(src);
     69            }
     70            else
     71            {
     72                Bounds bounds = new Bounds(lat1, lon1, lat2, lon2);
     73                DataSource src = new DataSource(bounds, MirroredDownloadPlugin.getDownloadUrl());
     74                ds.dataSources.add(src);
     75            }
     76        }
     77        System.out.println(ds.dataSources.toString());
     78
     79        return ds;
     80    }
    3581}
  • applications/editors/josm/plugins/mirrored_download/src/mirrored_download/UrlSelectionDialog.java

    r27691 r27692  
    9797
    9898    cbSelectUrl = new JComboBox();
    99     cbSelectUrl.setEditable(false);
     99    cbSelectUrl.setEditable(true);
    100100
    101101    cbSelectUrl.addItem("http://overpass.osm.rambler.ru/cgi/xapi?");
Note: See TracChangeset for help on using the changeset viewer.