source: osm/applications/editors/josm/plugins/proj4j/patches/01proj4j-transverse-mercator-fix.patch@ 26606

Last change on this file since 26606 was 26410, checked in by bastik, 14 years ago

Fix Gauß-Krüger projection, wich was completly broken by adding stuff from the jmapprojlib project.

File size: 2.0 KB
  • src/org/osgeo/proj4j/proj/TransverseMercatorProjection.java

    Taken from the jmapprojlib project, fixes Gauß-Krüger projection, wich was completly broken.
    old new  
    1616
    1717/*
    1818 * This file was semi-automatically converted from the public-domain USGS PROJ source.
     19 *
     20 * Bernhard Jenny, February 2 2010: Corrected code for spherical case in
     21 * projectInverse, added isConformal.
     22 * 27 September 2010: added missing tests to forward spherical, removed
     23 * initialization code in constructor.
    1924 */
    2025package org.osgeo.proj4j.proj;
    2126
     
    154159
    155160        public ProjCoordinate projectInverse(double x, double y, ProjCoordinate out) {
    156161                if (spherical) {
    157                         double h = Math.exp(x / scaleFactor);
    158                         double g = .5 * (h - 1. / h);
    159                         h = Math.cos(projectionLatitude + y / scaleFactor);
    160                         out.y = ProjectionMath.asin(Math.sqrt((1. - h*h) / (1. + g*g)));
    161                         if (y < 0)
    162                                 out.y = -out.y;
    163                         out.x = Math.atan2(g, h);
     162                        /*
     163                        Original code
     164                        x = Math.exp(x / scaleFactor);
     165                        y = .5 * (x - 1. / x);
     166                        x = Math.cos(projectionLatitude + y / scaleFactor);
     167                        out.y = MapMath.asin(Math.sqrt((1. - x * x) / (1. + y * y)));
     168                        if (y < 0) {
     169                        out.y = -out.y;
     170                        }
     171                        out.x = Math.atan2(y, x);
     172                         */
     173
     174                        // new code by Bernhard Jenny, February 2 2010
     175                        double D = y / scaleFactor + projectionLatitude;
     176                        double xp = x / scaleFactor;
     177
     178                        out.y = Math.asin(Math.sin(D) / Math.cosh(xp));
     179                        out.x = Math.atan2(Math.sinh(xp), Math.cos(D));
    164180                } else {
    165181                        double n, con, cosphi, d, ds, sinphi, t;
    166182
     
    196212        public boolean hasInverse() {
    197213                return true;
    198214        }
     215       
     216        public boolean isConformal() {
     217                return true;
     218        }
    199219
    200220        public String toString() {
    201221    if (utmZone >= 0)
Note: See TracBrowser for help on using the repository browser.