Ignore:
Timestamp:
2011-02-26T00:35:10+01:00 (13 years ago)
Author:
framm
Message:

Changed the way in which JOSM handles imagery layer blacklisting. Instead
of a hard-coded list of Google URLs, we now parse the server's
/api/capabilities response which is expected to look like this:

<osm version="0.6" generator="OpenStreetMap server">

<api>

<version minimum="0.6" maximum="0.6"/>
<area maximum="0.25"/>
<tracepoints per_page="5000"/>
<waynodes maximum="2000"/>
<changesets maximum_elements="50000"/>
<timeout seconds="300"/>

</api>
<policy>

<imagery>

<blacklist regex=".*\.google\.com/.*"/>
<blacklist regex=".*209\.85\.2\d\d.*"/>
<blacklist regex=".*209\.85\.1[3-9]\d.*"/>
<blacklist regex=".*209\.85\.12[89].*"/>

</imagery>

</policy>

</osm>

JOSM will now try to establish an API connection when started, so that
it knows about blacklisted layers. It will also re-read the list when
the URL is changed in the preferences, and if any prohibited layers are
active they will be removed.

For an interim period, JOSM still uses the four regular expressions
listed above whenever the server API URL is *.openstreetmap.org and
the API does not send any blacklist entries. It is expected that the
API will soon return proper blacklist entries.

Things that could be improved:

  1. Establish a general listener system where components can register

their interest in a change of the configured OSM server. Currently
we have to plug through to the gui layer (Main.main.mapView) from
the base comms layer (OsmApi) which is ugly.

  1. Establish a new class of blacklist which works by IP number and not

just regular expression, so that you can say "any host name that resolves
to this IP is blacklisted".

  1. Track all layers that were used in editing a data set, and refuse

uploading if the upload URL bans any of these layers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java

    r3083 r3934  
    3232import org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator;
    3333import org.openstreetmap.josm.gui.widgets.SelectAllOnFocusGainedDecorator;
     34import org.openstreetmap.josm.io.OsmApi;
    3435import org.openstreetmap.josm.tools.ImageProvider;
    3536
     
    136137     */
    137138    public void saveToPreferences() {
     139        String old_url = Main.pref.get("osm-server.url", null);
    138140        if (cbUseDefaultServerUrl.isSelected()) {
    139141            Main.pref.put("osm-server.url", null);
     
    143145            Main.pref.put("osm-server.url", tfOsmServerUrl.getText().trim());
    144146        }
    145 
     147        String new_url = Main.pref.get("osm-server.url", null);
     148
     149        // When API URL changes, re-initialize API connection so we may adjust
     150        // server-dependent settings.
     151        if ((old_url == null && new_url != null) || (old_url != null && !old_url.equals(new_url))) {
     152            try {
     153                OsmApi.getOsmApi().initialize(null);
     154            } catch (Exception x) {
     155                // ignore;
     156            }
     157        }
    146158    }
    147159
Note: See TracChangeset for help on using the changeset viewer.