Article 41576 of comp.dcom.telecom:
Path: mri-gw!psinntp!psinntp!rutgers!sgigate.sgi.com!sgiblab!swrinde!howland.reston.ans.net!spool.mu.edu!uwm.edu!lll-winken.llnl.gov!telecom-request
Date: Mon, 19 Dec 1994 10:35:29 -0500
From: gordon@torrie.org (Gordon Torrie)
Newsgroups: comp.dcom.telecom
Subject: Re: Help Converting V&H Coordinates to Longitude and Latitude
Message-ID: <telecom14.456.1@eecs.nwu.edu>
Organization: Torrie Communication Services
Sender: telecom@eecs.nwu.edu
Approved: telecom@eecs.nwu.edu
X-Submissions-To: telecom@eecs.nwu.edu
X-Administrivia-To: telecom-request@eecs.nwu.edu
X-Telecom-Digest: Volume 14, Issue 456, Message 1 of 9
Lines: 243

C. Edward Chow <chow@quandary.harpo.uccs.edu> writes:

> I am working on a project that needs to convert switching 
> nodes' locations expressed in terms of V&H coordinates to those 
> in Longitude and Latitude coordinates.  I checked with 
> telecommunications references in the library but can not find 
> the definition of telephone network V&H coordinates.  Can 
> someone help pointing to the right references or explain it?  

Here are four messages which have appeared in comp.dcom.telecom in the
past and which describe how to perform the V&H <=> Lat./Long.
conversions including source code routines in C and Fortran.


  From: Thomas B. Libert <tom@comsol.com>
  Subject: Re: H & V Distance Computing Algorithm Wanted
  Date: Sun, 26 Sep 93 14:43:23 EDT
  Reply-To: tom@comsol.com
  Organization: Computing Solutions Inc., Ann Arbor, Michigan
  X-Telecom-Digest: Volume 13, Issue 666, Message 8 of 16

The H & V numbers are computed from the Donald Elliptical projection,
a two-point equidistant projection designed by Jay K. Donald of AT&T
around 1956.  The projection allows you to use the simple cartesian
distance formula to compute a reasonably good approximation for the
true distance.  Just compute sqrt((h2 - h1)^2 + (v2 - v1)^2), and
multiply by a scale factor (ten miles?  something like that.)


  From: StuJeffery@cup.portal.com
  Subject: Re: H & V Distance Computing Algorithm Wanted
  Date: Sun, 26 Sep 93 22:33:32 PDT
  X-Telecom-Digest: Volume 13, Issue 666, Message 9 of 16

Jimmy Gauvin (jimmy@cerberus.ulaval.ca) writes:
 
> Can somebody please tell me how to calculate the distance between two
> NPA-NXXs given their H & V coordinates?
 
The following is the answer in two forms:
 
1. as a text statement:
 
D = Square Root of (((V1 - V2)squared + (H1 - H2)squared)/10) where D
is in miles and V and H are values in the V and H Coordinate System.
 
For example the distance from San Diego ( 9462 7632) 
   to San Franciso (8493 8717) is: 460.02,
   to Sacramento (8303 8581) is: 473.70,
   to Los Angles (9213 7878) is: 110.69.
 
2. as a C program:
/* 
 * This program computes distance in miles between 
 * two points given their V and H coordinates.
 * 
 */
   
#include <stdio.h>
#include <math.h>
 
main()
{
	float D;
	int V1, V2, H1, H2;

while ( 1 == 1)
	{
	
	printf( "enter V and H for first point:\n" );
	scanf( "%i%i", &V1, &H1 );
	printf( "enter V and H for second point:\n" );
	scanf( "%i%i", &V2, &H2 );
	
	D = sqrt((pow ((V1-V2), 2) + pow ((H1-H2), 2) ) / 10 );
 
	printf( "Distance in miles =  %7.2f \n", D);
	printf (" \n");
	
	}
}

         ------------- tear here ----------------

Good luck,
Stuart Jeffery    415-966-8199


  Subject: V & H FORTRAN Routines
  Date: Jul 01 1990
  From: Mike.Riddle@f27.n285.z1.fidonet.org

The following routines were mentioned by Jim Riddle in a recent Digest
article.  The response has already been substantial; however, Jim has
no easy way of sending files through the Internet.

Since several people have already responded, perhaps you couuld run
them in the Digest or mention they are available wherever you put them
in the archives?

C     TO CONVERT EITHER EARTH-CENTERED TO LAT/LON OR VICE VERSA
      SUBROUTINE M2CONV (OPT,NUMPTS,LATS,LONS,XLAIST,YLIST,ZLIST)
      INTEGER*4 OPT,NUMPTS,I
      REAL*8    LATS(NUMPTS),LONS(NUMPTS),THETA,PHI,DTR
      REAL*8    XLIST(NUMPTS),YLIST(NUMPTS),ZLIST(NUMPTS)
      PI=3.141592653589793238462643
      DTR=PI/180.
      IF (OPT .EQ. 1) THEN
         DO FOR I = 1,NUMPTS
            THETA = LONS(I) * DTR
            PHI = (90.0D+0 - LATS(I)) * DTR
            XLIST(I) = DCOS(THETA) * DSIN(PHI)
            YLIST(I) = DSIN(THETA) * DSIN(PHI)
            ZLIST(I) = DCOS(PHI)
         ENDDO
      ELSEIF (OPT .EQ. 2) THEN
         DO FOR I = 1,NUMPTS
            LATS(I) = 90.0D+0 - DACOS(ZLIST(I)) / DTR
            IF (XLIST(I) .EQ. 0.0D+0) THEN
               IF (YLIST(I) .LT. 0.0D0+0) THEN
                  LONS(I) = -90.0D+0
               ELSE
                  LONS(I) = 90.0D0+0
               ENDIF
            ELSE
               LONS(I) = DATAN(YLIST(I)/XLIST(I)) / DTR
               IF (XLIST(I) .LT. 0.0D0+0) THEN
                  IF (YLIST(I) .LT. 0.0D0+0) THEN
                     LONS(I) = LONS(I) - 180.0D0+0
                  ELSE
                     LONS(I) = LONS(I) + 180.0D0+0
                  ENDIF
               ENDIF
            ENDIF
         ENDDO
      ENDIF
      END

      SUBROUTINE LLAXYZ(LAT,LON,ALT,Y,Y,Z)
C  SUBROUTINE TO CALCULATE ECI FROM LAT/LON/ALT
C
C  RE IS RADIUS OF THE EARTH
C  RE = 3437.5 NAUTICAL MILES MORE OR LESS
C  1 NAUTICAL MILE = 1852 METERS (EXACT)
C  1 STATUTE MILE = 1609.344 METERS (EXACT)
C  SUBROUTINE _DOES_ REQUIRE ALTITUDE -- CHECK THE LOCAL AIRPORT (!)
C INPUT REQUIRED IS LAT, LON, ALT OF POINT AND RETURNS X, Y, Z
C
      REAL LAT,LON,ALT
      RE = 3437.75
C     RE = 3437.75 * 1.852 FOR KILOMETERS
C     RE = 3437.75 * 1.852/1609.344 FOR STATUTE MILES
C     ON MOST MACHINES YOU MAY WANT TO GO DOUBLE PRECISION, BY THE WAY
      RANGE = RE + ALT
      CLAT = COS(LAT)
      SLAT = SIN(LAT)
      CLON = COS(LON)
      SLON = SIN(LON)
      Z = RANGE * SLAT
      X = RANGE * CLAT * CLON
      Y = RANGE * CLAT * SLON
      RETURN
      END

C     CONVERTS LAT AND LONG TO EUCLIDEAN COORDINATES
      SUBROUTINE M2EUCL
      REAL*4 DEGRAD, PI, ECLX(N), ECLY(N), ECLZ(N)
      REAL*4 LOND(N), LATD(N)
      INTEGER*4 NUMPTS,I
      PI=3.141592653589793238462643
      DEGRAD = PI/180.
      DO FOR I = 1,NUMPTS
         ECLX(I) = COS(LOND(I)*DEGRAD)*COS(LATD(I)*DEGRAD)
         ECLY(I) = SIN(LOND(I)*DEGRAD)*COS(LATD(I)*DEGRAD)
         ECLZ(I) = SIN(LATD(I)*DEGRAD)
      ENDDO
      RETURN
      END

      SUBROUTINE M2DIST(XPT,YPT,ZPT,NUMLST)
      INTEGER*4 NUMLST,N,INDEX
C     CALCULATE DISTANCES (GREAT CIRCLE) FROM A LIST OF POINTS TO 
C     A FOCAL POINT
C     XPT, YPT, ZPT ARE X, Y, Z COORDINATES OF THE FOCAL POINT
C     XLST, YLST, ZLST ARE LISTS OF X, Y AND Z COORDINATES
C     RADIUS IS RADIUS OF THE EARTH
      REAL*4 
      XPT,YPT,ZPT,CSQRED,CTHETA,XLST(N),YLST(N),ZLST(N),DLST(N)
      DO FOR INDEX = 1, NUMLST
         CSQRED = (XLST(INDEX) - XPT)**2 + (YLST(INDEX) - YPT)**2 +
     1   (ZLST(INDEX) - ZPT)**2
         CTHETA = 1.0 - CSQRED/2.0
         DLST(INDEX) = ACOS(CTHETA) * RADIUS
      ENDDO
      RETURN
      END

 --- Ybbat (DRBBS) 8.9 v. 3.11 r.3
[1:285/27@fidonet] The Inns of Court 402/593-1192 (1:285/27.0)


  Subject: Comments For V & H FORTRAN Routines
  Date: Jul 01 1990
  From: Mike.Riddle@f27.n285.z1.fidonet.org

[Moderator's Note: This message was intended to accompany the V&H 
Fortran routines which appeared in Digest # 458 early Wedensday.
Unfortunately it was delayed in transmission and arrived here 
later. PT]

The file in the accompanying message contains the routines I
mentioned.  It contains several Fortran subroutines which should be
quasi-obvious to implment.  If you don't code Fortran, you can
probably understand then from either BASIC or Pascal; if you can't
comprehend the math involved, then you may be in over your head
already.

When using the coordinate system, it is NOT necessary that you have
the same X-Y grid as the phone company so long as you are using
statute miles, nautical miles, furlongs, picometers or whatever
consistent with their distancing measurement.  The most convienent way
to do it is probably to use real-Earth latitudes and longtitudes and
PAY ATTENTION TO WHICH ROUTINES USE DEGREES AND WHICH ARE IN RADIANS.

If you really want a polished, finished product, I really can't comply
as I am under some conflict of interest restrictions (sounds nebulous
because it is).

Thanks for the bevy of responses I received.

Jim R.

 --- Ybbat (DRBBS) 8.9 v. 3.11 r.3
[1:285/27@fidonet] The Inns of Court 402/593-1192 (1:285/27.0)

 --- Through FidoNet gateway node 1:16/390
Mike.Riddle@f27.n285.z1.fidonet.org

                      ----------------

gordon@torrie.org   Gord Torrie



