Jump to content

Converter latitude and longitude to UTM and vice versa


Patxi
 Share

Recommended Posts

Hello

I have two function to convert  Latitude and longitude to UTM and vice versa 

Examples of use:

$utm_X= 607187.665391066
$utm_y= 4740057.65037195
$long=0
$lat=0
$x=0
$y=0
$utmz=30; UTM zone
$SUR=False
$DATUM=0
UTMtoGeog($utm_X,$utm_y, $long, $lat, $utmz, $SUR, $DATUM )
ConsoleWrite(" Lat: 42.805572 " & $lat & @CRLF)
ConsoleWrite(" Long: -1.689084 " & $long & @CRLF)

$lat = 42.805572
$long= -1.689084
GeogToUTM($lat, $long, $x,  $y , $utmz, $SUR, $DATUM)
ConsoleWrite(" X: 607187.665391066 607187.6 " & $x & @CRLF)
ConsoleWrite(" Y: 4740057.65037195 4740057.6 " & $y & @CRLF)
ConsoleWrite(" Zone: 30 " & $utmz & @CRLF)
ConsoleWrite(" SUR: False " & $SUR & @CRLF)

The DATUM could be:

     //Datum Info here: 
    ;~  0     //WGS 84    
    ;~     1    //NAD 83    
    ;~     2    //GRS 80    
    ;~     3    //WGS 72    
    ;~     4    //Australian 1965    
    ;~     5    //Krasovsky 1940    
    ;~     6    //North American 1927    
    ;~     7    //International 1924    
    ;~     8    //Hayford 1909    
    ;~     9    //Clarke 1880    
    ;~     10    //Clarke 1866    
    ;~     11    //Airy 1830    
    ;~     12    //Bessel 1841    
    ;~     13    //Everest 1830    

 

I hope they'll be useful

Func GeogToUTM($lat, $long, Byref $x, Byref $y , Byref $utmz, Byref $SUR, $DATUM=0)
    ;//Convert Latitude and Longitude to UTM
    ; With Latitud ($lat) and Longitud ($long) get UTM X ($x), UTM y ($y), UTM Zone ($utmz) and hemisphere ($SUR=False is North, $SUR=true is South)
    ; $DATUM by default is WGS 84 (0)
    ; Example of use:
    ;   Local $lat, $long, $x,  $y , $utmz, $SUR
    ;   $lat = 42.805572
    ;   $long= -1.689084
    ;   GeogToUTM($lat, $long, $x,  $y , $utmz, $SUR)
    ;   ConsoleWrite("UTM X: " & $x & @CRLF)
    ;   ConsoleWrite("UTM Y: " & $y & @CRLF)
    ;   ConsoleWrite("UTM Zone: " & $utmz & @CRLF)
    ;   ConsoleWrite("UTM hemisphere SUR: " & $SUR & @CRLF)

    ;~      //Datum Info here: Name, a, b, f, 1/f
    ;~  0   //WGS 84    6,378,137.0 6356752.314 0.003352811 298.2572236
    ;~  1   //NAD 83    6,378,137.0 6356752.314 0.003352811 298.2572236
    ;~  2   //GRS 80    6,378,137.0 6,356,752.3 0.003352811 298.2572215
    ;~  3   //WGS 72    6,378,135.0 6,356,750.5 0.003352783 298.2597208
    ;~  4   //Australian 1965   6,378,160.0 6,356,774.7 0.003352895 298.2497323
    ;~  5   //Krasovsky 1940    6,378,245.0 6,356,863.0 0.003352333 298.2997381
    ;~  6   //North American 1927   6,378,206.4 6,356,583.8 0.003390075 294.9786982
    ;~  7   //International 1924    6,378,388.0 6,356,911.9 0.003367011 296.9993621
    ;~  8   //Hayford 1909  6,378,388.0 6,356,911.9 0.003367011 296.9993621
    ;~  9   //Clarke 1880   6,378,249.1 6,356,514.9 0.00340755  293.4660167
    ;~  10  //Clarke 1866   6,378,206.4 6,356,583.8 0.003390075 294.9786982
    ;~  11  //Airy 1830 6,377,563.4 6,356,256.9 0.003340853 299.3247788
    ;~  12  //Bessel 1841   6,377,397.2 6,356,079.0 0.003342774 299.1527052
    ;~  13  //Everest 1830  6,377,276.3 6,356,075.4 0.003324444 300.8021499
    ; More information in:
    ; https://www.uwgb.edu/dutchs/UsefulData/UTMFormulas.HTM
    ; IMPORT from javascript version of: https://www.uwgb.edu/dutchs/UsefulData/ConvertUTMNoOZ.HTM

    ;Declarations();
    Local $M_PI= 3.14159265358979323846
    Local $DatumEqRad [14] = [6378137.0,6378137.0,6378137.0,6378135.0,6378160.0,6378245.0,6378206.4, 6378388.0,6378388.0,6378249.1,6378206.4,6377563.4,6377397.2,6377276.3];
    Local $DatumFlat[14] = [298.2572236, 298.2572236, 298.2572215,  298.2597208, 298.2497323, 298.2997381, 294.9786982, 296.9993621, 296.9993621, 293.4660167, 294.9786982, 299.3247788, 299.1527052, 300.8021499];
    Local $Item = $DATUM
    Local $k0 = 0.9996;//scale on central meridian
    Local $a = $DatumEqRad[$Item];//equatorial radius, meters.
    Local $f = 1/$DatumFlat[$Item];//polar flattening.
    Local $b = $a*(1-$f);//polar axis.
    Local $e = Sqrt (1 - ($b*$b)/($a*$a));//eccentricity
    Local $drad = $M_PI/180;//Convert degrees to radians)
    Local $latd = 0;//latitude in degrees
    Local $phi = 0;//latitude (north +, south -), but uses phi in reference
    Local $e0 = $e/Sqrt(1 - $e*$e);//e prime in reference
    ;; Creo que no hace falta y da error $N = $a/Sqrt(1-Math.pow($e*sin($phi)),2);
    Local $T = (Tan($phi)^2);
    Local $C = ($e*(cos($phi)^2));
    Local $lng = 0;//Longitude (e = +, w = -) - can't use long - reserved word
    Local $lng0 = 0;//longitude of central meridian
    Local $lngd = 0;//longitude in degrees
    Local $M = 0;//M requires calculation
    ;$x = 0;//x coordinate
    ;$y = 0;//y coordinate
    Local $k = 1;//local scale
    ;$utmz = 30;//utm zone
    Local $zcm = 0;//zone central meridian
    Local $DigraphLetrsE = "ABCDEFGHJKLMNPQRSTUVWXYZ";
    Local $DigraphLetrsN = "ABCDEFGHJKLMNPQRSTUV";
    ;document.getElementById("EqRadBox").value = a;
    ;document.getElementById("PolRadBox").value = b;
    ;document.getElementById("FlatBox").value = f;
    ;document.getElementById("RecipBox").value = 1/f;

    ;Consolewrite ("EqRadBox " & $a & @CRLF)
    ;Consolewrite ("PolRadBox " & $b & @CRLF)
    ;Consolewrite ("FlatBox " & $f & @CRLF)
    ;Consolewrite ("RecipBox " & (1/$f) & @CRLF)

    Local $OOZok = false;

    ;Fin de Declarations
    ;$k0 = 0.9996;//scale on central meridian
    ;$b = a*(1-f);//polar axis.
    ;//alert(a+"   "+b);
    ;//alert(1-(b/a)*(b/a));
    ;$e = Math.sqrt(1 - (b/a)*(b/a));//eccentricity
    ;//alert(e);
    ;//Input Geographic Coordinates
    ;//Decimal Degree Option
    Local $latd0 = $lat ;parseFloat(document.getElementById("DDLatBox0").value);
    Local $lngd0 = $long; parseFloat(document.getElementById("DDLonBox0").value);
    ;latd1 = Math.abs(parseFloat(document.getElementById("DLatBox0").value));
    ;latd1 = latd1 + parseFloat(document.getElementById("MLatBox0").value)/60;
    ;latd1 = latd1 + parseFloat(document.getElementById("SLatBox0").value)/3600;
    ;if (parseFloat(document.getElementById("DLatBox0").value)<0){latd1=-latd1;}
    ;lngd1 = Math.abs(parseFloat(document.getElementById("DLonBox0").value));
    ;lngd1 = lngd1 + parseFloat(document.getElementById("MLonBox0").value)/60;
    ;lngd1 = lngd1 + parseFloat(document.getElementById("SLonBox0").value)/3600;
    ;if (parseFloat(document.getElementById("DLonBox0").value)<0){lngd1=-lngd1;}

    $lngd=$lngd0;
    $latd=$latd0;
    ;if(isNaN(latd)){
    ;latd = latd1;
    ;document.getElementById("DDLatBox0").value = Math.floor(1000000*latd)/1000000;
    ;lngd=lngd1;
    ;document.getElementById("DDLonBox0").value = Math.floor(1000000*lngd)/1000000;
    ;}

    ;if(isNaN(lngd)){lngd = latd1;}
    If (Not (IsNumber($latd)) )Or (Not (IsNumber($lngd)) ) Then

        ;if(isNaN(latd)|| isNaN(lngd)){
        ;alert("Non-Numeric Input Value");
        ConsoleWrite("Non-Numeric Input Value" & @CRLF)
    EndIf
        ;}
    ;if(latd <-90 || latd> 90){
    If  ($latd <-90 Or $latd> 90) then
        ;alert("Latitude must be between -90 and 90");
        ConsoleWrite("Latitude must be between -90 and 90" & @CRLF)
    EndIf

    ;if(lngd <-180 || lngd > 180){
    If ($lngd <-180 Or $lngd > 180) then
        ;alert("Latitude must be between -180 and 180");
        ConsoleWrite("Longitud must be between -180 and 180")
        ;}
    EndIf
    $xd = $lngd;
    $yd = $latd;

    ;?????????????????????????? ES NECESARIO ?????????????????????????
    ;DDtoDMS();
    ;//Read Input from DMS Boxes
    ;document.getElementById("DLatBox0").value = Math.floor(ydd);
    ;document.getElementById("MLatBox0").value = ym;
    ;document.getElementById("SLatBox0").value = Math.floor(1000*ys)/1000;
    ;document.getElementById("DLonBox0").value = Math.floor(xdd);
    ;document.getElementById("MLonBox0").value = xm;
    ;document.getElementById("SLonBox0").value = Math.floor(1000*xs)/1000;
    ;??????????????????????????????????????????????????????????????????

    $phi = $latd*$drad;//Convert latitude to radians
    $lng = $lngd*$drad;//Convert longitude to radians
    $utmz = 1 + floor(($lngd+180)/6);//calculate utm zone
    $latz = 0;//Latitude zone: A-B S of -80, C-W -80 to +72, X 72-84, Y,Z N of 84
    ;if (latd > -80 && latd < 72){latz = Math.floor((latd + 80)/8)+2;}
    If  ($latd > -80 And $latd < 72) Then
        $latz = floor(($latd + 80)/8)+2
    EndIf
    ;if (latd > 72 && latd < 84){latz = 21;}
    If  ($latd > 72 AND $latd < 84) Then
        $latz = 21
    EndIf
    ;if (latd > 84){latz = 23;}
    If  $latd > 84 Then
        $latz = 23
    EndIf

    $zcm = 3 + 6*($utmz-1) - 180;//Central meridian of zone
    ;//alert(utmz + "   " + zcm);
    ;//Calculate Intermediate Terms
    $e0 = $e/sqrt(1 - $e*$e);//Called e prime in reference
    $esq = (1 - ($b/$a)*($b/$a));//e squared for use in expansions
    $e0sq = $e*$e/(1-$e*$e);// e0 squared - always even powers
    ;//alert(esq+"   "+e0sq)
    ;N = a/Math.sqrt(1-Math.pow(e*Math.sin(phi),2));
    $N = $a/sqrt(1-(($e*sin($phi))^2));
    ;//alert(1-Math.pow(e*Math.sin(phi),2));
    ;//alert("N=  "+N);
    $T = (tan($phi)^2);
    ;//alert("T=  "+T);
    ;C = e0sq*Math.pow(Math.cos(phi),2);
    $C = $e0sq*(cos($phi)^2);
    ;//alert("C=  "+C);
    $A1 = ($lngd-$zcm)*$drad*cos($phi);
    ;//alert("A=  "+A);
    ;//Calculate M
    ;M = phi*(1 - esq*(1/4 + esq*(3/64 + 5*esq/256)));
    ;M = M - Math.sin(2*phi)*(esq*(3/8 + esq*(3/32 + 45*esq/1024)));
    ;M = M + Math.sin(4*phi)*(esq*esq*(15/256 + esq*45/1024));
    ;M = M - Math.sin(6*phi)*(esq*esq*esq*(35/3072));

    $M = $phi*(1 - $esq*(1/4 + $esq*(3/64 + 5*$esq/256)));
    ;Consolewrite("M1 " & $M & @CRLF)
    $M = $M -sin(2*$phi)*($esq*(3/8 + $esq*(3/32 + 45*$esq/1024)));
    ;Consolewrite("M2 " & $M & @CRLF)
    $M = $M + sin(4*$phi)*($esq*$esq*(15/256 + $esq*45/1024));
    ;Consolewrite("M3 " & $M & @CRLF)
    $M = $M - sin(6*$phi)*($esq*$esq*$esq*(35/3072));
    ;Consolewrite("M4 " & $M & @CRLF)
    $M = $M*$a;//Arc length along standard meridian
    ;//alert(a*(1 - esq*(1/4 + esq*(3/64 + 5*esq/256))));
    ;//alert(a*(esq*(3/8 + esq*(3/32 + 45*esq/1024))));
    ;//alert(a*(esq*esq*(15/256 + esq*45/1024)));
    ;//alert(a*esq*esq*esq*(35/3072));
    ;//alert(M);
    ;Consolewrite("M " & $M & @CRLF)
    ;Consolewrite("$a " & $a & @CRLF)
    ;Consolewrite("$A1 " & $A1 & @CRLF)
    ;Consolewrite("$esq " & $esq & @CRLF)
    ;Consolewrite("$phi" & $phi & @CRLF)
    $M0 = 0;//M0 is M for some origin latitude other than zero. Not needed for standard UTM
    ;//alert("M    ="+M);
    ;//Calculate UTM Values
    $x = $k0*$N*$A1*(1 + $A1*$A1*((1-$T+$C)/6 + $A1*$A1*(5 - 18*$T + $T*$T + 72*$C -58*$e0sq)/120));//Easting relative to CM
    $x=$x+500000;//Easting standard
    ;y = k0*(M - M0 + N*Math.tan(phi)*(A*A*(1/2 + A*A*((5 - T + 9*C + 4*C*C)/24 + A*A*(61 - 58*T + T*T + 600*C - 330*e0sq)/720))));//Northing from equator
    $y = $k0*($M - $M0 + $N*tan($phi)*($A1*$A1*(1/2 + $A1*$A1*((5 - $T + 9*$C + 4*$C*$C)/24 + $A1*$A1*(61 - 58*$T + $T*$T + 600*$C - 330*$e0sq)/720))));//Northing from equator
    $yg = $y + 10000000;//yg = y global, from S. Pole
    ;if (y < 0){y = 10000000+y;}
    If $y <0 Then
        $y= 10000000+$y
    EndIf
    ;//Output into UTM Boxes
    ;document.getElementById("UTMzBox1").value = utmz; Esto es la zona
    ;document.getElementById("UTMeBox1").value = Math.round(10*(x))/10;  Esto es X
    ;document.getElementById("UTMnBox1").value = Math.round(10*y)/10;  Esto es Y
    ;if (phi<0){document.getElementById("SHemBox").checked=true;} ESto es si es norte o SUR

    $x =round(10*$x)/10
    $y =round(10*$y)/10
    $utmz = $utmz
    If $phi<0 then
        $SUR=True
    Else
        $SUR=False
    EndIf
    ;//document.getElementById("UTMzBox1").value = utmz;
    ;//document.getElementById("UTMeBox1").value = Math.round(10*(500000+x))/10;
    ;document.getElementById("UTMLonZoneBox2").value = utmz;
    ;document.getElementById("UTMLatZoneBox2").value = DigraphLetrsE[latz];
    ;document.getElementById("UTMeBox2").value = Math.round(10*(x-100000*Math.floor(x/100000)))/10;
    ;document.getElementById("UTMnBox2").value = Math.round(10*(y-100000*Math.floor(y/100000)))/10;
;//Generate Digraph
    ;MakeDigraph();
    ;document.getElementById("UTMDgBox2").value = Digraph;

Endfunc;//close Geog to UTM

Func UTMtoGeog($x,$y, Byref $longitud, Byref $latitud, $utmz=30, $SUR=FALSE, $DATUM=0)

    ;$SUR hemisphere ($SUR=False is North, $SUR=true is South)
    ;$utmz = UTM Zone ($utmz)
    ; $DATUM
    ;~  //Datum Info here: Name, a, b, f, 1/f
    ;~  0 //WGS 84  6,378,137.0 6356752.314 0.003352811 298.2572236
    ;~  1   //NAD 83    6,378,137.0 6356752.314 0.003352811 298.2572236
    ;~  2   //GRS 80    6,378,137.0 6,356,752.3 0.003352811 298.2572215
    ;~  3   //WGS 72    6,378,135.0 6,356,750.5 0.003352783 298.2597208
    ;~  4   //Australian 1965   6,378,160.0 6,356,774.7 0.003352895 298.2497323
    ;~  5   //Krasovsky 1940    6,378,245.0 6,356,863.0 0.003352333 298.2997381
    ;~  6   //North American 1927   6,378,206.4 6,356,583.8 0.003390075 294.9786982
    ;~  7   //International 1924    6,378,388.0 6,356,911.9 0.003367011 296.9993621
    ;~  8   //Hayford 1909  6,378,388.0 6,356,911.9 0.003367011 296.9993621
    ;~  9   //Clarke 1880   6,378,249.1 6,356,514.9 0.00340755  293.4660167
    ;~  10  //Clarke 1866   6,378,206.4 6,356,583.8 0.003390075 294.9786982
    ;~  11  //Airy 1830 6,377,563.4 6,356,256.9 0.003340853 299.3247788
    ;~  12  //Bessel 1841   6,377,397.2 6,356,079.0 0.003342774 299.1527052
    ;~  13  //Everest 1830  6,377,276.3 6,356,075.4 0.003324444 300.8021499
    ;//Convert UTM Coordinates to Geographic

    ; More information in:
    ; https://www.uwgb.edu/dutchs/UsefulData/UTMFormulas.HTM
    ; IMPORT from javascript version of: https://www.uwgb.edu/dutchs/UsefulData/ConvertUTMNoOZ.HTM

    ;Declarations();
    ;Symbols as used in USGS PP 1395: Map Projections - A Working Manual
    Local $M_PI= 3.14159265358979323846
    Local $DatumEqRad [14] = [6378137.0,6378137.0,6378137.0,6378135.0,6378160.0,6378245.0,6378206.4, 6378388.0,6378388.0,6378249.1,6378206.4,6377563.4,6377397.2,6377276.3];
    Local $DatumFlat[14] = [298.2572236, 298.2572236, 298.2572215,  298.2597208, 298.2497323, 298.2997381, 294.9786982, 296.9993621, 296.9993621, 293.4660167, 294.9786982, 299.3247788, 299.1527052, 300.8021499];
    Local $Item = $DATUM
    Local $k0 = 0.9996;//scale on central meridian
    Local $a = $DatumEqRad[$Item];//equatorial radius, meters.
    Local $f = 1/$DatumFlat[$Item];//polar flattening.
    Local $b = $a*(1-$f);//polar axis.
    Local $e = Sqrt (1 - ($b*$b)/($a*$a));//eccentricity
    Local $drad = $M_PI/180;//Convert degrees to radians)
    Local $latd = 0;//latitude in degrees
    Local $phi = 0;//latitude (north +, south -), but uses phi in reference
    Local $e0 = $e/Sqrt(1 - $e*$e);//e prime in reference
    ;; Creo que no hace falta y da error $N = $a/Sqrt(1-Math.pow($e*sin($phi)),2);
    Local $T = (Tan($phi)^2);
    Local $C = ($e*(cos($phi)^2));
    Local $lng = 0;//Longitude (e = +, w = -) - can't use long - reserved word
    Local $lng0 = 0;//longitude of central meridian
    Local $lngd = 0;//longitude in degrees
    Local $M = 0;//M requires calculation
    ;$x = 0;//x coordinate
    ;$y = 0;//y coordinate
    Local $k = 1;//local scale
    ;$utmz = 30;//utm zone
    Local $zcm = 0;//zone central meridian
    Local $DigraphLetrsE = "ABCDEFGHJKLMNPQRSTUVWXYZ";
    Local $DigraphLetrsN = "ABCDEFGHJKLMNPQRSTUV";
    ;document.getElementById("EqRadBox").value = a;
    ;document.getElementById("PolRadBox").value = b;
    ;document.getElementById("FlatBox").value = f;
    ;document.getElementById("RecipBox").value = 1/f;
    ;Consolewrite ("EqRadBox " & $a & @CRLF)
    ;Consolewrite ("PolRadBox " & $b & @CRLF)
    ;Consolewrite ("FlatBox " & $f & @CRLF)
    ;Consolewrite ("RecipBox " & (1/$f) & @CRLF)

    Local $OOZok = false;

    ;Fin de Declarations

    ;; $k0 = 0.9996;//scale on central meridian
    ;; $b = $a*(1-$f);//polar axis.
    ;; $e = Sqrt(1 - ($b/$a)*($b/$a));//eccentricity
    ;; $e0 = $e/Sqrt(1 - $e*$e);//Called e prime in reference
    Local $esq = (1 - ($b/$a)*($b/$a));//e squared for use in expansions
    Local $e0sq = $e*$e/(1-$e*$e);// e0 squared - always even powers
    ;x = parseFloat(document.getElementById("UTMeBox1").value);
    ;ConsoleWrite("$x " & $x & @CRLF)

    if ($x<160000 OR $x>840000) Then
        ConsoleWrite("Outside permissible range of easting values" & @CRLF & "Results may be unreliable" & @CRLF & "Use with caution" & @CRLF);}
    EndIf
    ;y = parseFloat(document.getElementById("UTMnBox1").value);
    ;//alert(y)
    if ($y<0)Then
        ConsoleWrite("Negative values not allowed" & @CRLF & "Results may be unreliable" & @CRLF & "Use with caution" & @CRLF)
    EndIf   ;}
    if ($y>10000000)then
        ConsoleWrite("Northing may not exceed 10,000,000" & @CRLF & "Results may be unreliable" & @CRLF & "Use with caution"& @CRLF);}
    EndIf
    ;utmz = parseFloat(document.getElementById("UTMzBox1").value);
    $zcm = 3 + 6*($utmz-1) - 180;//Central meridian of zone
    Local $e1 = (1 - Sqrt(1 - $e*$e))/(1 + Sqrt(1 - $e*$e));//Called e1 in USGS PP 1395 also
    Local $M0 = 0;//In case origin other than zero lat - not needed for standard UTM
    $M = $M0 + $y/$k0;//Arc length along standard meridian.
    if $SUR=true then
        $M=$M0+($y-10000000)/$k;}
    EndIf
    Local $mu = $M/($a*(1 - $esq*(1/4 + $esq*(3/64 + 5*$esq/256))));
    Local $phi1 = $mu + $e1*(3/2 - 27*$e1*$e1/32)*sin(2*$mu) + $e1*$e1*(21/16 -55*$e1*$e1/32)*sin(4*$mu);//Footprint Latitude
    $phi1 = $phi1 + $e1*$e1*$e1*(sin(6*$mu)*151/96 + ($e1*sin(8*$mu)*1097)/512);
    Local $C1 = $e0sq*(cos($phi1)^2);
    Local $T1 = tan($phi1)^2;
    Local $N1 = $a/sqrt(1-((($e*sin($phi1))^2)));
    Local $R1 = ($N1*(1-$e*$e))/(1-((($e*sin($phi1))^2)));R1 = N1*(1-e*e)/(1-Math.pow(e*Math.sin(phi1),2));
    Local $D = ($x-500000)/($N1*$k0);
    $phi = ($D*$D)*(1/2 - $D*$D*(5 + 3*$T1 + 10*$C1 - 4*$C1*$C1 - 9*$e0sq)/24);
        $phi = $phi + (($D^6)*(61 + 90*$T1 + 298*$C1 + 45*$T1*$T1 -252*$e0sq - 3*$C1*$C1))/720;
        $phi = $phi1 - (($N1*tan($phi1))/$R1)*$phi;

    ;//Output Latitude
    ;document.getElementById("DDLatBox0").value = Math.floor(1000000*phi/drad)/1000000;
    $latitud= floor(1000000*$phi/$drad)/1000000;
    Consolewrite( "latitud: " & $latitud & @CRLF)
    ;//Longitude
    $lng = $D*(1 + $D*$D*((-1 -2*$T1 -$C1)/6 + $D*$D*(5 - 2*$C1 + 28*$T1 - 3*$C1*$C1 +8*$e0sq + 24*$T1*$T1)/120))/cos($phi1);
    $lngd = $zcm+$lng/$drad;

    ;//Output Longitude
    ;document.getElementById("DDLonBox0").value = Math.floor(1000000*lngd)/1000000;
    $longitud=floor(1000000*$lngd)/1000000;
    Consolewrite( "Longitud: " & $longitud & @CRLF)

    ;//Parse DMS
    ;~  xd = lngd;
    ;~  yd = phi/drad;
    ;~  DDtoDMS();  Para pasar a Grados minutos y segundos.
    ;~  document.getElementById("DLatBox0").value = Math.floor(ydd);
    ;~  document.getElementById("MLatBox0").value = ym;
    ;~  document.getElementById("SLatBox0").value = Math.floor(1000*ys)/1000;
    ;~  document.getElementById("DLonBox0").value = Math.floor(xdd);
    ;~  document.getElementById("MLonBox0").value = xm;
    ;~  document.getElementById("SLonBox0").value = Math.floor(1000*xs)/1000;

    ;~  document.getElementById("UTMLonZoneBox2").value = utmz;
    ;~  document.getElementById("UTMLatZoneBox2").value = DigraphLetrsE[latz];
    ;~  document.getElementById("UTMeBox2").value = Math.round(10*(x-100000*Math.floor(x/100000)))/10;
    ;~  document.getElementById("UTMnBox2").value = Math.round(10*(y-100000*Math.floor(y/100000)))/10;
    ;~  MakeDigraph();
    ;~  document.getElementById("UTMDgBox2").value = Digraph;

EndFunc; End UTM to Geog

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...