Changeset 26410 in osm for applications/editors


Ignore:
Timestamp:
2011-07-28T11:41:23+02:00 (13 years ago)
Author:
bastik
Message:

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

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/proj4j/src/org/osgeo/proj4j/proj/TransverseMercatorProjection.java

    r26409 r26410  
    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;
     
    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;
     
    197213                return true;
    198214        }
     215       
     216        public boolean isConformal() {
     217                return true;
     218        }
    199219
    200220        public String toString() {
Note: See TracChangeset for help on using the changeset viewer.