Changeset 13426 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java
- Timestamp:
- 2009-01-28T21:44:10+01:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java
r13382 r13426 18 18 19 19 import org.openstreetmap.josm.Main; 20 import org.openstreetmap.josm.data.coor.EastNorth; 20 21 import org.openstreetmap.josm.gui.layer.Layer; 21 22 import org.openstreetmap.josm.tools.GBC; … … 38 39 final String c0ptionListStart = "<option value=\""; 39 40 final String cOptionListEnd = "</option>"; 41 final String cBBoxCommunStart = "new GeoBox("; 42 final String cBBoxCommunEnd = ")"; 40 43 41 44 final String cInterfaceVector = "afficherCarteCommune.do"; … … 310 313 } 311 314 315 public EastNorthBound retrieveCommuneBBox() throws IOException { 316 if (interfaceRef == null) 317 return null; 318 String ln = null; 319 String line = null; 320 // send GET opening normally the small window with the commune overview 321 String content = baseURL + "/scpc/" + interfaceRef; 322 content += "&dontSaveLastForward&keepVolatileSession="; 323 searchFormURL = new URL(content); 324 System.out.println("HEAD:"+content); 325 urlConn = (HttpURLConnection)searchFormURL.openConnection(); 326 urlConn.setRequestMethod("GET"); 327 setCookie(); 328 urlConn.connect(); 329 if (urlConn.getResponseCode() != HttpURLConnection.HTTP_OK) { 330 throw (IOException) new IOException("Cannot get Cadastre response."); 331 } 332 BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream())); 333 while ((ln = in.readLine()) != null) { 334 line += ln; 335 } 336 in.close(); 337 urlConn.disconnect(); 338 return parseBBoxCommune(line); 339 } 340 341 private EastNorthBound parseBBoxCommune(String input) { 342 if (input.indexOf(cBBoxCommunStart) != -1) { 343 input = input.substring(input.indexOf(cBBoxCommunStart)); 344 int i = input.indexOf(","); 345 double minx = Double.parseDouble(input.substring(cBBoxCommunStart.length(), i)); 346 int j = input.indexOf(",", i+1); 347 double miny = Double.parseDouble(input.substring(i+1, j)); 348 int k = input.indexOf(",", j+1); 349 double maxx = Double.parseDouble(input.substring(j+1, k)); 350 int l = input.indexOf(cBBoxCommunEnd, k+1); 351 double maxy = Double.parseDouble(input.substring(k+1, l)); 352 return new EastNorthBound(new EastNorth(minx,miny), new EastNorth(maxx,maxy)); 353 } 354 return null; 355 } 356 312 357 private void checkLayerDuplicates(WMSLayer wmsLayer) throws DuplicateLayerException { 313 358 if (Main.map != null) {
Note:
See TracChangeset
for help on using the changeset viewer.
