Ignore:
Timestamp:
2010-02-28T16:29:31+01:00 (15 years ago)
Author:
pieren
Message:

Fixed image rotation and a null pointer exception in adjust mode (raster maps only).

File:
1 edited

Legend:

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

    r19949 r20211  
    5454    /**
    5555     * v1 to v2 = not supported
    56      * v2 to v3 = add 4 more EastNorth coordinates in GeorefImages
    57      */
    58     protected final int serializeFormatVersion = 3;
     56     * v2 to v3 = add 4 more EastNorth coordinates in GeorefImages
     57     * v3 to v4 = add original raster image width and height
     58     */
     59    protected final int serializeFormatVersion = 4;
    5960   
    6061    public static int currentFormat;
     
    535536        EastNorth adj2 = new EastNorth(en1.east() > en2.east() ? en1.east() : en2.east(),
    536537                en1.north() > en2.north() ? en1.north() : en2.north());
    537         // s1 and s2 have 0,0 at top, left where all EastNorth coord. have 0,0 at bottom, left
    538         int sx1 = (int)((adj1.getX() - images.get(0).min.getX())*images.get(0).getPixelPerEast());
    539         int sy1 = (int)((images.get(0).max.getY() - adj2.getY())*images.get(0).getPixelPerNorth());
    540         int sx2 = (int)((adj2.getX() - images.get(0).min.getX())*images.get(0).getPixelPerEast());
    541         int sy2 = (int)((images.get(0).max.getY() - adj1.getY())*images.get(0).getPixelPerNorth());
    542         int newWidth = Math.abs(sx2 - sx1);
    543         int newHeight = Math.abs(sy2 - sy1);
    544         BufferedImage new_img = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_ARGB);
    545         Graphics g = new_img.getGraphics();
    546         g.drawImage(images.get(0).image, 0, 0, newWidth-1, newHeight-1,
    547                 sx1, sy1, sx2, sy2,
    548                 this);
    549         images.set(0, new GeorefImage(new_img, adj1, adj2));
    550         // important: update the layer georefs !
     538        images.get(0).crop(adj1, adj2);
     539        // update the layer georefs
    551540        rasterMin = adj1;
    552541        rasterMax = adj2;
     542        setCommuneBBox(new EastNorthBound(new EastNorth(0,0), new EastNorth(images.get(0).image.getWidth()-1,images.get(0).image.getHeight()-1)));
    553543        rasterRatio = (rasterMax.getX()-rasterMin.getX())/(communeBBox.max.getX() - communeBBox.min.getX());
    554         setCommuneBBox(new EastNorthBound(new EastNorth(0,0), new EastNorth(newWidth-1,newHeight-1)));
    555544    }
    556545
     
    581570    public void displace(double dx, double dy) {
    582571        this.rasterMin = new EastNorth(rasterMin.east() + dx, rasterMin.north() + dy);
     572        this.rasterMax = new EastNorth(rasterMax.east() + dx, rasterMax.north() + dy);
    583573        images.get(0).shear(dx, dy);
    584574    }
     
    586576    public void resize(EastNorth rasterCenter, double proportion) {
    587577        this.rasterMin = rasterMin.interpolate(rasterCenter, proportion);
     578        this.rasterMax = rasterMax.interpolate(rasterCenter, proportion);
    588579        images.get(0).scale(rasterCenter, proportion);
    589580    }
     
    591582    public void rotate(EastNorth rasterCenter, double angle) {
    592583        this.rasterMin = rasterMin.rotate(rasterCenter, angle);
     584        this.rasterMax = rasterMax.rotate(rasterCenter, angle);
     585//        double proportion = dst1.distance(dst2)/org1.distance(org2);
    593586        images.get(0).rotate(rasterCenter, angle);
     587        this.angle += angle;
    594588    }
    595589
Note: See TracChangeset for help on using the changeset viewer.