www/lib/NDSFutility_max.js
/*----------------------------------------------------------
#   translate_coordinates
#   routine to translate between geographic and cartesian coordinates
#   user must supply following data on the cartesian coordinate system:
#   location of the origin in lat/lon degrees;
#   rotational skew from true north in degrees;
#   N.B. sense of rotation i/p here is exactly as o/p by ORIGIN
#   x/y offset in meters - only if an offset was used during the
#   running of prog ORIGIN;
*/
translate_coordinates
routine to translate between geographic and cartesian coordinates
user must supply following data on the cartesian coordinate system:
location of the origin in lat/lon degrees;
rotational skew from true north in degrees;
N.B. sense of rotation i/p here is exactly as o/p by ORIGIN
x/y offset in meters - only if an offset was used during the
running of prog ORIGIN.
translate_coordinates routine to translate between geographic and cartesian coordinates user must supply following data on the cartesian coordinate system : location of the origin in lat / lon degrees ; rotational skew from true north in degrees ; N . B . sense of rotation i / p here is exactly as o / p by ORIGIN x / y offset in meters - only if an offset was used during the running of prog ORIGIN .
function translate_coordinates(trans_option,porg)
{
   with(Math)
   {   
      var xx,yy,r,ct,st,angle;
      angle = DEG_TO_RADIANS(porg.rotation_angle_degs);
      if( trans_option == XY_TO_LL)
      {
         pxpos_mtrs = porg.x;  
         pypos_mtrs = porg.y;
	 xx = pxpos_mtrs - porg.xoffset_mtrs;
	 yy = pypos_mtrs - porg.yoffset_mtrs;
	 r = sqrt(xx*xx + yy*yy);
	 if(r)
	 {
            ct = xx/r;
	    st = yy/r;
	    xx = r * ( (ct * cos(angle))+ (st * sin(angle)) );
	    yy = r * ( (st * cos(angle))- (ct * sin(angle)) );
	 }
	 var plon = porg.olon + xx/METERS_DEGLON(olat);
	 var plat = porg.olat + yy/METERS_DEGLAT(olat);
         var sll={};
         sll={slat:plat, slon:plon};
         return(sll);
      }
      else if(trans_option == LL_TO_XY)
      {
         xx = (porg.slon - porg.olon)*METERS_DEGLON(porg.olat);
	 yy = (porg.slat - porg.olat)*METERS_DEGLAT(porg.olat);
	r = sqrt(xx*xx + yy*yy);
	if(r)
	{
	    ct = xx/r;
            st = yy/r;
	    xx = r * ( (ct * cos(angle)) + (st * sin(angle)) );
	    yy = r * ( (st * cos(angle)) - (ct * sin(angle)) );
	}
	pxpos_mtrs = xx + porg.xoffset_mtrs;
	pypos_mtrs = yy + porg.yoffset_mtrs;
        var sxy={};
        sxy={x:pxpos_mtrs, y:pypos_mtrs};
        return(sxy);
     }
  }
}
function translate_coordinates ( trans_option , porg ) { with ( Math ) { var xx , yy , r , ct , st , angle ; angle = DEG_TO_RADIANS ( porg . rotation_angle_degs ) ; if ( trans_option == XY_TO_LL ) { pxpos_mtrs = porg . x ; pypos_mtrs = porg . y ; xx = pxpos_mtrs - porg . xoffset_mtrs ; yy = pypos_mtrs - porg . yoffset_mtrs ; r = sqrt ( xx * xx + yy * yy ) ; if ( r ) { ct = xx / r ; st = yy / r ; xx = r * ( ( ct * cos ( angle ) ) + ( st * sin ( angle ) ) ) ; yy = r * ( ( st * cos ( angle ) ) - ( ct * sin ( angle ) ) ) ; } var plon = porg . olon + xx / METERS_DEGLON ( olat ) ; var plat = porg . olat + yy / METERS_DEGLAT ( olat ) ; var sll = { } ; sll = { slat : plat , slon : plon } ; return ( sll ) ; } else if ( trans_option == LL_TO_XY ) { xx = ( porg . slon - porg . olon ) * METERS_DEGLON ( porg . olat ) ; yy = ( porg . slat - porg . olat ) * METERS_DEGLAT ( porg . olat ) ; r = sqrt ( xx * xx + yy * yy ) ; if ( r ) { ct = xx / r ; st = yy / r ; xx = r * ( ( ct * cos ( angle ) ) + ( st * sin ( angle ) ) ) ; yy = r * ( ( st * cos ( angle ) ) - ( ct * sin ( angle ) ) ) ; } pxpos_mtrs = xx + porg . xoffset_mtrs ; pypos_mtrs = yy + porg . yoffset_mtrs ; var sxy = { } ; sxy = { x : pxpos_mtrs , y : pypos_mtrs } ; return ( sxy ) ; } } }
translate_coordinates
routine to translate between geographic and cartesian coordinates
user must supply following data on the cartesian coordinate system:
location of the origin in lat/lon degrees;
rotational skew from true north in degrees;
N.B.
translate_coordinates routine to translate between geographic and cartesian coordinates user must supply following data on the cartesian coordinate system : location of the origin in lat / lon degrees ; rotational skew from true north in degrees ; N . B .
/* X,Y to Lat/Lon Coordinate Translation  */ /* alert('LL_TO_XY: xx=' + xx + ' yy=' + yy + ' r=' + r);
        return false;*/