Changeset 32211 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java
- Timestamp:
- 2016-06-01T00:55:28+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java
r32060 r32211 14 14 import java.net.MalformedURLException; 15 15 import java.net.URL; 16 import java.nio.charset.StandardCharsets; 16 17 import java.util.ArrayList; 17 18 import java.util.Collection; … … 38 39 private WMSLayer wmsLayer; 39 40 private CadastreInterface wmsInterface; 40 private String svg = null;41 private static EastNorthBound currentView = null;42 private EastNorthBound viewBox = null;41 private String svg; 42 private static EastNorthBound currentView; 43 private EastNorthBound viewBox; 43 44 private static String errorMessage; 44 45 … … 82 83 @Override 83 84 protected void finish() { 85 // Do nothing 84 86 } 85 87 … … 119 121 // check if new node is not already created by another new path 120 122 Node nearestNewNode = checkNearestNode(nodeToAdd, svgDataSet.getNodes()); 121 if (n earestNewNode == nodeToAdd)123 if (nodeToAdd.equals(nearestNewNode)) 122 124 svgDataSet.addPrimitive(nearestNewNode); 123 125 wayToAdd.addNode(nearestNewNode); // either a new node or an existing one … … 175 177 double dy = Double.parseDouble(coor[2]); 176 178 for (int i=3; i<coor.length; i+=2){ 177 if (coor[i]. equals("")) {179 if (coor[i].isEmpty()) { 178 180 eastNorth.clear(); // some paths are just artifacts 179 181 return; … … 197 199 * @return the already existing node (if any), otherwise the new node candidate. 198 200 */ 199 private Node checkNearestNode(Node nodeToAdd, Collection<Node> nodes) {201 private static Node checkNearestNode(Node nodeToAdd, Collection<Node> nodes) { 200 202 double epsilon = 0.05; // smallest distance considering duplicate node 201 203 for (Node n : nodes) { … … 220 222 } 221 223 222 private URL getURLsvg(EastNorthBound bbox) throws MalformedURLException {223 String str = new String(wmsInterface.baseURL+"/scpc/wms?version=1.1&request=GetMap");224 private static URL getURLsvg(EastNorthBound bbox) throws MalformedURLException { 225 String str = CadastreInterface.BASE_URL+"/scpc/wms?version=1.1&request=GetMap"; 224 226 str += "&layers="; 225 227 str += "CDIF:LS2"; … … 243 245 wmsInterface.setCookie(); 244 246 File file = new File(CadastrePlugin.cacheDir + "building.svg"); 245 String svg = new String();247 String svg = ""; 246 248 try (InputStream is = new ProgressInputStream(wmsInterface.urlConn, NullProgressMonitor.INSTANCE)) { 247 249 if (file.exists()) 248 250 file.delete(); 249 251 try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file, true)); 250 InputStreamReader isr = new InputStreamReader(is );252 InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); 251 253 BufferedReader br = new BufferedReader(isr)) { 252 String line ="";254 String line; 253 255 while ( null!=(line=br.readLine())){ 254 256 line += "\n"; 255 bos.write(line.getBytes( ));257 bos.write(line.getBytes(StandardCharsets.UTF_8)); 256 258 svg += line; 257 259 }
Note:
See TracChangeset
for help on using the changeset viewer.