com.bbn.openmap.proj.coords
Class VHTransform

java.lang.Object
  extended by com.bbn.openmap.proj.coords.VHTransform
All Implemented Interfaces:
GeoCoordTransformation

public class VHTransform
extends java.lang.Object
implements GeoCoordTransformation

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

K1

public static final double K1
See Also:
Constant Field Values

K2

public static final double K2
See Also:
Constant Field Values

K3

public static final double K3
See Also:
Constant Field Values

K4

public static final double K4
See Also:
Constant Field Values

K5

public static final double K5
See Also:
Constant Field Values

M_PI_2

public static final double M_PI_2
See Also:
Constant Field Values

EX

public static final double EX
See Also:
Constant Field Values

EY

public static final double EY
See Also:
Constant Field Values

EZ

public static final double EZ
See Also:
Constant Field Values

WX

public static final double WX
See Also:
Constant Field Values

WY

public static final double WY
See Also:
Constant Field Values

WZ

public static final double WZ
See Also:
Constant Field Values

PX

public static final double PX
See Also:
Constant Field Values

PY

public static final double PY
See Also:
Constant Field Values

PZ

public static final double PZ
See Also:
Constant Field Values

rot

public static final double rot

ROTC

public static final double ROTC

ROTS

public static final double ROTS

TRANSV

public static final double TRANSV
See Also:
Constant Field Values

TRANSH

public static final double TRANSH
See Also:
Constant Field Values

RADIUS

public static final double RADIUS
radius of earth in sqrt(0.1)-mile units, minus 0.3 percent

See Also:
Constant Field Values

K9

public static final double K9

K10

public static final double K10
Constructor Detail

VHTransform

public VHTransform()
Method Detail

getV

public double getV()
Return the V corresponding to the most recent toVH(). *


getH

public double getH()
Return the H corresponding to the most recent toVH(). *


getLat

public double getLat()
Return the latitude corresponding to the most recent toLatLon(). *


getLon

public double getLon()
Return the longitude corresponding to the most recent toLatLon(). *


distance

public static double distance(double v1,
                              double h1,
                              double v2,
                              double h2)
Return the distance in miles between 2 VH pairs. *


toVH

public void toVH(double lat,
                 double lon)
lat and lon are in degrees, positive north and east.


toLatLon

public 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. The projection, devised by J. K. Donald, is an "elliptical," or "doubly equidistant" projection, scaled down by a factor of 0.003 to balance errors.

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.


toLatLon

public void toLatLon(int v0,
                     int h0)

forward

public java.awt.geom.Point2D forward(double lat,
                                     double lon)
Specified by:
forward in interface GeoCoordTransformation

forward

public java.awt.geom.Point2D forward(double lat,
                                     double lon,
                                     java.awt.geom.Point2D ret)
Specified by:
forward in interface GeoCoordTransformation

inverse

public LatLonPoint inverse(double v,
                           double h)
Specified by:
inverse in interface GeoCoordTransformation

inverse

public LatLonPoint inverse(double v,
                           double h,
                           LatLonPoint ret)
Specified by:
inverse in interface GeoCoordTransformation

main

public static void main(java.lang.String[] args)


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details