Changeset 9134 in josm for trunk


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.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/maps.xsd

    r8695 r9134  
    689689                                                                </xs:complexType>
    690690                                                        </xs:element>
     691                                                        <!--  is imagery properly georeferenced (i.e. no need to check offsets). Defaults to false. Affects showing warnings. -->
     692                                                        <xs:element name="valid-georeference" minOccurs="0" maxOccurs="1" type="xs:boolean" />
     693                                                        <!-- does imagery server supports JOSM 4326 to 3857 reprojection and non-square queries. Affects showing warnings. -->
     694                                                        <xs:element name="epsg4326to3857Supported" minOccurs="0" maxOccurs="1" type="xs:boolean" />
    691695                                                </xs:choice>
    692696                                        </xs:sequence>
  • trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

    r8853 r9134  
    8383            if (infoToAdd != null) {
    8484                Main.main.addLayer(ImageryLayer.create(infoToAdd));
    85                 AlignImageryPanel.addNagPanelIfNeeded();
     85                AlignImageryPanel.addNagPanelIfNeeded(infoToAdd);
    8686            }
    8787        } catch (IllegalArgumentException ex) {
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r9007 r9134  
    200200    /** icon used in menu */
    201201    private String icon;
    202     // when adding a field, also adapt the ImageryInfo(ImageryInfo) constructor, equals method, and ImageryPreferenceEntry
     202    private boolean isGeoreferenceValid = false;
     203    private boolean isEpsg4326To3857Supported = false;
     204    // when adding a field, also adapt the ImageryInfo(ImageryInfo) and ImageryInfo(ImageryPreferenceEntry) constructor, equals method, and ImageryPreferenceEntry
    203205
    204206    /**
     
    230232        @pref int tileSize = OsmMercator.DEFAUL_TILE_SIZE;
    231233        @pref Map<String, String> metadataHeaders;
     234        @pref boolean valid_georeference;
     235        @pref boolean supports_epsg_4326_to_3857_conversion;
    232236
    233237        /**
     
    292296
    293297            tileSize = i.getTileSize();
     298
     299            valid_georeference = i.isGeoreferenceValid();
     300            supports_epsg_4326_to_3857_conversion = i.isEpsg4326To3857Supported();
     301
    294302        }
    295303
     
    413421        setTileSize(e.tileSize);
    414422        metadataHeaders = e.metadataHeaders;
     423        isEpsg4326To3857Supported = e.supports_epsg_4326_to_3857_conversion;
     424        isGeoreferenceValid = e.valid_georeference;
    415425    }
    416426
     
    441451        this.noTileHeaders = i.noTileHeaders;
    442452        this.metadataHeaders = i.metadataHeaders;
     453        this.isEpsg4326To3857Supported = i.isEpsg4326To3857Supported;
     454        this.isGeoreferenceValid = i.isGeoreferenceValid;
    443455    }
    444456
     
    9931005        this.metadataHeaders = metadataHeaders;
    9941006    }
     1007
     1008    public boolean isEpsg4326To3857Supported() {
     1009        return isEpsg4326To3857Supported;
     1010    }
     1011
     1012    public void setEpsg4326To3857Supported(boolean isEpsg4326To3857Supported) {
     1013        this.isEpsg4326To3857Supported = isEpsg4326To3857Supported;
     1014    }
     1015
     1016    public boolean isGeoreferenceValid() {
     1017        return isGeoreferenceValid;
     1018    }
     1019
     1020    public void setGeoreferenceValid(boolean isGeoreferenceValid) {
     1021        this.isGeoreferenceValid = isGeoreferenceValid;
     1022    }
     1023
    9951024}
  • trunk/src/org/openstreetmap/josm/gui/layer/AlignImageryPanel.java

    r8510 r9134  
    1212
    1313import javax.swing.JButton;
     14import javax.swing.JCheckBox;
    1415import javax.swing.JLabel;
    1516import javax.swing.JPanel;
     
    1920
    2021import org.openstreetmap.josm.Main;
     22import org.openstreetmap.josm.data.imagery.ImageryInfo;
     23import org.openstreetmap.josm.data.preferences.BooleanProperty;
    2124import org.openstreetmap.josm.gui.widgets.UrlLabel;
    2225import org.openstreetmap.josm.tools.GBC;
     
    2932 */
    3033public class AlignImageryPanel extends JPanel {
    31     private static final String PREF = "imagery.offsetnagging";
    3234
    33     public AlignImageryPanel(boolean oneLine) {
     35    /**
     36     * @param oneLine if true, show the nagging message in one line, otherwise - in two lines
     37     * @param showAgain show again property
     38     * @param infoToAdd imagery info for which the nagging message is shown
     39     */
     40    public AlignImageryPanel(boolean oneLine, final BooleanProperty showAgain, ImageryInfo infoToAdd) {
    3441        Font font = getFont().deriveFont(Font.PLAIN, 14.0f);
    35         JLabel nagLabel = new JLabel(tr("Aerial imagery might be misaligned. Please check its offset using GPS tracks!"));
     42        JLabel nagLabel = new JLabel(tr("Aerial imagery \"{0}\" might be misaligned. Please check its offset using GPS tracks!", infoToAdd.getName()));
    3643        UrlLabel detailsList = new UrlLabel(tr("http://wiki.openstreetmap.org/wiki/Using_Imagery"), tr("Details..."));
    3744        nagLabel.setLabelFor(detailsList);
    3845        nagLabel.setFont(font);
    3946        detailsList.setFont(font);
     47        final JCheckBox doNotShowAgain = new JCheckBox(tr("Do not show this message again"));
     48        doNotShowAgain.setOpaque(false);
    4049
    4150        JButton closeButton = new JButton(ImageProvider.get("misc", "black_x"));
     
    4958                if (Main.isDisplayingMapView()) {
    5059                    Main.map.removeTopPanel(AlignImageryPanel.class);
    51                     Main.pref.put(PREF, false);
     60                    if (doNotShowAgain.isSelected()) {
     61                        showAgain.put(false);
     62                    }
    5263                }
    5364            }
     
    5869            add(nagLabel, GBC.std(1, 1).fill());
    5970            add(detailsList, GBC.std(1, 2).fill());
     71            add(doNotShowAgain, GBC.std(1, 3).fill());
    6072            add(closeButton, GBC.std(2, 1).span(1, 2).anchor(GBC.EAST));
    6173        } else {
    6274            add(nagLabel, GBC.std(1, 1).fill());
    6375            add(detailsList, GBC.std(2, 1).fill());
     76            add(doNotShowAgain, GBC.std(1, 2).fill());
    6477            add(closeButton, GBC.std(3, 1).anchor(GBC.EAST));
    6578        }
     
    6881    }
    6982
    70     public static void addNagPanelIfNeeded() {
    71         if (Main.isDisplayingMapView() && !Main.pref.getBoolean("expert") && Main.pref.getBoolean(PREF, true)) {
     83    /**
     84     * @param infoToAdd ImageryInfo for which the nag panel should be created
     85     */
     86    public static void addNagPanelIfNeeded(ImageryInfo infoToAdd) {
     87        BooleanProperty showAgain = new BooleanProperty("message.imagery.nagPanel." + infoToAdd.getUrl(), true);
     88        if (Main.isDisplayingMapView() && showAgain.get() && !infoToAdd.isGeoreferenceValid() ) {
    7289            if (Main.map.getTopPanel(AlignImageryPanel.class) == null) {
    7390                double w = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
    74                 AlignImageryPanel p = new AlignImageryPanel(w > 1300);
     91                AlignImageryPanel p = new AlignImageryPanel(w > 1300, showAgain, infoToAdd);
    7592                Main.map.addTopPanel(p);
    7693            }
  • 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}
  • trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java

    r9078 r9134  
    143143                        "icon",
    144144                        "tile-size",
     145                        "validGeoreference",
     146                        "epsg4326to3857Supported",
    145147                }).contains(qName)) {
    146148                    newState = State.ENTRY_ATTRIBUTE;
     
    324326                    }
    325327                    break;
     328                case "valid-georeference":
     329                    entry.setGeoreferenceValid(new Boolean(accumulator.toString()));
     330                    break;
     331                case "epsg4326to3857Supported":
     332                    entry.setEpsg4326To3857Supported(new Boolean(accumulator.toString()));
     333                    break;
    326334                }
    327335                break;
Note: See TracChangeset for help on using the changeset viewer.