Ignore:
Timestamp:
2015-08-24T22:58:21+02:00 (5 years ago)
Author:
simon04
Message:

see #11428 - Make Overpass server configurable

File:
1 edited

Legend:

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

    r8685 r8688  
    1010import java.net.URLEncoder;
    1111import java.util.ArrayList;
     12import java.util.Arrays;
    1213import java.util.Collections;
    1314import java.util.concurrent.Future;
     
    6364            DownloadOsmTask task = new DownloadOsmTask();
    6465            Future<?> future = task.download(
    65                     new OverpassDownloadReader(area, dialog.getOverpassQuery()),
     66                    new OverpassDownloadReader(area, dialog.getOverpassServer(), dialog.getOverpassQuery()),
    6667                    dialog.isNewLayerRequired(), area, null);
    6768            Main.worker.submit(new PostDownloadHandler(task, future));
     
    7172    static final class OverpassDownloadDialog extends DownloadDialog {
    7273
     74        protected HistoryComboBox overpassServer;
    7375        protected HistoryComboBox overpassWizard;
    7476        protected JTextArea overpassQuery;
    7577        private static OverpassDownloadDialog instance;
     78        static final StringProperty OVERPASS_SERVER = new StringProperty("download.overpass.server", "http://overpass-api.de/api/");
     79        static final CollectionProperty OVERPASS_SERVER_HISTORY = new CollectionProperty("download.overpass.servers",
     80                Arrays.asList("http://overpass-api.de/api/", "http://overpass.osm.rambler.ru/cgi/"));
    7681        static final CollectionProperty OVERPASS_WIZARD_HISTORY = new CollectionProperty("download.overpass.wizard", new ArrayList<String>());
    7782
     
    129134            gbc.ipady = 200;
    130135            pnl.add(scrollPane, gbc);
     136
     137            overpassServer = new HistoryComboBox();
     138            pnl.add(new JLabel(tr("Overpass server: ")), GBC.std().insets(5, 5, 5, 5));
     139            pnl.add(overpassServer, GBC.eol().fill(GBC.HORIZONTAL));
     140
     141        }
     142
     143        public String getOverpassServer() {
     144            return overpassServer.getText();
    131145        }
    132146
     
    138152        public void restoreSettings() {
    139153            super.restoreSettings();
     154            overpassServer.setPossibleItems(OVERPASS_SERVER_HISTORY.get());
     155            overpassServer.setText(OVERPASS_SERVER.get());
    140156            overpassWizard.setPossibleItems(OVERPASS_WIZARD_HISTORY.get());
    141157        }
     
    145161            super.rememberSettings();
    146162            overpassWizard.addCurrentItemToHistory();
     163            OVERPASS_SERVER.put(getOverpassServer());
     164            OVERPASS_SERVER_HISTORY.put(overpassServer.getHistory());
    147165            OVERPASS_WIZARD_HISTORY.put(overpassWizard.getHistory());
    148166        }
     
    152170    static class OverpassDownloadReader extends BoundingBoxDownloader {
    153171
     172        final String overpassServer;
    154173        final String overpassQuery;
    155         static final StringProperty OVERPASS_URL = new StringProperty("download.overpass.url", "https://overpass-api.de/api/");
    156 
    157         public OverpassDownloadReader(Bounds downloadArea, String overpassQuery) {
     174
     175        public OverpassDownloadReader(Bounds downloadArea, String overpassServer, String overpassQuery) {
    158176            super(downloadArea);
     177            this.overpassServer = overpassServer;
    159178            this.overpassQuery = overpassQuery.trim();
    160179        }
     
    162181        @Override
    163182        protected String getBaseUrl() {
    164             return OVERPASS_URL.get();
     183            return overpassServer;
    165184        }
    166185
Note: See TracChangeset for help on using the changeset viewer.