Changeset 33514 in osm for applications
- Timestamp:
- 2017-08-23T00:34:13+02:00 (7 years ago)
- 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 7 7 import java.io.IOException; 8 8 import java.io.InputStream; 9 import java.net.HttpURLConnection;10 9 import java.net.MalformedURLException; 11 10 import java.net.URL; … … 15 14 import org.openstreetmap.josm.Main; 16 15 import org.openstreetmap.josm.data.coor.EastNorth; 17 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;18 16 import org.openstreetmap.josm.io.OsmTransferException; 19 import org.openstreetmap.josm.io.ProgressInputStream;20 17 21 18 public class CadastreGrabber { … … 86 83 87 84 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)) { 93 86 return ImageIO.read(is); 94 87 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java
r32556 r33514 7 7 import java.io.BufferedReader; 8 8 import java.io.IOException; 9 import java.io.InputStream; 9 10 import java.io.InputStreamReader; 10 11 import java.io.OutputStream; … … 29 30 import org.openstreetmap.josm.data.validation.util.Entities; 30 31 import org.openstreetmap.josm.gui.layer.Layer; 32 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 33 import org.openstreetmap.josm.gui.util.GuiHelper; 34 import org.openstreetmap.josm.io.OsmTransferException; 35 import org.openstreetmap.josm.io.ProgressInputStream; 31 36 import org.openstreetmap.josm.tools.GBC; 32 37 33 38 public class CadastreInterface { 34 39 public boolean downloadCanceled; 35 p ublicHttpURLConnection urlConn;40 private HttpURLConnection urlConn; 36 41 37 42 private String cookie; … … 53 58 private long cookieTimestamp; 54 59 55 static final String BASE_URL = "http ://www.cadastre.gouv.fr";60 static final String BASE_URL = "https://www.cadastre.gouv.fr"; 56 61 static final String C_IMAGE_FORMAT = "Cette commune est au format "; 57 62 static final String C_COMMUNE_LIST_START = "<select name=\"codeCommune\""; … … 98 103 } catch (IOException e) { 99 104 Main.error(e); 100 JOptionPane.showMessageDialog(Main.parent, 105 GuiHelper.runInEDT(() -> 106 JOptionPane.showMessageDialog(Main.parent, 101 107 tr("Town/city {0} not found or not available\n" + 102 "or action canceled", wmsLayer.getLocation())) ;108 "or action canceled", wmsLayer.getLocation()))); 103 109 return false; 104 110 } … … 191 197 } 192 198 193 p ublicvoid setCookie() {199 private void setCookie() { 194 200 this.urlConn.setRequestProperty("Cookie", this.cookie); 195 201 } … … 591 597 lastWMSLayerName = null; 592 598 } 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 } 593 607 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
r33226 r33514 40 40 41 41 /** 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"> 43 43 * www.cadastre.gouv.fr</a>.<br> 44 44 * 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 11 11 import java.io.InputStream; 12 12 import java.io.InputStreamReader; 13 import java.net.HttpURLConnection;14 13 import java.net.MalformedURLException; 15 14 import java.net.URL; … … 31 30 import org.openstreetmap.josm.gui.MapView; 32 31 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 33 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;34 32 import org.openstreetmap.josm.io.OsmTransferException; 35 import org.openstreetmap.josm.io.ProgressInputStream;36 33 37 34 public class DownloadSVGBuilding extends PleaseWaitRunnable { … … 243 240 244 241 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();249 242 File file = new File(CadastrePlugin.cacheDir + "building.svg"); 250 243 String svg = ""; 251 try (InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE)) {244 try (InputStream is = wmsInterface.getContent(url)) { 252 245 if (file.exists()) 253 246 file.delete(); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java
r33047 r33514 11 11 import java.io.InputStream; 12 12 import java.io.InputStreamReader; 13 import java.net.HttpURLConnection;14 13 import java.net.MalformedURLException; 15 14 import java.net.URL; … … 31 30 import org.openstreetmap.josm.data.osm.Way; 32 31 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 33 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;34 32 import org.openstreetmap.josm.io.OsmTransferException; 35 import org.openstreetmap.josm.io.ProgressInputStream; 33 36 34 /** 37 35 * Grab the SVG administrative boundaries of the active commune layer (cadastre), … … 193 191 194 192 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();199 193 File file = new File(CadastrePlugin.cacheDir + "boundary.svg"); 200 194 String svg = ""; 201 try (InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE)) {195 try (InputStream is = wmsInterface.getContent(url)) { 202 196 if (file.exists()) 203 197 file.delete(); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSPlanImage.java
r32556 r33514 49 49 if (wmsLayer.grabThread.getCacheControl().loadCacheIfExist()) { 50 50 dontGeoreference = true; 51 Main.map.mapView.repaint();51 wmsLayer.invalidate(); 52 52 return; 53 53 } … … 61 61 if (wmsLayer.grabber.getWmsInterface().downloadCanceled) { 62 62 wmsLayer.clearImages(); 63 Main.map.mapView.repaint();63 wmsLayer.invalidate(); 64 64 } else { 65 65 // next steps follow in method finish() when download is terminated -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GrabThread.java
r32556 r33514 119 119 } 120 120 wmsLayer.addImage(newImage); 121 Main.map.mapView.repaint();121 wmsLayer.invalidate(); 122 122 saveToCache(newImage); 123 123 } catch (NullPointerException e) { -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageGeoreferencer.java
r33047 r33514 126 126 if (countMouseClicked == 2) { 127 127 wmsLayer.cropImage(ea1, ea); 128 Main.map.mapView.repaint();128 wmsLayer.invalidate(); 129 129 startGeoreferencing(wmsLayer); 130 130 } … … 201 201 affineTransform(ea1, ea2, georefpoint1, georefpoint2); 202 202 wmsLayer.grabThread.saveNewCache(); 203 Main.map.mapView.repaint();203 wmsLayer.invalidate(); 204 204 actionCompleted(); 205 205 clickOnTheMap = false; … … 300 300 affineTransform(ea1, ea2, georefpoint1, georefpoint2); 301 301 wmsLayer.grabThread.saveNewCache(); 302 Main.map.mapView.repaint();302 wmsLayer.invalidate(); 303 303 } 304 304 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/SimplifyWay.java
r33047 r33514 64 64 65 65 /* From Aviaton Formulary v1.3 66 * http://w illiams.best.vwh.net/avform.htm66 * http://www.edwilliams.org/avform.htm 67 67 */ 68 68 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 112 112 prevEastNorth = newEastNorth; 113 113 } 114 Main.map.mapView.repaint(); 114 if (modifiedLayer != null) { 115 modifiedLayer.invalidate(); 116 } 115 117 } 116 118 … … 161 163 } 162 164 163 @Override public void mouseReleased(MouseEvent e) { 165 @Override 166 public void mouseReleased(MouseEvent e) { 164 167 if (mode == Mode.rotate) { 165 168 EastNorth newEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY()); 166 169 rotate(prevEastNorth, newEastNorth); 167 Main.map.mapView.repaint(); 170 if (modifiedLayer != null) { 171 modifiedLayer.invalidate(); 172 } 168 173 } 169 174 Main.map.mapView.setCursor(Cursor.getDefaultCursor()); … … 188 193 189 194 private void saveModifiedLayers() { 190 195 modifiedLayer.grabThread.saveNewCache(); 191 196 } 192 197 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
r33279 r33514 98 98 private Action refineGeoRef; 99 99 100 @SuppressWarnings("serial")101 100 class ResetOffsetActionMenu extends JosmAction { 102 101 ResetOffsetActionMenu() { … … 108 107 deltaEast = 0; 109 108 deltaNorth = 0; 110 Main.map.mapView.repaint();109 invalidate(); 111 110 } 112 111 }
Note:
See TracChangeset
for help on using the changeset viewer.