| | |
| | | package com.ximple.eofms.util; |
| | | |
| | | import com.vividsolutions.jts.geom.Coordinate; |
| | | |
| | | /** |
| | | * TWDDatumConverter |
| | | * User: Ulysses |
| | |
| | | /* |
| | | * 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; |
| | |
| | | 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)) |
| | | { |
| | |
| | | lat = HALF_PI; |
| | | } else if ((lat < -HALF_PI) || (lat > HALF_PI)) |
| | | { |
| | | return; |
| | | return null; |
| | | } |
| | | |
| | | if (lon > PI) |
| | |
| | | newY = lat * RAD_DEG; |
| | | newZ = -TWD97_B; |
| | | |
| | | return; |
| | | return new Coordinate(newX, newY, newZ); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | 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)) |
| | | { |
| | |
| | | lat = HALF_PI; |
| | | } else if ((lat < -HALF_PI) || (lat > HALF_PI)) |
| | | { |
| | | return; |
| | | return null; |
| | | } |
| | | |
| | | if (lon > PI) |
| | |
| | | newY = lat * RAD_DEG; |
| | | newZ = -TWD67_B; |
| | | |
| | | return; |
| | | return new Coordinate(newX, newY, newZ); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | + (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; |
| | |
| | | / 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) |
| | | { |