Changeset 24907 in osm for applications/editors/josm/plugins
- Timestamp:
- 2010-12-29T23:18:37+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
- Files:
-
- 3 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
r23190 r24907 96 96 public boolean loadCacheIfExist() { 97 97 try { 98 if (!wmsLayer.isBuildingsOnly()) { 99 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + WMSFileExtension()); 100 if (file.exists()) { 101 JOptionPane pane = new JOptionPane( 102 tr("Location \"{0}\" found in cache.\n"+ 103 "Load cache first ?\n"+ 104 "(No = new cache)", wmsLayer.getName()), 105 JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null); 106 // this below is a temporary workaround to fix the "always on top" issue 107 JDialog dialog = pane.createDialog(Main.parent, tr("Select Feuille")); 108 CadastrePlugin.prepareDialog(dialog); 109 dialog.setVisible(true); 110 int reply = (Integer)pane.getValue(); 111 // till here 112 113 if (reply == JOptionPane.OK_OPTION && loadCache(file, wmsLayer.getLambertZone())) { 114 return true; 115 } else { 116 delete(file); 117 } 118 } 119 } else { 120 int i=0; 121 while (new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "."+i+"."+ WMSFileExtension()).exists()) 122 i++; 123 wmsLayer.setName(wmsLayer.getName()+"."+i); 98 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + WMSFileExtension()); 99 if (file.exists()) { 100 JOptionPane pane = new JOptionPane( 101 tr("Location \"{0}\" found in cache.\n"+ 102 "Load cache first ?\n"+ 103 "(No = new cache)", wmsLayer.getName()), 104 JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null); 105 // this below is a temporary workaround to fix the "always on top" issue 106 JDialog dialog = pane.createDialog(Main.parent, tr("Select Feuille")); 107 CadastrePlugin.prepareDialog(dialog); 108 dialog.setVisible(true); 109 int reply = (Integer)pane.getValue(); 110 // till here 111 112 if (reply == JOptionPane.OK_OPTION && loadCache(file, wmsLayer.getLambertZone())) { 113 return true; 114 } else { 115 delete(file); 116 } 124 117 } 125 118 } catch (Exception e) { -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java
r23190 r24907 37 37 imageModified = new VectorImageModifier(img, false); 38 38 return new GeorefImage(imageModified.bufferedImage, lambertMin, lambertMax); 39 } catch (MalformedURLException e) {40 throw (IOException) new IOException(tr("CadastreGrabber: Illegal url.")).initCause(e);41 }42 }43 44 public GeorefImage grabBuildings(WMSLayer wmsLayer, EastNorth lambertMin, EastNorth lambertMax) throws IOException, OsmTransferException {45 try {46 URL url = getURLVectorBuildings(lambertMin, lambertMax);47 BufferedImage img = grab(url);48 ImageModifier imageModified = new VectorImageModifier(img, true);49 return new GeorefImage(imageModified.bufferedImage, lambertMin, lambertMax);50 } catch (MalformedURLException e) {51 throw (IOException) new IOException(tr("CadastreGrabber: Illegal url.")).initCause(e);52 }53 }54 55 public GeorefImage grabParcels(WMSLayer wmsLayer, EastNorth lambertMin, EastNorth lambertMax) throws IOException, OsmTransferException {56 try {57 URL url = getURLVectorParcels(lambertMin, lambertMax);58 BufferedImage img = grab(url);59 //ImageModifier imageModified = new VectorImageModifier(img, true);60 return new GeorefImage(/*imageModified.bufferedImage*/img, lambertMin, lambertMax);61 39 } catch (MalformedURLException e) { 62 40 throw (IOException) new IOException(tr("CadastreGrabber: Illegal url.")).initCause(e); … … 105 83 } 106 84 107 private URL getURLVectorBuildings(EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {108 return buildURLVector("CDIF:LS2", "LS2_90", 1000, 800, lambertMin, lambertMax);109 }110 111 private URL getURLVectorParcels(EastNorth lambertMin, EastNorth lambertMax) throws MalformedURLException {112 return buildURLVector("CDIF:PARCELLE", "PARCELLE_90", 1000, 800, lambertMin, lambertMax);113 }114 115 85 private BufferedImage grab(URL url) throws IOException, OsmTransferException { 116 86 wmsInterface.urlConn = (HttpURLConnection)url.openConnection(); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java
r24899 r24907 20 20 private static String errorMessage; 21 21 22 public DownloadWMSVectorImage(WMSLayer wmsLayer, Bounds bounds , boolean buildingsOnly) {22 public DownloadWMSVectorImage(WMSLayer wmsLayer, Bounds bounds) { 23 23 super(tr("Downloading {0}", wmsLayer.getName())); 24 24 25 25 this.wmsLayer = wmsLayer; 26 26 this.bounds = bounds; 27 this.wmsLayer.setBuildingsOnly(buildingsOnly);28 27 } 29 28 … … 84 83 } 85 84 86 public static void download(WMSLayer wmsLayer , boolean buildingsOnly) {85 public static void download(WMSLayer wmsLayer) { 87 86 MapView mv = Main.map.mapView; 88 87 Bounds bounds = new Bounds(mv.getLatLon(0, mv.getHeight()), mv.getLatLon(mv.getWidth(), 0)); 89 88 90 Main.worker.execute(new DownloadWMSVectorImage(wmsLayer, bounds , buildingsOnly));89 Main.worker.execute(new DownloadWMSVectorImage(wmsLayer, bounds)); 91 90 if (errorMessage != null) 92 91 JOptionPane.showMessageDialog(Main.parent, errorMessage); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrab.java
r20390 r24907 33 33 WMSLayer wmsLayer = WMSDownloadAction.getLayer(); 34 34 if (wmsLayer != null) 35 DownloadWMSVectorImage.download(wmsLayer , false);35 DownloadWMSVectorImage.download(wmsLayer); 36 36 } else { 37 37 JOptionPane.showMessageDialog(Main.parent, -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java
r23190 r24907 58 58 WMSLayer wmsLayer = addNewLayer(new ArrayList<WMSLayer>()); 59 59 if (wmsLayer != null) 60 DownloadWMSVectorImage.download(wmsLayer , false);60 DownloadWMSVectorImage.download(wmsLayer); 61 61 } 62 62 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java
r20390 r24907 30 30 if (Main.map != null) { 31 31 Layer activeLayer = Main.map.mapView.getActiveLayer(); 32 if (activeLayer instanceof WMSLayer && !((WMSLayer)activeLayer).isBuildingsOnly())32 if (activeLayer instanceof WMSLayer) 33 33 return (WMSLayer) activeLayer; 34 34 for (Layer l : Main.map.mapView.getAllLayers()) { 35 if (l instanceof WMSLayer && !((WMSLayer)l).isBuildingsOnly()) {35 if (l instanceof WMSLayer) { 36 36 existingWMSlayers.add((WMSLayer)l); 37 37 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
r23190 r24907 59 59 public static int currentFormat; 60 60 61 private static final int cBBoxForBuildings = 50; // hard coded size of grabbed boxes for building layers62 63 61 private ArrayList<EastNorthBound> dividedBbox = new ArrayList<EastNorthBound>(); 64 62 … … 77 75 private boolean isRaster = false; 78 76 private boolean isAlreadyGeoreferenced = false; 79 private boolean buildingsOnly = false;80 77 public double X0, Y0, angle, fX, fY; 81 78 … … 95 92 96 93 public WMSLayer(String location, String codeCommune, int lambertZone) { 97 super(buildName(location, codeCommune , false));94 super(buildName(location, codeCommune)); 98 95 this.location = location; 99 96 this.codeCommune = codeCommune; … … 118 115 } 119 116 120 private static String buildName(String location, String codeCommune , boolean buildingOnly) {117 private static String buildName(String location, String codeCommune) { 121 118 String ret = location.toUpperCase(); 122 119 if (codeCommune != null && !codeCommune.equals("")) 123 120 ret += "(" + codeCommune + ")"; 124 if (buildingOnly)125 ret += ".b";126 121 return ret; 127 122 } 128 123 129 124 private String rebuildName() { 130 return buildName(this.location.toUpperCase(), this.codeCommune , this.buildingsOnly);125 return buildName(this.location.toUpperCase(), this.codeCommune); 131 126 } 132 127 … … 142 137 divideBbox(b, Integer.parseInt(Main.pref.get("cadastrewms.rasterDivider", 143 138 CadastrePreferenceSetting.DEFAULT_RASTER_DIVIDER)), 0); 144 } else if (buildingsOnly) 145 divideBbox(b, 5, cBBoxForBuildings); 146 else 139 } else 147 140 divideBbox(b, Integer.parseInt(Main.pref.get("cadastrewms.scale", Scale.X1.toString())), 0); 148 141 } else … … 155 148 GeorefImage newImage; 156 149 try { 157 if (buildingsOnly == false) 158 newImage = grabber.grab(this, n.min, n.max); 159 else { // TODO 160 GeorefImage buildings = grabber.grabBuildings(this, n.min, n.max); 161 GeorefImage parcels = grabber.grabParcels(this, n.min, n.max); 162 new BuildingsImageModifier(buildings, parcels); 163 newImage = buildings; 164 } 150 newImage = grabber.grab(this, n.min, n.max); 165 151 } catch (IOException e) { 166 152 System.out.println("Download action cancelled by user or server did not respond"); … … 189 175 } 190 176 if (!cancelled) { 191 if (buildingsOnly)192 joinBufferedImages();193 177 for (int i=lastSavedImage; i < images.size(); i++) 194 178 saveToCache(images.get(i)); … … 197 181 198 182 /** 199 * 183 * Divides the bounding box in smaller polygons. 184 * 200 185 * @param b the original bbox, usually the current bbox on screen 201 186 * @param factor 1 = source bbox 1:1 … … 398 383 } 399 384 400 public boolean isBuildingsOnly() {401 return buildingsOnly;402 }403 404 public void setBuildingsOnly(boolean buildingsOnly) {405 this.buildingsOnly = buildingsOnly;406 setName(rebuildName());407 }408 409 385 public boolean isRaster() { 410 386 return isRaster; … … 458 434 oos.writeInt(this.lambertZone); 459 435 oos.writeBoolean(this.isRaster); 460 oos.writeBoolean( this.buildingsOnly);436 oos.writeBoolean(false); // previously buildingsOnly 461 437 if (this.isRaster) { 462 438 oos.writeDouble(this.rasterMin.getX()); … … 491 467 this.setRaster(ois.readBoolean()); 492 468 if (currentFormat >= 4) 493 this.setBuildingsOnly(ois.readBoolean());469 ois.readBoolean(); 494 470 if (this.isRaster) { 495 471 double X = ois.readDouble();
Note:
See TracChangeset
for help on using the changeset viewer.