Ignore:
Timestamp:
2011-10-12T00:39:26+02:00 (14 years ago)
Author:
pieren
Message:

Fixed issues with new offset in grabbing vector images

File:
1 edited

Legend:

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

    r26823 r26835  
    2929    public EastNorth min;
    3030    public EastNorth max;
    31     // offset for vector images temporarily shifted (correcting Cadastre artifacts), in pixels
    32     public double deltaEast=0;
    33     public double deltaNorth=0;
    3431    // bbox of the georeferenced original image (raster only) (inclined if rotated and before cropping)
    3532    // P[0] is bottom,left then next are clockwise.
     
    4340
    4441    public BufferedImage image;
     42    public WMSLayer wmsLayer;
    4543
    4644    private double pixelPerEast;
    4745    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) {
    5049        image = img;
    5150 
     
    6362        this.imageOriginalHeight = (img == null ? 1 : img.getHeight());
    6463        this.imageOriginalWidth = (img == null ? 1 : img.getWidth());
     64        this.wmsLayer = wmsLayer;
    6565        updatePixelPer();
    6666    }
     
    111111
    112112        // 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));
    115120
    116121        if (!g.hitClip(minPt.x, maxPt.y, maxPt.x - minPt.x, minPt.y - maxPt.y))
     
    127132                Point[] croppedPoint = new Point[5];
    128133                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));
    130136                croppedPoint[4] = croppedPoint[0];
    131137                for (int i=0; i<4; i++) {
     
    369375    }
    370376
    371     /**
    372      * Add a temporary translation (dx, dy) to this image (for vector images only)
    373      * @param dx delta added to X image coordinate
    374      * @param dy delta added to Y image coordinate
    375      */
    376     public void tempShear(double dx, double dy) {
    377         this.deltaEast+=dx;
    378         this.deltaNorth+=dy;
    379     }
    380377}
Note: See TracChangeset for help on using the changeset viewer.