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/GeorefImage.java

    r24955 r26823  
    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;
    3134    // bbox of the georeferenced original image (raster only) (inclined if rotated and before cropping)
    3235    // P[0] is bottom,left then next are clockwise.
     
    107110            return;
    108111
    109         Point minPt = nc.getPoint(min), maxPt = nc.getPoint(max);
     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));
    110115
    111116        if (!g.hitClip(minPt.x, maxPt.y, maxPt.x - minPt.x, minPt.y - maxPt.y))
     
    171176        double maxMaskNorth = (georefImage.max.north() < this.max.north()) ? georefImage.max.north() : this.max.north();
    172177        if ((maxMaskNorth - minMaskNorth) > 0 && (maxMaskEast - minMaskEast) > 0) {
    173             double pixelPerEast = (max.east() - min.east()) / image.getWidth();
    174             double pixelPerNorth = (max.north() - min.north()) / image.getHeight();
    175             int minXMaskPixel = (int) ((minMaskEast - min.east()) / pixelPerEast);
    176             int minYMaskPixel = (int) ((max.north() - maxMaskNorth) / pixelPerNorth);
    177             int widthXMaskPixel = Math.abs((int) ((maxMaskEast - minMaskEast) / pixelPerEast));
    178             int heightYMaskPixel = Math.abs((int) ((maxMaskNorth - minMaskNorth) / pixelPerNorth));
     178            double pxPerEast = (max.east() - min.east()) / image.getWidth();
     179            double pxPerNorth = (max.north() - min.north()) / image.getHeight();
     180            int minXMaskPixel = (int) ((minMaskEast - min.east()) / pxPerEast);
     181            int minYMaskPixel = (int) ((max.north() - maxMaskNorth) / pxPerNorth);
     182            int widthXMaskPixel = Math.abs((int) ((maxMaskEast - minMaskEast) / pxPerEast));
     183            int heightYMaskPixel = Math.abs((int) ((maxMaskNorth - minMaskNorth) / pxPerNorth));
    179184            Graphics g = image.getGraphics();
    180185            for (int x = minXMaskPixel; x < minXMaskPixel + widthXMaskPixel; x++)
     
    279284        }
    280285    }
    281 
     286   
    282287    /**
    283288     * Change this image scale by moving the min,max coordinates around an anchor
     
    364369    }
    365370
     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    }
    366380}
Note: See TracChangeset for help on using the changeset viewer.