Ignore:
Timestamp:
2015-12-15T20:55:53+01:00 (8 years ago)
Author:
wiktorn
Message:

Introduce imagery-source warnings about alignment and reprojections.

Introduce new setting to maps.xsd:

  • valid-georeference - which marks imagery sources that are properly georeferenced (i.e. do not need imagery offset adjustments)
  • epsg4326to3857Supported - which marks imagery sources that might be safely queried using EPSG:3857 square BBOX, using EPSG:4326 projection

Make the AlignImageryPanel to show only, when valid-georeference is not set to true and provide the ability to hide this message ("do not show again"), which will be now remembered on per-source basis. Due to this changes, good imagery sources will not show warning to novice users and - experienced users will be presented with a warning, when they open an new imagery source which might be unaligned.

Introduce the ability to check "do not show again" the warning about EPSG:3857 to EPSG:4326 reprojections - as above - on per imagery basis.

All imagery sources should be now reviewed and set valid-georeference=true when appropriate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java

    r9078 r9134  
    1414import javax.swing.AbstractAction;
    1515import javax.swing.Action;
     16import javax.swing.JOptionPane;
    1617
    1718import org.apache.commons.jcs.access.CacheAccess;
     
    2930import org.openstreetmap.josm.data.preferences.IntegerProperty;
    3031import org.openstreetmap.josm.data.projection.Projection;
     32import org.openstreetmap.josm.gui.ExtendedDialog;
    3133
    3234/**
     
    113115    @Override
    114116    public boolean isProjectionSupported(Projection proj) {
    115         return supportedProjections == null || supportedProjections.isEmpty() || supportedProjections.contains(proj.toCode());
     117        return supportedProjections == null || supportedProjections.isEmpty() || supportedProjections.contains(proj.toCode()) ||
     118                (info.isEpsg4326To3857Supported() && supportedProjections.contains("EPSG:4326") &&  "EPSG:3857".equals(Main.getProjection().toCode()));
    116119    }
    117120
     
    124127        String appendix = "";
    125128
    126         if (supportedProjections.contains("EPSG:4326") &&  "EPSG:3857".equals(Main.getProjection().toCode())) {
     129        if (isReprojectionPossible()) {
    127130            appendix = ". " + tr("JOSM will use EPSG:4326 to query the server, but results may vary "
    128131                    + "depending on the WMS server");
     
    133136    @Override
    134137    public void projectionChanged(Projection oldValue, Projection newValue) {
    135         super.projectionChanged(oldValue, newValue);
     138        // do not call super - we need custom warning dialog
     139
     140        if (!isProjectionSupported(newValue)) {
     141            String message = tr("The layer {0} does not support the new projection {1}.\n"
     142                    + " Supported projections are: {2}\n"
     143                    + "Change the projection again or remove the layer.",
     144                    getName(), newValue.toCode(), nameSupportedProjections());
     145
     146            ExtendedDialog warningDialog = new ExtendedDialog(Main.parent, tr("Warning"), new String[]{tr("OK")}).
     147                    setContent(message).
     148                    setIcon(JOptionPane.WARNING_MESSAGE);
     149
     150            if (isReprojectionPossible()) {
     151                warningDialog.toggleEnable("imagery.wms.projectionSupportWarnings." + tileSource.getBaseUrl());
     152            }
     153            warningDialog.showDialog();
     154        }
    136155
    137156        if (!newValue.equals(oldValue) && tileSource instanceof TemplatedWMSTileSource) {
     
    156175        return AbstractCachedTileSourceLayer.getCache(CACHE_REGION_NAME);
    157176    }
     177
     178    private boolean isReprojectionPossible() {
     179        return supportedProjections.contains("EPSG:4326") &&  "EPSG:3857".equals(Main.getProjection().toCode());
     180    }
    158181}
Note: See TracChangeset for help on using the changeset viewer.