3dmap-master/js/utm-converter/src/converter.js
/*
  * MapLatLonToXY
  *
  * Converts a latitude/longitude pair to x and y coordinates in the
  * Transverse Mercator projection.  Note that Transverse Mercator is not
  * the same as UTM; a scale factor is required to convert between them.
  *
  * Reference: Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J.,
  * GPS: Theory and Practice, 3rd ed.  New York: Springer-Verlag Wien, 1994.
  *
  * Inputs:
  *    phi - Latitude of the point, in radians.
  *    lambda - Longitude of the point, in radians.
  *    lambda0 - Longitude of the central meridian to be used, in radians.
  *
  * Outputs:
  *    xy - A 2-element array containing the x and y coordinates
  *         of the computed point.
  *
  * Returns:
  *    The function does not return a value.
  *
  */
MapLatLonToXY
Converts a latitude/longitude pair to x and y coordinates in the
Transverse Mercator projection.  Note that Transverse Mercator is not
the same as UTM; a scale factor is required to convert between them.

Hoffmann-Wellenhof, B., Lichtenegger, H., and Collins, J.,
GPS: Theory and Practice, 3rd ed.  New York: Springer-Verlag Wien, 1994.

Latitude of the point, in radians.
lambda - Longitude of the point, in radians.
lambda0 - Longitude of the central meridian to be used, in radians.

A 2-element array containing the x and y coordinates
of the computed point.

The function does not return a value.
MapLatLonToXY Converts a latitude / longitude pair to x and y coordinates in the Transverse Mercator projection . Note that Transverse Mercator is not the same as UTM ; a scale factor is required to convert between them . Hoffmann - Wellenhof B . Lichtenegger H . and Collins J . GPS : Theory and Practice 3rd ed . New York : Springer - Verlag Wien 1994 . Latitude of the point in radians . lambda - Longitude of the point in radians . lambda0 - Longitude of the central meridian to be used in radians . A 2 - element array containing the x and y coordinates of the computed point . The function does not return a value .
function MapLatLonToXY (phi, lambda, lambda0, xy)
  {
      var N, nu2, ep2, t, t2, l;
      var l3coef, l4coef, l5coef, l6coef, l7coef, l8coef;
      var tmp;
      ep2 = (Math.pow (sm_a, 2.0) - Math.pow (sm_b, 2.0)) / Math.pow (sm_b, 2.0);
      nu2 = ep2 * Math.pow (Math.cos (phi), 2.0);
      N = Math.pow (sm_a, 2.0) / (sm_b * Math.sqrt (1 + nu2));
      t = Math.tan (phi);
      t2 = t * t;
      tmp = (t2 * t2 * t2) - Math.pow (t, 6.0);
      l = lambda - lambda0;
      l3coef = 1.0 - t2 + nu2;
      l4coef = 5.0 - t2 + 9 * nu2 + 4.0 * (nu2 * nu2);
      l5coef = 5.0 - 18.0 * t2 + (t2 * t2) + 14.0 * nu2
          - 58.0 * t2 * nu2;
      l6coef = 61.0 - 58.0 * t2 + (t2 * t2) + 270.0 * nu2
          - 330.0 * t2 * nu2;
      l7coef = 61.0 - 479.0 * t2 + 179.0 * (t2 * t2) - (t2 * t2 * t2);
      l8coef = 1385.0 - 3111.0 * t2 + 543.0 * (t2 * t2) - (t2 * t2 * t2);
      xy[0] = N * Math.cos (phi) * l
          + (N / 6.0 * Math.pow (Math.cos (phi), 3.0) * l3coef * Math.pow (l, 3.0))
          + (N / 120.0 * Math.pow (Math.cos (phi), 5.0) * l5coef * Math.pow (l, 5.0))
          + (N / 5040.0 * Math.pow (Math.cos (phi), 7.0) * l7coef * Math.pow (l, 7.0));
      xy[1] = ArcLengthOfMeridian (phi)
          + (t / 2.0 * N * Math.pow (Math.cos (phi), 2.0) * Math.pow (l, 2.0))
          + (t / 24.0 * N * Math.pow (Math.cos (phi), 4.0) * l4coef * Math.pow (l, 4.0))
          + (t / 720.0 * N * Math.pow (Math.cos (phi), 6.0) * l6coef * Math.pow (l, 6.0))
          + (t / 40320.0 * N * Math.pow (Math.cos (phi), 8.0) * l8coef * Math.pow (l, 8.0));
      return;
  }
function MapLatLonToXY ( phi , lambda , lambda0 , xy ) { var N , nu2 , ep2 , t , t2 , l ; var l3coef , l4coef , l5coef , l6coef , l7coef , l8coef ; var tmp ; ep2 = ( Math . pow ( sm_a , 2.0 ) - Math . pow ( sm_b , 2.0 ) ) / Math . pow ( sm_b , 2.0 ) ; nu2 = ep2 * Math . pow ( Math . cos ( phi ) , 2.0 ) ; N = Math . pow ( sm_a , 2.0 ) / ( sm_b * Math . sqrt ( 1 + nu2 ) ) ; t = Math . tan ( phi ) ; t2 = t * t ; tmp = ( t2 * t2 * t2 ) - Math . pow ( t , 6.0 ) ; l = lambda - lambda0 ; l3coef = 1.0 - t2 + nu2 ; l4coef = 5.0 - t2 + 9 * nu2 + 4.0 * ( nu2 * nu2 ) ; l5coef = 5.0 - 18.0 * t2 + ( t2 * t2 ) + 14.0 * nu2 - 58.0 * t2 * nu2 ; l6coef = 61.0 - 58.0 * t2 + ( t2 * t2 ) + 270.0 * nu2 - 330.0 * t2 * nu2 ; l7coef = 61.0 - 479.0 * t2 + 179.0 * ( t2 * t2 ) - ( t2 * t2 * t2 ) ; l8coef = 1385.0 - 3111.0 * t2 + 543.0 * ( t2 * t2 ) - ( t2 * t2 * t2 ) ; xy [ 0 ] = N * Math . cos ( phi ) * l + ( N / 6.0 * Math . pow ( Math . cos ( phi ) , 3.0 ) * l3coef * Math . pow ( l , 3.0 ) ) + ( N / 120.0 * Math . pow ( Math . cos ( phi ) , 5.0 ) * l5coef * Math . pow ( l , 5.0 ) ) + ( N / 5040.0 * Math . pow ( Math . cos ( phi ) , 7.0 ) * l7coef * Math . pow ( l , 7.0 ) ) ; xy [ 1 ] = ArcLengthOfMeridian ( phi ) + ( t / 2.0 * N * Math . pow ( Math . cos ( phi ) , 2.0 ) * Math . pow ( l , 2.0 ) ) + ( t / 24.0 * N * Math . pow ( Math . cos ( phi ) , 4.0 ) * l4coef * Math . pow ( l , 4.0 ) ) + ( t / 720.0 * N * Math . pow ( Math . cos ( phi ) , 6.0 ) * l6coef * Math . pow ( l , 6.0 ) ) + ( t / 40320.0 * N * Math . pow ( Math . cos ( phi ) , 8.0 ) * l8coef * Math . pow ( l , 8.0 ) ) ; return ; }
MapLatLonToXY
 Converts a latitude/longitude pair to x and y coordinates in the
 Transverse Mercator projection.
MapLatLonToXY Converts a latitude / longitude pair to x and y coordinates in the Transverse Mercator projection .
/* Precalculate ep2 */ /* Precalculate nu2 */ /* Precalculate N */ /* Precalculate t */ /* Precalculate l */ /* Precalculate coefficients for l**n in the equations below
         so a normal human being can read the expressions for easting
         and northing
         -- l**1 and l**2 have coefficients of 1.0 */ /* Calculate easting (x) */ /* Calculate northing (y) */