forked from geodmms/xdgnjobs

?? ?
2008-04-14 7840e31dd97db0efe77bdf859ac2fe9767d3dd1a
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/util/TWDDatumConverter.java
@@ -1,5 +1,7 @@
package com.ximple.eofms.util;
import com.vividsolutions.jts.geom.Coordinate;
/**
 * TWDDatumConverter
 * User: Ulysses
@@ -49,7 +51,7 @@
    /*
     * datum convert function
     */
    void toTWD97(double x, double y, double z)
    public static Coordinate toTWD97(Coordinate pt)
    {
        double newX, newY, newZ;
        double r, pole, sin_lat, cos_lat;
@@ -57,9 +59,9 @@
        double x1, y1, z1, x2, y2, z2;
        double q, q2, t, t1, s, s1, sum, sin_b, cos_b, sin_p, cos_p;
        lon    = x * DEG_RAD;
        lat    = y * DEG_RAD;
        height = z * DEG_RAD;
        lon    = pt.x * DEG_RAD;
        lat    = pt.y * DEG_RAD;
        height = pt.z * DEG_RAD;
        if ((lat < -HALF_PI) && (lat > -1.001 * HALF_PI))
        {
@@ -69,7 +71,7 @@
            lat = HALF_PI;
        } else if ((lat < -HALF_PI) || (lat > HALF_PI))
        {
            return;
            return null;
        }
        if (lon > PI)
@@ -117,7 +119,7 @@
                    newY = lat * RAD_DEG;
                    newZ = -TWD97_B;
                    return;
                    return new Coordinate(newX, newY, newZ);
                }
            }
        }
@@ -154,9 +156,10 @@
        newX = lon * RAD_DEG;
        newY = lat * RAD_DEG;
        newZ = height;
        return new Coordinate(newX, newY, newZ);
    }
    void toTWD67(double x, double y, double z)
    public static Coordinate toTWD67(Coordinate pt)
    {
        double newX, newY, newZ;
        double r, pole, sin_lat, cos_lat;
@@ -164,9 +167,9 @@
        double x1, y1, z1, x2, y2, z2;
        double q, q2, t, t1, s, s1, sum, sin_b, cos_b, sin_p, cos_p;
        lon    = x * DEG_RAD;
        lat    = y * DEG_RAD;
        height = z * DEG_RAD;
        lon    = pt.x * DEG_RAD;
        lat    = pt.y * DEG_RAD;
        height = pt.z * DEG_RAD;
        if ((lat < -HALF_PI) && (lat > -1.001 * HALF_PI))
        {
@@ -176,7 +179,7 @@
            lat = HALF_PI;
        } else if ((lat < -HALF_PI) || (lat > HALF_PI))
        {
            return;
            return null;
        }
        if (lon > PI)
@@ -224,7 +227,7 @@
                    newY = lat * RAD_DEG;
                    newZ = -TWD67_B;
                    return;
                    return new Coordinate(newX, newY, newZ);
                }
            }
        }
@@ -261,9 +264,10 @@
        newX = lon * RAD_DEG;
        newY = lat * RAD_DEG;
        newZ = height;
        return new Coordinate(newX, newY, newZ);
    }
    void toTM2(double a, double ecc, double ecc2, double lat, double lon, double scale, double x, double y)
    public static void toTM2(double a, double ecc, double ecc2, double lat, double lon, double scale, double x, double y)
    {
        double x0, y0, x1, y1, m0, m1;
        double n, t, c, A;
@@ -289,7 +293,7 @@
                       + (61.0 - 58.0 * t + t * t + 600.0 * c - 330.0 * ecc2) * Math.pow(A, 6.0) / 720.0));
    }
    void fromTM2(double a, double ecc, double ecc2, double lat, double lon, double scale, double x, double y)
    public static void fromTM2(double a, double ecc, double ecc2, double lat, double lon, double scale, double x, double y)
    {
        double newX, newY;
        double x0, y0, x1, y1, phi, m, m0, mu, e1;
@@ -321,7 +325,7 @@
                       / 72.0)) * RAD_DEG;
    }
    double mercator(double y, double a, double ecc)
    private static double mercator(double y, double a, double ecc)
    {
        if (y == 0.0)
        {