Ignore:
Timestamp:
2011-10-09T23:41:21+02:00 (14 years ago)
Author:
pieren
Message:

Add a new possibility to shift cadastre vector maps (not saved in cache)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java

    r26509 r26823  
    1111import java.awt.RenderingHints;
    1212import java.awt.Toolkit;
     13import java.awt.event.ActionEvent;
    1314import java.awt.image.BufferedImage;
    1415import java.awt.image.ImageObserver;
     
    2930
    3031import org.openstreetmap.josm.Main;
     32import org.openstreetmap.josm.actions.JosmAction;
    3133import org.openstreetmap.josm.data.Bounds;
    3234import org.openstreetmap.josm.data.coor.EastNorth;
     
    8789    private Action cancelGrab;
    8890
     91    @SuppressWarnings("serial")
     92    class ResetOffsetActionMenu extends JosmAction {
     93        private WMSLayer wmsLayer;
     94        public ResetOffsetActionMenu(WMSLayer wmsLayer) {
     95            super(tr("Reset offset"), null, tr("Reset offset (only vector images)"), null, false);
     96            this.wmsLayer = wmsLayer;
     97        }
     98        @Override
     99        public void actionPerformed(ActionEvent arg0) {
     100            for (GeorefImage img:wmsLayer.images) {
     101                img.deltaEast = 0;
     102                img.deltaNorth = 0;
     103            }
     104            Main.map.mapView.repaint();
     105        }
     106       
     107    }
     108   
    89109    public boolean adjustModeEnabled;
    90110
     
    213233                dividedBbox.add(new EastNorthBound(mid, new EastNorth(mid.east()+c, mid.north()+c)));
    214234            }
    215 //            // simple algorithm to grab all squares
    216 //            minEast = minEast - minEast % cSquare;
    217 //            minNorth = minNorth - minNorth % cSquare;
    218 //            for (int xEast = (int)minEast; xEast < lambertMax.east(); xEast+=cSquare)
    219 //                for (int xNorth = (int)minNorth; xNorth < lambertMax.north(); xNorth+=cSquare) {
    220 //                    dividedBbox.add(new EastNorthBound(new EastNorth(xEast, xNorth),
    221 //                                new EastNorth(xEast + cSquare, xNorth + cSquare)));
    222 //            }
    223235        }
    224236    }
     
    297309        cancelGrab = new MenuActionCancelGrab(this);
    298310        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));
    299313        return new Action[] {
    300314                LayerListDialog.getInstance().createShowHideLayerAction(),
     
    303317                saveAsPng,
    304318                cancelGrab,
     319                resetOffset,
    305320                new LayerListPopup.InfoAction(this),
    306321
     
    566581        return communeBBox;
    567582    }
     583   
     584    public EastNorthBound getFirstViewFromCacheBBox() {
     585        if (isRaster) {
     586            return communeBBox;
     587        }
     588        double min_x = Double.MAX_VALUE;
     589        double max_x = Double.MIN_VALUE;
     590        double min_y = Double.MAX_VALUE;
     591        double max_y = Double.MIN_VALUE;
     592        for (GeorefImage image:images){
     593            min_x = image.min.east() < min_x ? image.min.east() : min_x;
     594            max_x = image.max.east() > max_x ? image.max.east() : max_x;
     595            min_y = image.min.north() < min_y ? image.min.north() : min_y;
     596            max_y = image.max.north() > max_y ? image.max.north() : max_y;
     597        }
     598        EastNorthBound maxGrabbedBBox = new EastNorthBound(new EastNorth(min_x, min_y), new EastNorth(max_x, max_y));
     599        return maxGrabbedBBox;
     600    }
    568601
    569602    public void setCommuneBBox(EastNorthBound entireCommune) {
     
    588621
    589622    public void displace(double dx, double dy) {
    590         this.rasterMin = new EastNorth(rasterMin.east() + dx, rasterMin.north() + dy);
    591         this.rasterMax = new EastNorth(rasterMax.east() + dx, rasterMax.north() + dy);
    592         images.get(0).shear(dx, dy);
     623        if (isRaster) {
     624            this.rasterMin = new EastNorth(rasterMin.east() + dx, rasterMin.north() + dy);
     625            this.rasterMax = new EastNorth(rasterMax.east() + dx, rasterMax.north() + dy);
     626            images.get(0).shear(dx, dy);
     627        } else {
     628            for (GeorefImage image:images)
     629                image.tempShear(dx, dy);
     630        }
    593631    }
    594632
Note: See TracChangeset for help on using the changeset viewer.