Changeset 33514 in osm


Ignore:
Timestamp:
2017-08-23T00:34:13+02:00 (7 years ago)
Author:
donvip
Message:

fix #josm15178 - use new HTTPS links from French cadastre - requires JOSM 12623+ to load Certigna certificate from platform keystore (not included in JRE keystore)

Location:
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java

    r33392 r33514  
    77import java.io.IOException;
    88import java.io.InputStream;
    9 import java.net.HttpURLConnection;
    109import java.net.MalformedURLException;
    1110import java.net.URL;
     
    1514import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.data.coor.EastNorth;
    17 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1816import org.openstreetmap.josm.io.OsmTransferException;
    19 import org.openstreetmap.josm.io.ProgressInputStream;
    2017
    2118public class CadastreGrabber {
     
    8683
    8784    private BufferedImage grab(URL url) throws IOException, OsmTransferException {
    88         wmsInterface.urlConn = (HttpURLConnection) url.openConnection();
    89         wmsInterface.urlConn.setRequestProperty("Connection", "close");
    90         wmsInterface.urlConn.setRequestMethod("GET");
    91         wmsInterface.setCookie();
    92         try (InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE)) {
     85        try (InputStream is = wmsInterface.getContent(url)) {
    9386            return ImageIO.read(is);
    9487        }
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java

    r32556 r33514  
    77import java.io.BufferedReader;
    88import java.io.IOException;
     9import java.io.InputStream;
    910import java.io.InputStreamReader;
    1011import java.io.OutputStream;
     
    2930import org.openstreetmap.josm.data.validation.util.Entities;
    3031import org.openstreetmap.josm.gui.layer.Layer;
     32import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     33import org.openstreetmap.josm.gui.util.GuiHelper;
     34import org.openstreetmap.josm.io.OsmTransferException;
     35import org.openstreetmap.josm.io.ProgressInputStream;
    3136import org.openstreetmap.josm.tools.GBC;
    3237
    3338public class CadastreInterface {
    3439    public boolean downloadCanceled;
    35     public HttpURLConnection urlConn;
     40    private HttpURLConnection urlConn;
    3641
    3742    private String cookie;
     
    5358    private long cookieTimestamp;
    5459
    55     static final String BASE_URL = "http://www.cadastre.gouv.fr";
     60    static final String BASE_URL = "https://www.cadastre.gouv.fr";
    5661    static final String C_IMAGE_FORMAT = "Cette commune est au format ";
    5762    static final String C_COMMUNE_LIST_START = "<select name=\"codeCommune\"";
     
    98103        } catch (IOException e) {
    99104            Main.error(e);
    100             JOptionPane.showMessageDialog(Main.parent,
     105            GuiHelper.runInEDT(() ->
     106                JOptionPane.showMessageDialog(Main.parent,
    101107                    tr("Town/city {0} not found or not available\n" +
    102                             "or action canceled", wmsLayer.getLocation()));
     108                            "or action canceled", wmsLayer.getLocation())));
    103109            return false;
    104110        }
     
    191197    }
    192198
    193     public void setCookie() {
     199    private void setCookie() {
    194200        this.urlConn.setRequestProperty("Cookie", this.cookie);
    195201    }
     
    591597        lastWMSLayerName = null;
    592598    }
     599
     600    public InputStream getContent(URL url) throws IOException, OsmTransferException {
     601        urlConn = (HttpURLConnection) url.openConnection();
     602        urlConn.setRequestProperty("Connection", "close");
     603        urlConn.setRequestMethod("GET");
     604        setCookie();
     605        return new ProgressInputStream(urlConn, NullProgressMonitor.INSTANCE);
     606    }
    593607}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java

    r33226 r33514  
    4040
    4141/**
    42  * Plugin to access the French Cadastre WMS server at <a href="http://www.cadastre.gouv.fr">
     42 * Plugin to access the French Cadastre WMS server at <a href="https://www.cadastre.gouv.fr">
    4343 * www.cadastre.gouv.fr</a>.<br>
    4444 * This WMS server requires some specific handling like retrieving a cookie for a
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java

    r32556 r33514  
    1111import java.io.InputStream;
    1212import java.io.InputStreamReader;
    13 import java.net.HttpURLConnection;
    1413import java.net.MalformedURLException;
    1514import java.net.URL;
     
    3130import org.openstreetmap.josm.gui.MapView;
    3231import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    33 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3432import org.openstreetmap.josm.io.OsmTransferException;
    35 import org.openstreetmap.josm.io.ProgressInputStream;
    3633
    3734public class DownloadSVGBuilding extends PleaseWaitRunnable {
     
    243240
    244241    private String grabSVG(URL url) throws IOException, OsmTransferException {
    245         wmsInterface.urlConn = (HttpURLConnection) url.openConnection();
    246         wmsInterface.urlConn.setRequestProperty("Connection", "close");
    247         wmsInterface.urlConn.setRequestMethod("GET");
    248         wmsInterface.setCookie();
    249242        File file = new File(CadastrePlugin.cacheDir + "building.svg");
    250243        String svg = "";
    251         try (InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE)) {
     244        try (InputStream is = wmsInterface.getContent(url)) {
    252245            if (file.exists())
    253246                file.delete();
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java

    r33047 r33514  
    1111import java.io.InputStream;
    1212import java.io.InputStreamReader;
    13 import java.net.HttpURLConnection;
    1413import java.net.MalformedURLException;
    1514import java.net.URL;
     
    3130import org.openstreetmap.josm.data.osm.Way;
    3231import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    33 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3432import org.openstreetmap.josm.io.OsmTransferException;
    35 import org.openstreetmap.josm.io.ProgressInputStream;
     33
    3634/**
    3735 * Grab the SVG administrative boundaries of the active commune layer (cadastre),
     
    193191
    194192    private String grabSVG(URL url) throws IOException, OsmTransferException {
    195         wmsInterface.urlConn = (HttpURLConnection) url.openConnection();
    196         wmsInterface.urlConn.setRequestProperty("Connection", "close");
    197         wmsInterface.urlConn.setRequestMethod("GET");
    198         wmsInterface.setCookie();
    199193        File file = new File(CadastrePlugin.cacheDir + "boundary.svg");
    200194        String svg = "";
    201         try (InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE)) {
     195        try (InputStream is = wmsInterface.getContent(url)) {
    202196            if (file.exists())
    203197                file.delete();
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSPlanImage.java

    r32556 r33514  
    4949                            if (wmsLayer.grabThread.getCacheControl().loadCacheIfExist()) {
    5050                                dontGeoreference = true;
    51                                 Main.map.mapView.repaint();
     51                                wmsLayer.invalidate();
    5252                                return;
    5353                            }
     
    6161                            if (wmsLayer.grabber.getWmsInterface().downloadCanceled) {
    6262                                wmsLayer.clearImages();
    63                                 Main.map.mapView.repaint();
     63                                wmsLayer.invalidate();
    6464                            } else {
    6565                                // next steps follow in method finish() when download is terminated
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GrabThread.java

    r32556 r33514  
    119119                        }
    120120                        wmsLayer.addImage(newImage);
    121                         Main.map.mapView.repaint();
     121                        wmsLayer.invalidate();
    122122                        saveToCache(newImage);
    123123                    } catch (NullPointerException e) {
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageGeoreferencer.java

    r33047 r33514  
    126126              if (countMouseClicked == 2) {
    127127                  wmsLayer.cropImage(ea1, ea);
    128                   Main.map.mapView.repaint();
     128                  wmsLayer.invalidate();
    129129                  startGeoreferencing(wmsLayer);
    130130              }
     
    201201     affineTransform(ea1, ea2, georefpoint1, georefpoint2);
    202202     wmsLayer.grabThread.saveNewCache();
    203      Main.map.mapView.repaint();
     203     wmsLayer.invalidate();
    204204     actionCompleted();
    205205     clickOnTheMap = false;
     
    300300    affineTransform(ea1, ea2, georefpoint1, georefpoint2);
    301301    wmsLayer.grabThread.saveNewCache();
    302     Main.map.mapView.repaint();
     302    wmsLayer.invalidate();
    303303}
    304304
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/SimplifyWay.java

    r33047 r33514  
    6464
    6565    /* From Aviaton Formulary v1.3
    66      * http://williams.best.vwh.net/avform.htm
     66     * http://www.edwilliams.org/avform.htm
    6767     */
    6868    public static double dist(double lat1, double lon1, double lat2, double lon2) {
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java

    r33226 r33514  
    112112            prevEastNorth = newEastNorth;
    113113        }
    114         Main.map.mapView.repaint();
     114        if (modifiedLayer != null) {
     115            modifiedLayer.invalidate();
     116        }
    115117    }
    116118
     
    161163    }
    162164
    163     @Override public void mouseReleased(MouseEvent e) {
     165    @Override
     166    public void mouseReleased(MouseEvent e) {
    164167        if (mode == Mode.rotate) {
    165168            EastNorth newEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
    166169            rotate(prevEastNorth, newEastNorth);
    167             Main.map.mapView.repaint();
     170            if (modifiedLayer != null) {
     171                modifiedLayer.invalidate();
     172            }
    168173        }
    169174        Main.map.mapView.setCursor(Cursor.getDefaultCursor());
     
    188193
    189194    private void saveModifiedLayers() {
    190             modifiedLayer.grabThread.saveNewCache();
     195        modifiedLayer.grabThread.saveNewCache();
    191196    }
    192197}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java

    r33279 r33514  
    9898    private Action refineGeoRef;
    9999
    100     @SuppressWarnings("serial")
    101100    class ResetOffsetActionMenu extends JosmAction {
    102101        ResetOffsetActionMenu() {
     
    108107            deltaEast = 0;
    109108            deltaNorth = 0;
    110             Main.map.mapView.repaint();
     109            invalidate();
    111110        }
    112111    }
Note: See TracChangeset for help on using the changeset viewer.