www/lib/NDSFutility_max.js
/*-----------------------------------------------------------
  xy2utm (call xy2ll then geo_utm for ll2utm)  
-------------------------------------------------------------*/
xy2utm (call xy2ll then geo_utm for ll2utm)
xy2utm ( call xy2ll then geo_utm for ll2utm )
function xy2utm(Form)
{
   with(Math)
   {
      var oll=getoll(Form);
      olat=oll.olat;
      olon=oll.olon;
      if( Form.Xcord.value == "" | Form.Ycord.value == "")
      {
          alert('Enter X/Y values');
          return false;
      }
      else
      {
         sx=1*Form.Xcord.value; 
         sy=1*Form.Ycord.value;
      }
      var   origin={};
      origin={x:sx,y:sy,coord_system:1,
              olat:olat,
olon:olon,xoffset_mtrs:0,
              yoffset_mtrs:0,rotation_angle_degs:0,rms_error:0};
      var xy2ll = translate_coordinates(XY_TO_LL,
origin); 
      var slat=xy2ll.slat;  
      var slon=xy2ll.slon;
      var utmzone=utm_zone(slat,slon); 
      var slat_rad=DTOR*slat;  
      var slon_rad=DTOR*slon; 
      var utmxy = geo_utm(slat_rad,slon_rad,utmzone);
      if( slat >=84.0 | slat < -80.0)
      {
	  utmzone="outsideGrid";
      }
      Form.UTMX.value=(utmxy.x.toFixed(1));
      Form.UTMY.value=(utmxy.y.toFixed(1));
      Form.UTMZone.value=utmzone;
      return true;
   }
   return true;
}
function xy2utm ( Form ) { with ( Math ) { var oll = getoll ( Form ) ; olat = oll . olat ; olon = oll . olon ; if ( Form . Xcord . value == "" | Form . Ycord . value == "" ) { alert ( 'Enter X/Y values' ) ; return false ; } else { sx = 1 * Form . Xcord . value ; sy = 1 * Form . Ycord . value ; } var origin = { } ; origin = { x : sx , y : sy , coord_system : 1 , olat : olat , olon : olon , xoffset_mtrs : 0 , yoffset_mtrs : 0 , rotation_angle_degs : 0 , rms_error : 0 } ; var xy2ll = translate_coordinates ( XY_TO_LL , origin ) ; var slat = xy2ll . slat ; var slon = xy2ll . slon ; var utmzone = utm_zone ( slat , slon ) ; var slat_rad = DTOR * slat ; var slon_rad = DTOR * slon ; var utmxy = geo_utm ( slat_rad , slon_rad , utmzone ) ; if ( slat >= 84.0 | slat < - 80.0 ) { utmzone = "outsideGrid" ; } Form . UTMX . value = ( utmxy . x . toFixed ( 1 ) ) ; Form . UTMY . value = ( utmxy . y . toFixed ( 1 ) ) ; Form . UTMZone . value = utmzone ; return true ; } return true ; }
xy2utm (call xy2ll then geo_utm for ll2utm)
xy2utm ( call xy2ll then geo_utm for ll2utm )
/* get the origin lat and lon */ /* get the source x and y (to be converted) */ /* convert string to float */ /* return in degrees */ /* take slat and slon in degrees */ /* decimal degrees to radius */ /* get the results and fill in the form */ /* check for validity of parameters */ /* out side of grid */ /* get the results and fill in the form */