|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.proj.coords.VHTransform
public class VHTransform
The VH coordinate system is used by ATT to compute distance used in determining phone call costs.
VH coordinates can be used to compute distance simply, see distance().
This code is based on C code provided by the authors mentioned below, as well as Lisp code by Larry Denenberg of BBN.
I have ported this code to Java, unified the forward and inverse transformations and added some comments. I've left basic code and comments mostly intact.
The url's to the original emails are:
http://x11.dejanews.com/getdoc.xp?AN=177302113&CONTEXT=895858362.931528704&
hitnum=1
http://x11.dejanews.com/getdoc.xp?AN=223540739&CONTEXT=895858362.931528704&
hitnum=5
Field Summary | |
---|---|
static double |
EX
|
static double |
EY
|
static double |
EZ
|
static double |
K1
|
static double |
K10
|
static double |
K2
|
static double |
K3
|
static double |
K4
|
static double |
K5
|
static double |
K9
|
static double |
M_PI_2
|
static double |
PX
|
static double |
PY
|
static double |
PZ
|
static double |
RADIUS
radius of earth in sqrt(0.1)-mile units, minus 0.3 percent |
static double |
rot
|
static double |
ROTC
|
static double |
ROTS
|
static double |
TRANSH
|
static double |
TRANSV
|
static double |
WX
|
static double |
WY
|
static double |
WZ
|
Constructor Summary | |
---|---|
VHTransform()
|
Method Summary | |
---|---|
static double |
distance(double v1,
double h1,
double v2,
double h2)
Return the distance in miles between 2 VH pairs. |
java.awt.geom.Point2D |
forward(double lat,
double lon)
|
java.awt.geom.Point2D |
forward(double lat,
double lon,
java.awt.geom.Point2D ret)
|
double |
getH()
Return the H corresponding to the most recent toVH(). |
double |
getLat()
Return the latitude corresponding to the most recent toLatLon(). |
double |
getLon()
Return the longitude corresponding to the most recent toLatLon(). |
double |
getV()
Return the V corresponding to the most recent toVH(). |
LatLonPoint |
inverse(double v,
double h)
|
LatLonPoint |
inverse(double v,
double h,
LatLonPoint ret)
|
static void |
main(java.lang.String[] args)
|
void |
toLatLon(double v0,
double h0)
V&H is a system of coordinates (V and H) for describing locations of rate centers in the United States. |
void |
toLatLon(int v0,
int h0)
|
void |
toVH(double lat,
double lon)
lat and lon are in degrees, positive north and east. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double K1
public static final double K2
public static final double K3
public static final double K4
public static final double K5
public static final double M_PI_2
public static final double EX
public static final double EY
public static final double EZ
public static final double WX
public static final double WY
public static final double WZ
public static final double PX
public static final double PY
public static final double PZ
public static final double rot
public static final double ROTC
public static final double ROTS
public static final double TRANSV
public static final double TRANSH
public static final double RADIUS
public static final double K9
public static final double K10
Constructor Detail |
---|
public VHTransform()
Method Detail |
---|
public double getV()
public double getH()
public double getLat()
public double getLon()
public static double distance(double v1, double h1, double v2, double h2)
public void toVH(double lat, double lon)
public void toLatLon(double v0, double h0)
The foci of the projection, from which distances are measured accurately (except for the scale correction), are at 37d 42m 14.69s N, 82d 39m 15.27s W (in Floyd Co., Ky.) and 41d 02m 55.53s N, 112d 03m 39.35 W (in Webster Co., Utah). They are just 0.4 radians apart.
Here is the transformation from latitude and longitude to V&H: First project the earth from its ellipsoidal surface to a sphere. This alters the latitude; the coefficients bi in the program are the coefficients of the polynomial approximation for the inverse transformation. (The function is odd, so the coefficients are for the linear term, the cubic term, and so on.) Also subtract 52 degrees from the longitude.
For the rest, compute the arc distances of the given point to the reference points, and transform them to the coordinate system in which the line through the reference points is the X-axis and the origin is the eastern reference point. The solution is
h = (square of distance to E - square of distance to W + square of
distance between E and W) / twice distance between E and W;
v = square root of absolute value of (square of distance to E - square of
h).
Reduce by three-tenths of a percent, rotate by 76.597497 degrees, and add 6363.235 to V and 2250.7 to H.
To go the other way, as this program does, undo the final translation, rotation, and scaling. The z-value Pz of the point on the x-y-z sphere satisfies the quadratic Azz+Bz+c=0, where
A = (ExWz-EzWx)^2 + (EyWzx-EzWy)^2 + (ExWy-EyWx)^2;
B = -2[(Ex cos(arc to W) - Wx cos(arc to E))(ExWz-EzWx) - (Ey cos(arc to
W) -Wy cos(arc to E))(EyWz-EzWy)];
C = (Ex cos(arc to W) - Wx cos(arc to E))^2 + (Ey cos(arc to W) - Wy
cos(arc to E))^2 - (ExWy - EyWx)^2.
Solve with the quadratic formula. The latitude is simply the arc sine of Pz. Px and Py satisfy
ExPx + EyPy + EzPz = cos(arc to E);
WxPx + WyPy + WzPz = cos(arc to W).
Substitute Pz's value, and solve linearly to get Px and Py. The longitude is the arc tangent of Px/Py. Finally, this latitude and longitude are spherical; use the inverse polynomial approximation on the latitude to get the ellipsoidal earth latitude, and add 52 degrees to the longitude.
public void toLatLon(int v0, int h0)
public java.awt.geom.Point2D forward(double lat, double lon)
forward
in interface GeoCoordTransformation
public java.awt.geom.Point2D forward(double lat, double lon, java.awt.geom.Point2D ret)
forward
in interface GeoCoordTransformation
public LatLonPoint inverse(double v, double h)
inverse
in interface GeoCoordTransformation
public LatLonPoint inverse(double v, double h, LatLonPoint ret)
inverse
in interface GeoCoordTransformation
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |