Ignore:
Timestamp:
2017-02-15T11:10:44+01:00 (8 years ago)
Author:
bastik
Message:

add worldfile export

Location:
applications/editors/josm/plugins/piclayer
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/piclayer/nbproject/project.xml

    r32680 r33144  
    5656            </view>
    5757        </general-data>
    58         <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3">
     58        <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/4">
    5959            <compilation-unit>
    6060                <package-root>src</package-root>
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/LoadPictureCalibrationFromWorldAction.java

    r32675 r33144  
    1919
    2020    public LoadPictureCalibrationFromWorldAction(PicLayerAbstract layer) {
    21         super(tr("Load World File Calibration..."), null, tr("Loads calibration data from a world file"), null, false);
     21        super(tr("Import World File Calibration..."), null, tr("Loads calibration data from a world file"), null, false);
    2222
    2323        this.layer = layer;
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerAbstract.java

    r32675 r33144  
    5656import org.openstreetmap.josm.plugins.piclayer.actions.ResetCalibrationAction;
    5757import org.openstreetmap.josm.plugins.piclayer.actions.SavePictureCalibrationAction;
     58import org.openstreetmap.josm.plugins.piclayer.actions.SavePictureCalibrationToWorldAction;
    5859import org.openstreetmap.josm.plugins.piclayer.transform.PictureTransform;
    5960
     
    212213                new SavePictureCalibrationAction(this),
    213214                new LoadPictureCalibrationAction(this),
     215                SeparatorLayerAction.INSTANCE,
     216                new SavePictureCalibrationToWorldAction(this),
    214217                new LoadPictureCalibrationFromWorldAction(this),
    215218                SeparatorLayerAction.INSTANCE,
     
    498501    }
    499502
     503    public void saveWorldFile(double[] values) {
     504        double[] matrix = new double[6];
     505        transformer.getTransform().getMatrix(matrix);
     506        double a00 = matrix[0], a01 = matrix[2], a02 = matrix[4];
     507        double a10 = matrix[1], a11 = matrix[3], a12 = matrix[5];
     508        int w = image.getWidth(null);
     509        int h = image.getHeight(null);
     510        EastNorth imagePosition = transformer.getImagePosition();
     511        // piclayer calibration stores 9 parameters
     512        // worldfile has 6 parameters
     513        // only 6 parameters needed, so write it in a way that
     514        // eliminates the 3 redundant parameters
     515        double qx = initialImageScale / 100 / getMetersPerEasting(imagePosition);
     516        double qy = -initialImageScale / 100 / getMetersPerNorthing(imagePosition);
     517        double sx = qx * a00;
     518        double sy = qy * a11;
     519        double rx = qx * a01;
     520        double ry = qy * a10;
     521        double dx = imagePosition.getX() + qx * a02 - sx * w / 2 - rx * h / 2;
     522        double dy = imagePosition.getY() + qy * a12 - ry * w / 2 - sy * h / 2;
     523        values[0] = sx;
     524        values[1] = ry;
     525        values[2] = rx;
     526        values[3] = sy;
     527        values[4] = dx;
     528        values[5] = dy;
     529    }
     530
    500531    public Point2D transformPoint(Point p) throws NoninvertibleTransformException {
    501532        // Position image at the right graphical place
Note: See TracChangeset for help on using the changeset viewer.