|
Yksityiskohtien viidakko on tarjolla toisella sivulla.
<?php # -*- PHP -*-
$OTHERURI="mhbearing-r1.php?LANG=other"; $NOCACHE=1;
require("../include/head1.inc");
langfilt('FI: FI:Viestikallion työkaluja: Maidenhead suunta ja etäisyys<br>vain IARU R1 etäisyys EN:Viestikallio Tools: Maidenhead Bearing and Distance<br>IARU R1 distance only'); require("../include/head2.inc"); langfilt('FI: FI:Viestikallion työkaluja: Maidenhead suunta ja etäisyys<br>vain IARU R1 etäisyys EN:Viestikallio Tools: Maidenhead Bearing and Distance<br>IARU R1 distance only'); require("../include/head3.inc"); require("../include/menu.inc");
langfilt('FI:
<TABLE><TR><TD>
<FONT COLOR=GREEN> FI: Yksityiskohtien viidakko on tarjolla <A HREF="mhbearing.php">toisella sivulla</A>. EN: A dense presentation of deep details at available at <A HREF="mhbearing.php">other page</A>. </FONT> <P> ');
if ($HTTP_GET_VARS["SOURCE"] != "" || $HTTP_GET_VARS["source"] != "") { echo("<FONT SIZE=1>\n"); highlight_file("mhbearing-r1.php"); echo("</FONT>\n"); echo("</TD></TR></TABLE><P><HR><P>Matti Aarnio" . " - OH2MQK <matti.aarnio@zmailer.org>\n"); include("../include/base.inc"); include("../include/foot.inc"); exit; }
require("kkj-funcs.php"); require("geodinver.php"); require("maidenheadfuncs.php");
$DoTest = 0; if ($HTTP_GET_VARS["TEST"] != "" || $HTTP_GET_VARS["test"] != "") { $DoTest = 1; }
$DoKKJ = 0; $DoLaLo = 0; $DoLaLoWGS = 0; $Debug = 0; $DoMaidenhead = 0;
if ($HTTP_GET_VARS["DO-MH"] != "" || $HTTP_GET_VARS["do-mh"] != "") { $DoMaidenhead = 1; } if ($HTTP_POST_VARS["DO-MH"] != "" || $HTTP_POST_VARS["do-mh"] != "") { $DoMaidenhead = 1; }
$MHDIGITS = 0 + $HTTP_POST_VARS["MHDIGITS"]; if ($MHDIGITS == "") { $MHDIGITS = 0 + $HTTP_GET_VARS["MHDIGITS"]; } if ($MHDIGITS == "") { $MHDIGITS = 0 + $HTTP_GET_VARS["mhdigits"]; }
if ($MHDIGITS == 0) { $MHDIGITS = 10; }
if ($HTTP_GET_VARS["Debug"] != "") { $Debug = 1; } if ($HTTP_POST_VARS["Debug"] != "") { $Debug = 1; }
$QTHMH = $HTTP_POST_VARS["QTH-MH"]; if ($QTHMH == "") { $QTHMH = $HTTP_GET_VARS["QTH-MH"]; }
$WGSMH = $HTTP_POST_VARS["WGS-MH"]; if ($WGSMH == "") $WGSMH = $HTTP_GET_VARS["WGS-MH"];
if ($Debug) { # TEST TEST!
echo("<FONT SIZE=1><PRE>\n"); echo("---------- Headers --------------\n"); $headers = getallheaders(); for(reset($headers); $key = key($headers); next($headers)) { echo("$key = $headers[$key]\n"); } echo("---------- GET VARS --------------\n"); $headers = $HTTP_GET_VARS; for(reset($headers); $key = key($headers); next($headers)) { echo("$key = $headers[$key]\n"); } echo("---------- POST VARS -------------\n"); $headers = $HTTP_POST_VARS; for(reset($headers); $key = key($headers); next($headers)) { echo("$key = $headers[$key]\n"); } echo("----------------------------------\n"); echo("</PRE></FONT>\n"); }
# # Input: This[La] Source Latitude, in radians # This[Lo] Source Longitude, in radians # That[La] Destination Latitude, in radians # That[Lo] Destination Longitude, in radians # Output: R[s] Distance, in kilometers #
function maidenhead_km_distance($This, $That) {
#Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", #Sky and Telescope, vol. 68, no. 2, 1984, p. 159):
$dlon = $That[Lo] - $This[Lo]; $dlat = $That[La] - $This[La];
$sinDlat2 = sin($dlat/2); $sinDlon2 = sin($dlon/2); $a = ($sinDlat2 * $sinDlat2 + cos($This[La]) * cos($That[La]) * $sinDlon2 * $sinDlon2);
# The Haversine Formula can be expressed in terms of a two-argument # inverse tangent function, atan2(y,x), instead of an inverse sine # as follows (no bulletproofing is needed for an inverse tangent):
$c = 2.0 * atan2( sqrt($a), sqrt(1.0-$a) ); # $d = R * $c ; # Radius of ball times angle [radians] ...
$R[s] = rad2deg($c) * 111.2;
return($R);
}
define("gm4anb_a", 6378388.0); # Semi-major axis define("gm4anb_b", 6356912.0); # Semi-minor axis define("gm4anb_b2pera2", (gm4anb_b * gm4anb_b / gm4anb_a / gm4anb_a)); define("gm4anb_e", 1.0 - gm4anb_b2pera2); # Eccentricity squared
# # Input: This[La] Source Latitude, in radians # This[Lo] Source Longitude, in radians # That[La] Destination Latitude, in radians # That[Lo] Destination Longitude, in radians # Output: R[s] Distance, in kilometers #
# Math explained: http://www.kirsta.com/radio/dxrechow.doc
function gm4anb_km_distance($This, $That) {
# double e, si, co, th, ca, a1, a2, l1, l2, ep; /* Locals */
# Convert latitudes to geocentric
$This[La] = atan(gm4anb_b2pera2 * tan($This[La])); $That[La] = atan(gm4anb_b2pera2 * tan($That[La]));
# lat1 = atan((b * b) / (a * a) * tan(lat1)); # lat2 = atan((b * b) / (a * a) * tan(lat2));
# Calculate central angle #ca = acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon2-lon1));
$ca = acos(sin($This[La])*sin($That[La]) + cos($This[La])*cos($That[La])*cos($That[Lo]-$This[Lo]));
# #Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", # #Sky and Telescope, vol. 68, no. 2, 1984, p. 159): # # $dlon = $That[Lo] - $This[Lo]; # $dlat = $That[La] - $This[La]; # # $sinDlat2 = sin($dlat/2); # $sinDlon2 = sin($dlon/2); # $a = ($sinDlat2 * $sinDlat2 + # cos($This[La]) * cos($That[La]) * $sinDlon2 * $sinDlon2); # # # The Haversine Formula can be expressed in terms of a two-argument # # inverse tangent function, atan2(y,x), instead of an inverse sine # # as follows (no bulletproofing is needed for an inverse tangent): # # $ca = 2.0 * atan2( sqrt($a) , sqrt(1.0 - $a) );
$lat1 = $This[La]; $lat2 = $That[La];
# Calculate angles along great ellipse from equator if ($lat1 > $lat2) { $t = $lat2; $lat2 = $lat1; $lat1 = $t; }
$si = sin($lat1) * sin($ca); $co = sin($lat2) - sin($lat1) * cos($ca); $a1 = atan2($si, $co); $a2 = $a1 + $ca;
# Calculate ellipticity (squared) of great circle */
$th = sin($lat2) / sin($a2); $ep = gm4anb_e * $th * $th;
# Calculate great circle distance from equator for each */ $l1 = gm4anb_a * ($a1 - $ep * $a1 / 4.0 + $ep * sin(2.0 * $a1) / 8.0); $l2 = gm4anb_a * ($a2 - $ep * $a2 / 4.0 + $ep * sin(2.0 * $a2) / 8.0);
$R[s] = ($l2 - $l1) * 0.001; # Station distance is difference
return($R); }
function printbearingdistance($R, $POINT, $Az0) {
global $LANG;
printf(" %s ", $POINT);
langfilt('FI:Etäisyys EN:Distance');
if ($R[dist] >= 10000.0) printf(" = %3.3f km", $R[dist]/1000.0 ); else printf(" = %4.3f m", $R[dist] );
printf(" Az %3.3f°", rad2deg($R[Az]));
if ($Az0 < 0.0) printf(" RevAz %3.3f°", rad2deg($R[rAz])); else { $dK = $R[Az] - $Az0; if ($dK > M_PI) $dK -= M_PI + M_PI; if ($dK < -M_PI) $dK += M_PI + M_PI; if ($LANG == "fi") printf(" dK %4.3f°", rad2deg($dK)); else printf(" dM %4.3f°", rad2deg($dK)); } printf("\n");
}
function bearingdistanceMH($MyWGS1, $ThatWGS1, $MyWGS2, $ThatWGS2) {
langfilt('**: FI:MH: Etäisyys Maidenhead laskentasäännöillä: EN:MH: Distance with Maidenhead computing rules:
FI:R1: Etäisyys Region-1/GM4ANB:n ennätyslaskentasäännöillä: EN:R1: Distance with Region-1/GM4ANB\'s distance record computing rules:
');
if ($MyWGS1[MH] != "" && $ThatWGS1[MH] != "") { printf(" %-10s -> %-10s", $MyWGS1[MH], $ThatWGS1[MH]);
$R = maidenhead_km_distance($MyWGS1,$ThatWGS1); printf(" MH Distance: %4.3f km\n", $R[s]); $RR[0] = $R[s];
$R = gm4anb_km_distance($MyWGS1,$ThatWGS1); printf(" %-10s -> %-10s", $MyWGS1[MH], $ThatWGS1[MH]); printf(" R1 Distance: %4.3f km\n", $R[s]);
$R = ellipsoidal_great_circle($MyWGS1, $ThatWGS1, $EL); printf("\n Azimuth: %5.1f RevAzimuth: %5.1f\n", rad2deg($R[Az]), rad2deg($R[rAz])); }
# if ($MyWGS2[MH] != "" && $ThatWGS2[MH] != "") { # printf(" %-10s -> %-10s", $MyWGS2[MH], $ThatWGS2[MH]); # # $R = maidenhead_km_distance($MyWGS2,$ThatWGS2); # printf(" MH Distance: %4.3f km\n", $R[s]); # $RR[1] = $R[s]; # # $R = gm4anb_km_distance($MyWGS2,$ThatWGS2); # printf(" %-10s -> %-10s", $MyWGS2[MH], $ThatWGS2[MH]); # printf(" R1 Distance: %4.3f km\n", $R[s]); # }
return($RR); }
function bearingdistance($MyWGS, $ThatWGS, $MHdist) {
global $LANG;
# GRS80 ellipsoid: $EL[a] = 6378137.0; $EL[f] = 1.0/298.25722210088;
$ELw[a] = 6378137.0; $ELw[f] = 1.0/298.257223563; # a.k.a. "WGS84"
$ELh[a] = 6378388.0; # Hayford ellipsoid $ELh[f] = 1/297.0;
$ELs[a] = 6378388.0; # "ball" $ELs[f] = 0;
if ($MyWGS[MH] != $ThatWGS[MH]) { $R = ellipsoidal_great_circle($MyWGS, $ThatWGS, $EL); # $Rw = ellipsoidal_great_circle($MyWGS, $ThatWGS, $ELw); # $Rh = ellipsoidal_great_circle($MyWGS, $ThatWGS, $ELh); # $Rs = ellipsoidal_great_circle($MyWGS, $ThatWGS, $ELs); }
if ($MyWGS[MH] != "" && $ThatWGS[MH] != "") { printf("\n%s -> %s\n", $MyWGS[MH], $ThatWGS[MH]); }
if ($LANG == "fi") { printf("<I><FONT SIZE=1>Globaali GSR80 ellipsoidi (~ WGS84):</FONT></I>\n"); printbearingdistance($R, "K ", -1); # printbearingdistance($Rw, "Kw", -1); # printf("<I><FONT SIZE=1>Hayford ellipsoidilla ja pallolla laskien:</FONT></I>\n"); # printbearingdistance($Rh, "Kh", -1); # printbearingdistance($Rs, "Kp", -1); } else { printf("<I><FONT SIZE=1>GSR80 global ellipsoid (~ WGS84):</FONT></I>\n"); printbearingdistance($R, "M ", -1); # printbearingdistance($Rw, "Mw", -1); # printf("<I><FONT SIZE=1>Computing at Hayford ellipsoid and at sphere:</FONT></I>\n"); # printbearingdistance($Rh, "Mh", -1); # printbearingdistance($Rs, "Ms", -1); }
if ($ThatWGS[dLo]) {
$Wsw[La] = $ThatWGS[La] - $ThatWGS[dLa]; $Wsw[Lo] = $ThatWGS[Lo] - $ThatWGS[dLo];
$Wse[La] = $ThatWGS[La] - $ThatWGS[dLa]; $Wse[Lo] = $ThatWGS[Lo] + $ThatWGS[dLo];
$Wne[La] = $ThatWGS[La] + $ThatWGS[dLa]; $Wne[Lo] = $ThatWGS[Lo] + $ThatWGS[dLo];
$Wnw[La] = $ThatWGS[La] + $ThatWGS[dLa]; $Wnw[Lo] = $ThatWGS[Lo] - $ThatWGS[dLo];
$Rsw = ellipsoidal_great_circle($MyWGS, $Wsw, $EL); $Rse = ellipsoidal_great_circle($MyWGS, $Wse, $EL); $Rne = ellipsoidal_great_circle($MyWGS, $Wne, $EL); $Rnw = ellipsoidal_great_circle($MyWGS, $Wnw, $EL);
# $Rsw[Az] -= $R[Az]; # $Rse[Az] -= $R[Az]; # $Rne[Az] -= $R[Az]; # $Rnw[Az] -= $R[Az];
if ($LANG == "fi") printf("<I><FONT SIZE=1>Ruudun nurkkapisteisiin:</FONT></I>\n"); else printf("<I><FONT SIZE=1>Square corner points:</FONT></I>\n");
printbearingdistance($Rsw, "SW", $R[Az]); printbearingdistance($Rse, "SE", $R[Az]); printbearingdistance($Rne, "NE", $R[Az]); printbearingdistance($Rnw, "NW", $R[Az]); } }
# # Converts WGS84 Lat/Long/Alt pair into geocentric GSR80 X/Y/Z coordinates # # Inputs: # $lat = Latitude, Radians # $long = Longitude, Radians # $alt = Altitude, meters relative to GSR80 geoid # # Outputs: # $R[X] = Geocentric X coordinate, meters # $R[Y] = Geocentric Y coordinate, meters # $R[Z] = Geocentric Z coordinate, meters #
function latlong2xyz($lat,$long,$alt) { $a = 6378137.0; $b = 6356752.0;
$aa = $a * $a; $bb = $b * $b; $coslat = cos($lat); $sinlat = sin($lat);
$N = $aa / sqrt($aa * $coslat * $coslat + $bb * $sinlat * $sinlat);
$R[X] = ($N + $alt) * $coslat * cos($long); $R[Y] = ($N + $alt) * $coslat * sin($long); $R[Z] = ($bb/$aa * $N + $alt) * $sinlat;
return ($R); }
# # Distance in between two XYZ coordinates # # Inputs: $This[X] Geocentric X coordinate # $This[Y] Geocentric Y coordinate # $This[Z] Geocentric Z coordinate # $That[X] Geocentric X coordinate # $That[Y] Geocentric Y coordinate # $That[Z] Geocentric Z coordinate # # Outputs: $R[s] Direct line distance, same units as inputs #
function xyzdistance($This, $That) { $dX = $That[X] - $This[X]; $dY = $That[Y] - $This[Y]; $dZ = $That[Z] - $This[Z];
$R[dX] = $dX; $R[dY] = $dY; $R[dZ] = $dZ;
$R[s] = sqrt( $dX * $dX + $dY * $dY + $dZ * $dZ );
return ($R); }
######## TEST STUFF ########
function KKJ_LaLo_test($la1,$la2,$la3, $lo1,$lo2,$lo3,$P0,$I0) { $WGS[La] = deg2rad(dms2deg($la1,$la2,$la3)); $WGS[Lo] = deg2rad(dms2deg($lo1,$lo2,$lo3)); printf("\nTEST CASE: %s %s\n", fmtdms($WGS[La],1), fmtdms($WGS[Lo],0)); global $Long0; global $ZoneNumber; $ED5w = WGSLaLo_to_WGSxy($WGS, $ZoneNumber, $Long0); $KKJ = WGSxy_to_KKJ($ED5w); # $ED5w = KKJLaLo_to_KKJxy($WGS,$Long0); # $KKJ = ED50xy_to_KKJ($ED5w); printf(" ED50w P = %8.1f I = %8.1f\n", $ED5w[X], $ED5w[Y]); printf(" KKJ P = %8.1f I = %8.1f\n", $KKJ[X], $KKJ[Y]); printf("Should be: P = %.3f I = %.3f\n", $P0,$I0); printf(" dP = %8.3f dI = %8.3f\n", $KKJ[X]-$P0,$KKJ[Y]-$I0); }
if ($DoTest) {
echo("<PRE>\n\n"); echo(" Testing the algorithms:\n"); printf("TEST CASE: N 60°44'25.5072\"". " E 26°10'35.6438\"\n");
$ED50[La] = deg2rad(dms2deg( 60,44,25.5072)); $ED50[Lo] = deg2rad(dms2deg( 26,10,35.6438)); $WGS[La] = deg2rad(dms2deg( 60,44,26.6 )); $WGS[Lo] = deg2rad(dms2deg( 26,10,24.2 ));
printf(" fmt: %s %s\n", fmtdms($ED50[La],1), fmtdms($ED50[Lo],0)); printf(" fmt: %s %s\n", fmtdms($WGS[La],1), fmtdms($WGS[Lo],0));
$ED5 = KKJLaLo_to_KKJxy($ED50, $ZoneNumber, $Long0); $ED5w = WGSLaLo_to_WGSxy($WGS, $ZoneNumber, $Long0); $KKJ = ED50xy_to_KKJ($ED5);
printf(" WGSxy P = %8.1f I = %8.1f\n", $ED5w[X], $ED5w[Y]); printf(" KKJ P = %8.1f I = %8.1f\n", $KKJ[X], $KKJ[Y]); printf(" ED50xy P = %8.1f I = %8.1f\n", $ED5[X], $ED5[Y]); $P0 = 6737009.924; $I0 = 3455081.597; printf("Should be: P = %.3f I = %.3f\n", $P0,$I0); printf(" dP = %8.3f dI = %8.3f\n", $ED5[X]-$P0,$ED5[Y]-$I0);
KKJ_LaLo_test(63,46, 4.7071, 27,38,30.5830, 7074280.405, 3531837.668); KKJ_LaLo_test(60,13, 2.8760, 24,23,40.1880, 6681284.022, 3355761.859);
KKJ_LaLo_test(60, 0, 0.0001, 20, 0, 0.0000, 6674883.03, 3110054.63 ); KKJ_LaLo_test(60, 0, 0.0001, 27, 0, 0.0000, 6654203.70, 3500168.98 ); KKJ_LaLo_test(60, 0, 0.0001, 32, 0, 0.0000, 6664747.91, 3778993.05 );
KKJ_LaLo_test(70, 0, 0.0001, 20, 0, 0.0000, 7784451.51, 3233376.02 ); KKJ_LaLo_test(70, 0, 0.0001, 27, 0, 0.0000, 7769113.61, 3500171.81 ); KKJ_LaLo_test(70, 0, 0.0001, 32, 0, 0.0000, 7776941.00, 3690918.66 );
echo("\n</PRE>\n");
printf("</TD></TR></TABLE><P><HR><P>Matti Aarnio" . " - OH2MQK <matti.aarnio@zmailer.org>\n"); include("../include/base.inc"); include("../include/foot.inc"); exit; } # end of '$DoTest'
?>
<P>
<HR><A NAME="QTH-MH"></A> <!-- <?php intlinks(); ?> --> <P> <FORM ACTION="mhbearing-r1.php" METHOD=GET> <?php langfilt('FI: FI: <H3>Tarkka Maidenhead koordinaatti QTH:llesi:</H3> EN: <H3>High-resolution Maidenhead coordinate for your QTH:</H3> <P>
<INPUT TYPE="HIDDEN" NAME="DO-MH" VALUE="1"> Maidenhead: <INPUT TYPE="text" NAME="QTH-MH" SIZE=18 VALUE="'.$QTHMH.'"> <P>
FI: <H3>Vasta-aseman Maidenhead ruutukoodi:</H3> EN: <H3>Remote station Maidenhead grid code:</H3> **: Maidenhead:
<INPUT TYPE="text" NAME="WGS-MH" SIZE=18 VALUE="'.$WGSMH.'"); <P> <!-- MH code: <?php form_mh_digits($MHDIGITS); ?> --> <!-- Debug: --> '); ?> <!-- <INPUT TYPE="checkbox" NAME="Debug"<?php if($Debug)echo(" CHECKED"); ?>> --> <BR> <INPUT TYPE="SUBMIT" VALUE="<?php if($LANG == "fi") {echo ("Laske MH-MH etäisyys"); }else{echo("Calculate the MH-MH distance");} ?>"> </FORM> <P>
<?php
# Input mode: MAIDENHEAD
if ($DoMaidenhead) {
$QTHMH = strtoupper($QTHMH);
$WGSQTH = parsemaidenhead($QTHMH); $WGSQTH4 = parsemaidenhead(substr($QTHMH,0,4)); $WGSQTH6 = parsemaidenhead(substr($QTHMH,0,6));
if ($WGSQTH[La] && $WGSQTH[Lo] && $WGSQTH[dLa] && $WGSQTH[dLo]) {
if (0) { langfilt('FI: FI:Lähtö QTH Ruudun keskikohta: EN:Origination QTH Grid square center:');
echo("<PRE>\n");
printf(" WGS84: %s %s\n", fmtdms($WGSQTH[La],1), fmtdms($WGSQTH[Lo],0)); printf(" WGS84: %s %s\n", fmtdmm($WGSQTH[La],1), fmtdmm($WGSQTH[Lo],0)); printf(" WGS84: %s %s\n", fmtddd($WGSQTH[La],1), fmtddd($WGSQTH[Lo],0));
$ThisXYZ = latlong2xyz($WGSQTH[La],$WGSQTH[Lo],0.0);
printf(" WGS84: X: %9.3fm\n", $ThisXYZ[X]); printf(" Y: %9.3fm\n", $ThisXYZ[Y]); printf(" Z: %9.3fm\n", $ThisXYZ[Z]);
echo("</PRE>\n");
langfilt('FI: FI:Lähtö QTH Ruudun puolikorkeus/puolileveys: EN:Origination QTH Grid square half-height/half-width:');
echo("<PRE>\n");
printf(" Delta: %s %s\n", fmtdms($WGSQTH[dLa],1), fmtdms($WGSQTH[dLo],0)); printf(" Delta: %s %s\n", fmtdmm($WGSQTH[dLa],1), fmtdmm($WGSQTH[dLo],0)); printf(" Delta: %s %s\n", fmtddd($WGSQTH[dLa],1), fmtddd($WGSQTH[dLo],0));
echo("\n");
$KKJtest[La] = $WGSQTH[La]; $KKJtest[Lo] = deg2rad(27.0); $KKJ3 = KKJLaLo_to_KKJxy($KKJtest, 3, deg2rad(27.0)); $KKJtestP[La] = $KKJtest[La] + $WGSQTH[dLa]; $KKJtestP[Lo] = $KKJtest[Lo]; $KKJtest3 = KKJLaLo_to_KKJxy($KKJtest, 3, deg2rad(27.0)); $KKJtestI[La] = $KKJtest[La]; $KKJtestI[Lo] = $KKJtest[Lo] + $WGSQTH[dLo]; $KKJtest3P = KKJLaLo_to_KKJxy($KKJtestP, 3, deg2rad(27.0)); $KKJtest3I = KKJLaLo_to_KKJxy($KKJtestI, 3, deg2rad(27.0));
printmhdimensions($KKJtest3P[X] - $KKJ3[X], $KKJtest3I[Y] - $KKJ3[Y]);
if ($LANG == "fi") printf("<P ALIGN=CENTER><IMG SRC=\"mh-ruutu.gif\"></P>\n"); else printf("<P ALIGN=CENTER><IMG SRC=\"mh-square.gif\"></P>\n");
echo("</PRE>\n"); } } else { echo(" ** INVALID QTH-MH INPUT ??? **\n\n"); }
# echo("<HR WIDTH=\"49%\" ALIGN=CENTER>"); # # echo("MAIDENHEAD -> WGS84 / KKJ\n"); # echo("<PRE>\n\n"); # # if ($LANG == "fi") # printf("Syöte: '%s'\n\n", $WGSMH); # else # printf("Input: '%s'\n\n", $WGSMH);
$MH = parsemaidenhead($WGSMH); $MH4 = parsemaidenhead(substr($WGSMH,0,4)); $MH6 = parsemaidenhead(substr($WGSMH,0,6));
if ($MH[La] && $MH[Lo] && $MH[dLa] && $MH[dLo]) {
if (0) { langfilt('FI: FI:Kohde QTH Ruudun keskikohta: EN:Destination QTH Grid square midpoint:'); echo("\n");
printf(" WGS84: %s %s\n", fmtdms($MH[La],1), fmtdms($MH[Lo],0)); printf(" WGS84: %s %s\n", fmtdmm($MH[La],1), fmtdmm($MH[Lo],0)); printf(" WGS84: %s %s\n", fmtddd($MH[La],1), fmtddd($MH[Lo],0));
$ThatXYZ = latlong2xyz($MH[La],$MH[Lo],0.0); printf(" WGS84: X: %9.3fm\n", $ThatXYZ[X]); printf(" Y: %9.3fm\n", $ThatXYZ[Y]); printf(" Z: %9.3fm\n", $ThatXYZ[Z]);
$XYZdist = xyzdistance($ThisXYZ, $ThatXYZ);
printf(" XYZdistance = %9.3fm\n", $XYZdist[s]); printf(" dX = %9.3fm\n", $XYZdist[dX]); printf(" dY = %9.3fm\n", $XYZdist[dY]); printf(" dZ = %9.3fm\n", $XYZdist[dZ]);
echo("\n");
langfilt('FI: FI:Kohde QTH Ruudun puolikorkeus/puolileveys: EN:Destination QTH Grid square half-height/half-width:'); echo("\n");
printf(" Delta: %s %s\n", fmtdms($MH[dLa],1), fmtdms($MH[dLo],0)); printf(" Delta: %s %s\n", fmtdmm($MH[dLa],1), fmtdmm($MH[dLo],0)); printf(" Delta: %s %s\n", fmtddd($MH[dLa],1), fmtddd($MH[dLo],0));
echo("\n");
$KKJtest[La] = $MH[La]; $KKJtest[Lo] = deg2rad(27.0); $KKJ3 = KKJLaLo_to_KKJxy($KKJtest, 3, deg2rad(27.0)); $KKJtestP[La] = $KKJtest[La] + $MH[dLa]; $KKJtestP[Lo] = $KKJtest[Lo]; $KKJtest3 = KKJLaLo_to_KKJxy($KKJtest, 3, deg2rad(27.0)); $KKJtestI[La] = $KKJtest[La]; $KKJtestI[Lo] = $KKJtest[Lo] + $MH[dLo]; $KKJtest3P = KKJLaLo_to_KKJxy($KKJtestP, 3, deg2rad(27.0)); $KKJtest3I = KKJLaLo_to_KKJxy($KKJtestI, 3, deg2rad(27.0));
printmhdimensions($KKJtest3P[X] - $KKJ3[X], $KKJtest3I[Y] - $KKJ3[Y]);
langfilt('FI: FI:<P ALIGN=CENTER><IMG SRC=mh-ruutu.gif></P> EN:<P ALIGN=CENTER><IMG SRC=mh-square.gif></P>');
echo("\n");
mh_edge_distance($MH, $WGSMH); # WARNING! # DIFFERENT TO ALL OTHER INSTANCES!
echo("</PRE>\n");
langfilt("FI: FI: Kilpailujen säännöt sanovat, että kilpailuissa FI: etäisyydet lasketaan oleskeluruudun keskipisteestä FI: kohderuudun keskipisteeseen <B>pallofunktioilla</B> FI: ja että etäisyys <I>asteina</I> muunnetaan FI: kilometreiksi käyttäen kerrointa ``111.2'' FI: Lillehammerin kokouksen -99 päätöksen mukaan ruudun FI: sisäiset yhteydet saavat 1km. FI: Etäisyysvirhe suhteessa geodeettiseen laskentaan FI: on helposti havaittava. EN: Radio-amateur competition rules say that EN: distances are to be calculated from the mid-point EN: of the QTH locator grid square to destination's EN: similarly derived locator square mid-point. EN: This distance is calculated with <I>spherical EN: functions</I> with classical cosine equation EN: (or with Haversine variant of it), and the distance EN: in <I>degrees</I> is then multiplied with ``111.2'' EN: to get kilometers. EN: Per Lillehammer -99 meeting, contacts within a square EN: will be scored at 1km. EN: The error in distances is observable, although not EN: excessively large.");
} echo("<PRE>\n"); $RR = bearingdistanceMH($WGSQTH, $MH, $WGSQTH, $MHz); if (0) { bearingdistance($WGSQTH, $MH, -1 ); bearingdistance($WGSQTH, $MH4, -1); bearingdistance($WGSQTH4, $MH4, $RR[0]); bearingdistance($WGSQTH, $MH6, -1); bearingdistance($WGSQTH6, $MH6, $RR[1]);
echo("\n"); } } else { echo(" ** INVALID DESTINATION MH INPUT ??? **\n\n"); }
echo("</PRE>\n"); }
## } # end of if(!$DoTest) ... ## if (! $DoTest) {
?>
<P> <HR> <P>
<!-- <?php require("selitykset.php"); ?> -->
<P> <HR> <P>
<?php langfilt('
FI:<H3>Tämä työkalu koostuu useista lähdekoodimoduleista:</H3> EN:<H3>This tool consists of following source components:</H3> <UL> FI: <LI><A HREF="mhbearing-r1.php?source=1">mhbearing-r1.php</A>: FI: Pääkoodi EN: <LI><A HREF="mhbearing-r1.php?source=1">mhbearing-r1.php</A>: EN: The main code itself
FI: <LI><A HREF="kkj-funcs.php?source=1">kkj-funcs.php</A>: FI: Koordinaatistokäsittelyä, yms. yhteisiä juttuja EN: <LI><A HREF="kkj-funcs.php?source=1">kkj-funcs.php</A>: EN: Common stuff, coordinate transformations, HTML things, etc.
FI: <LI><A HREF="maidenheadfuncs.php?source=1">maidenheadfuncs.php</A>: FI: Maidenhead hilan käsittelyä EN: <LI><A HREF="maidenheadfuncs.php?source=1">maidenheadfuncs.php</A>: EN: Maidenhead grid coordinate processing
FI: <LI><A HREF="geodinver.php?source=1">geodinver.php</A>: FI: Geodeettisen käänteistehtävän matematiikka (Haetaan FI: etäisyys ja atsimuutit kahdelle annetulle pisteelle FI: ellipsoidilla.) EN: <LI><A HREF="geodinver.php?source=1">geodinver.php</A>: EN: Mathematics for the "geodetic inverse" problem. EN: (Finding distance and Azimuth between two points EN: on an ellipsoid.)
FI: <LI><A HREF="selitykset.php?source=1">selitykset.php</A>: FI: Yllä näkyvät selitystekstit. EN: <LI><A HREF="selitykset.php?source=1">selitykset.php</A>: EN: Explanations seen above...
</UL> <P> <HR> <P> ');
require("../include/sign-oh2mqk.inc");
printf("<P></TD></TR></TABLE>\n");
require("../include/base.inc"); require("../include/foot.inc");
?>
|