Changeset 11549 in josm


Ignore:
Timestamp:
2017-02-10T15:44:42+01:00 (8 years ago)
Author:
bastiK
Message:

applied #14346 Rotation angle for Transverse Mercator projection (based on patch by anonymous)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/proj/TransverseMercator.java

    r10748 r11549  
    4747 * at the time of migration.
    4848 * <p>
    49  *
     49 * The non-standard parameter <code>gamma</code> has been added as a method
     50 * to rotate the projected coordinates by a certain angle (clockwise, see
     51 * {@link ObliqueMercator}).
     52 * <p>
    5053 * <b>References:</b>
    5154 * <ul>
     
    107110    private double ml0;
    108111
     112    /**
     113     * The rectified bearing of the central line, in radians.
     114     */
     115    protected double rectifiedGridAngle;
     116
     117    /**
     118     * Sine and Cosine values for the coordinate system rotation angle
     119     */
     120    private double sinrot, cosrot;
     121
    109122    @Override
    110123    public String getName() {
     
    125138        latitudeOfOrigin = params.lat0 == null ? 0 : Math.toRadians(params.lat0);
    126139        ml0 = mlfn(latitudeOfOrigin, Math.sin(latitudeOfOrigin), Math.cos(latitudeOfOrigin));
     140
     141        if (params.gamma != null) {
     142                rectifiedGridAngle = Math.toRadians(params.gamma);
     143        } else {
     144                rectifiedGridAngle = 0.0;
     145        }
     146        sinrot = Math.sin(rectifiedGridAngle);
     147        cosrot = Math.cos(rectifiedGridAngle);
     148
    127149    }
    128150
     
    131153        double sinphi = Math.sin(y);
    132154        double cosphi = Math.cos(y);
     155        double u, v;
    133156
    134157        double t = (Math.abs(cosphi) > EPSILON) ? sinphi/cosphi : 0;
     
    151174            FC7 * als * (61.0+ t*(t*(179.0 - t) - 479.0)))));
    152175
     176        u=y; v=x;
     177        x = v * cosrot + u * sinrot;
     178        y = u * cosrot - v * sinrot;
     179
    153180        return new double[] {x, y};
    154181    }
     
    156183    @Override
    157184    public double[] invproject(double x, double y) {
     185        double v = x * cosrot - y * sinrot;
     186        double u = y * cosrot + x * sinrot;
     187        x=v; y=u;
     188
    158189        double phi = invMlfn(ml0 + y);
    159190
Note: See TracChangeset for help on using the changeset viewer.