Ticket #14346: gamma.diff

File gamma.diff, 2.0 KB (added by anonymous, 7 years ago)

Patch providing +gamma support for TM

  • src/org/openstreetmap/josm/data/projection/proj/TransverseMercator.java

     
    106106     */
    107107    private double ml0;
    108108
     109    /**
     110     * The rectified bearing of the central line, in radians.
     111     */
     112    protected double rectifiedGridAngle;
     113
     114    /**
     115     * Sine and Cosine values for the coordinate system rotation angle
     116     */
     117    private double sinrot, cosrot;
     118
    109119    @Override
    110120    public String getName() {
    111121        return tr("Transverse Mercator");
     
    124134        eb2 = params.ellps.eb2;
    125135        latitudeOfOrigin = params.lat0 == null ? 0 : Math.toRadians(params.lat0);
    126136        ml0 = mlfn(latitudeOfOrigin, Math.sin(latitudeOfOrigin), Math.cos(latitudeOfOrigin));
     137
     138        if (params.gamma != null) {
     139                rectifiedGridAngle = Math.toRadians(params.gamma);
     140        } else {
     141                rectifiedGridAngle = 0.0;
     142        }
     143        sinrot = Math.sin(rectifiedGridAngle);
     144        cosrot = Math.cos(rectifiedGridAngle);
     145
    127146    }
    128147
    129148    @Override
     
    130149    public double[] project(double y, double x) {
    131150        double sinphi = Math.sin(y);
    132151        double cosphi = Math.cos(y);
     152        double u, v;
    133153
    134154        double t = (Math.abs(cosphi) > EPSILON) ? sinphi/cosphi : 0;
    135155        t *= t;
     
    150170            FC5 * als * (5.0 + t*(t - 18.0) + n*(14.0 - 58.0*t) +
    151171            FC7 * als * (61.0+ t*(t*(179.0 - t) - 479.0)))));
    152172
     173        u=x; v=y;
     174        x = v * cosrot + u * sinrot;
     175        y = u * cosrot - v * sinrot;
     176
    153177        return new double[] {x, y};
    154178    }
    155179
    156180    @Override
    157181    public double[] invproject(double x, double y) {
     182        double v = x * cosrot - y * sinrot;
     183        double u = y * cosrot + x * sinrot;
     184        x=u; y=v;
     185
    158186        double phi = invMlfn(ml0 + y);
    159187
    160188        if (Math.abs(phi) >= Math.PI/2) {