Changeset 26835 in osm for applications
- Timestamp:
- 2011-10-12T00:39:26+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
r26228 r26835 140 140 public boolean loadCache(File file, int currentLambertZone) { 141 141 boolean successfulRead = false; 142 try { 143 FileInputStream fis = new FileInputStream(file); 144 ObjectInputStream ois = new ObjectInputStream(fis); 142 FileInputStream fis = null; 143 ObjectInputStream ois = null; 144 try { 145 fis = new FileInputStream(file); 146 ois = new ObjectInputStream(fis); 145 147 successfulRead = wmsLayer.read(ois, currentLambertZone); 146 ois.close();147 fis.close();148 148 } catch (Exception ex) { 149 149 ex.printStackTrace(System.out); 150 150 JOptionPane.showMessageDialog(Main.parent, tr("Error loading file.\nProbably an old version of the cache file."), tr("Error"), JOptionPane.ERROR_MESSAGE); 151 151 return false; 152 } finally { 153 try { 154 ois.close(); 155 fis.close(); 156 } catch (Exception e) { 157 e.printStackTrace(); 158 } 152 159 } 153 160 if (successfulRead && wmsLayer.isRaster()) { -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java
r24907 r26835 36 36 else 37 37 imageModified = new VectorImageModifier(img, false); 38 return new GeorefImage(imageModified.bufferedImage, lambertMin, lambertMax );38 return new GeorefImage(imageModified.bufferedImage, lambertMin, lambertMax, wmsLayer); 39 39 } catch (MalformedURLException e) { 40 40 throw (IOException) new IOException(tr("CadastreGrabber: Illegal url.")).initCause(e); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GeorefImage.java
r26823 r26835 29 29 public EastNorth min; 30 30 public EastNorth max; 31 // offset for vector images temporarily shifted (correcting Cadastre artifacts), in pixels32 public double deltaEast=0;33 public double deltaNorth=0;34 31 // bbox of the georeferenced original image (raster only) (inclined if rotated and before cropping) 35 32 // P[0] is bottom,left then next are clockwise. … … 43 40 44 41 public BufferedImage image; 42 public WMSLayer wmsLayer; 45 43 46 44 private double pixelPerEast; 47 45 private double pixelPerNorth; 48 49 public GeorefImage(BufferedImage img, EastNorth min, EastNorth max) { 46 47 48 public GeorefImage(BufferedImage img, EastNorth min, EastNorth max, WMSLayer wmsLayer) { 50 49 image = img; 51 50 … … 63 62 this.imageOriginalHeight = (img == null ? 1 : img.getHeight()); 64 63 this.imageOriginalWidth = (img == null ? 1 : img.getWidth()); 64 this.wmsLayer = wmsLayer; 65 65 updatePixelPer(); 66 66 } … … 111 111 112 112 // apply offsets defined manually when vector images are translated manually (not saved in cache) 113 Point minPt = nc.getPoint(new EastNorth(min.east()+deltaEast, min.north()+deltaNorth)); 114 Point maxPt = nc.getPoint(new EastNorth(max.east()+deltaEast, max.north()+deltaNorth)); 113 double dx=0, dy=0; 114 if (wmsLayer!=null) { 115 dx = wmsLayer.deltaEast; 116 dy = wmsLayer.deltaNorth; 117 } 118 Point minPt = nc.getPoint(new EastNorth(min.east()+dx, min.north()+dy)); 119 Point maxPt = nc.getPoint(new EastNorth(max.east()+dx, max.north()+dy)); 115 120 116 121 if (!g.hitClip(minPt.x, maxPt.y, maxPt.x - minPt.x, minPt.y - maxPt.y)) … … 127 132 Point[] croppedPoint = new Point[5]; 128 133 for (int i=0; i<4; i++) 129 croppedPoint[i] = nc.getPoint(orgCroppedRaster[i]); 134 croppedPoint[i] = nc.getPoint( 135 new EastNorth(orgCroppedRaster[i].east()+dx, orgCroppedRaster[i].north()+dy)); 130 136 croppedPoint[4] = croppedPoint[0]; 131 137 for (int i=0; i<4; i++) { … … 369 375 } 370 376 371 /**372 * Add a temporary translation (dx, dy) to this image (for vector images only)373 * @param dx delta added to X image coordinate374 * @param dy delta added to Y image coordinate375 */376 public void tempShear(double dx, double dy) {377 this.deltaEast+=dx;378 this.deltaNorth+=dy;379 }380 377 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
r26823 r26835 85 85 private double rasterRatio; 86 86 87 // offset for vector images temporarily shifted (correcting Cadastre artifacts), in pixels 88 public double deltaEast=0; 89 public double deltaNorth=0; 90 87 91 private Action saveAsPng; 88 92 … … 91 95 @SuppressWarnings("serial") 92 96 class ResetOffsetActionMenu extends JosmAction { 93 private WMSLayer wmsLayer; 94 public ResetOffsetActionMenu(WMSLayer wmsLayer) { 97 public ResetOffsetActionMenu() { 95 98 super(tr("Reset offset"), null, tr("Reset offset (only vector images)"), null, false); 96 this.wmsLayer = wmsLayer;97 99 } 98 100 @Override 99 101 public void actionPerformed(ActionEvent arg0) { 100 for (GeorefImage img:wmsLayer.images) { 101 img.deltaEast = 0; 102 img.deltaNorth = 0; 103 } 102 deltaEast = 0; 103 deltaNorth = 0; 104 104 Main.map.mapView.repaint(); 105 105 } … … 180 180 EastNorth lambertMin = Main.getProjection().latlon2eastNorth(b.getMin()); 181 181 EastNorth lambertMax = Main.getProjection().latlon2eastNorth(b.getMax()); 182 double minEast = lambertMin.east() ;183 double minNorth = lambertMin.north() ;182 double minEast = lambertMin.east()+deltaEast; 183 double minNorth = lambertMin.north()+deltaNorth; 184 184 double dEast = (lambertMax.east() - minEast) / factor; 185 185 double dNorth = (lambertMax.north() - minNorth) / factor; … … 309 309 cancelGrab = new MenuActionCancelGrab(this); 310 310 cancelGrab.setEnabled(!isRaster && grabThread.getImagesToGrabSize() > 0); 311 Action resetOffset = new ResetOffsetActionMenu( this);312 resetOffset.setEnabled(!isRaster && images.size() > 0 && ( images.get(0).deltaEast!=0.0 || images.get(0).deltaNorth!=0.0));311 Action resetOffset = new ResetOffsetActionMenu(); 312 resetOffset.setEnabled(!isRaster && images.size() > 0 && (deltaEast!=0.0 || deltaNorth!=0.0)); 313 313 return new Action[] { 314 314 LayerListDialog.getInstance().createShowHideLayerAction(), … … 338 338 new GeorefImage(null, 339 339 Main.getProjection().latlon2eastNorth(bounds.getMin()), 340 Main.getProjection().latlon2eastNorth(bounds.getMax()) );340 Main.getProjection().latlon2eastNorth(bounds.getMax()), this); 341 341 for (GeorefImage img : images) { 342 342 if (img.overlap(georefImage)) … … 509 509 } 510 510 } 511 newImage.wmsLayer = this; 511 512 this.images.add(newImage); 512 513 } … … 550 551 synchronized(this) { 551 552 images.clear(); 552 images.add(new GeorefImage(new_img, min, max ));553 images.add(new GeorefImage(new_img, min, max, this)); 553 554 } 554 555 } … … 626 627 images.get(0).shear(dx, dy); 627 628 } else { 628 for (GeorefImage image:images)629 image.tempShear(dx, dy);629 deltaEast+=dx; 630 deltaNorth+=dy; 630 631 } 631 632 }
Note:
See TracChangeset
for help on using the changeset viewer.