kopia lustrzana https://git.sr.ht/~michalr/hamlocator
Fixed Maidenhead calculation
rodzic
f941f87756
commit
e1a2c295e2
|
@ -7,7 +7,7 @@ namespace Hamlocator {
|
|||
private string l2m;
|
||||
|
||||
public LocationToMaidenhead() {
|
||||
this.l2m = "abcdefghijklmnopqrstuvwxyz";
|
||||
this.l2m = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
}
|
||||
|
||||
public string get_locator(GClue.Location pos) {
|
||||
|
@ -15,10 +15,10 @@ namespace Hamlocator {
|
|||
double lon = pos.longitude + 180;
|
||||
|
||||
// Field
|
||||
double lat1 = (lat / 10) + 0.0000001;
|
||||
double lon1 = (lon / 20) + 0.0000001;
|
||||
double lat1 = (lat / 10);
|
||||
double lon1 = (lon / 20);
|
||||
|
||||
string loc1 = @"$(this.l2m[Math.lround(Math.floor(lon1))])$(this.l2m[Math.lround(Math.floor(lat1))])".up();
|
||||
string loc1 = @"$(this.l2m[Math.lround(Math.floor(lon1))])$(this.l2m[Math.lround(Math.floor(lat1))])";
|
||||
|
||||
// Square
|
||||
double lat2 = 10 * (lat1 - Math.floor(lat1));
|
||||
|
@ -27,10 +27,10 @@ namespace Hamlocator {
|
|||
string loc2 = @"$(Math.lround(Math.floor(lon2)))$(Math.lround(Math.floor(lat2)))";
|
||||
|
||||
// Subsquare
|
||||
double lat3 = 24 * (lat1 - Math.floor(lat1));
|
||||
double lon3 = 24 * (lon1 - Math.floor(lon1));
|
||||
double lat3 = 24 * (lat2 - Math.floor(lat2));
|
||||
double lon3 = 24 * (lon2 - Math.floor(lon2));
|
||||
|
||||
string loc3 = @"$(this.l2m[Math.lround(Math.floor(lon3))])$(this.l2m[Math.lround(Math.floor(lat3))])";
|
||||
string loc3 = @"$(this.l2m[Math.lround(Math.floor(lon3))])$(this.l2m[Math.lround(Math.floor(lat3))])".down();
|
||||
|
||||
return @"$loc1$loc2$loc3";
|
||||
}
|
||||
|
|
|
@ -11,6 +11,18 @@ public class MaidenheadTests : TestCase {
|
|||
add_test_location(90.0, -180.0, "AS00aa");
|
||||
add_test_location(-90.0, 180.0, "SA00aa");
|
||||
|
||||
add_test_location(51.0, 17.0, "JO80lx");
|
||||
add_test_location(51.1, 17.1, "JO81nc");
|
||||
add_test_location(51.2, 17.2, "JO81oe");
|
||||
add_test_location(51.3, 17.3, "JO81ph");
|
||||
add_test_location(51.4, 17.4, "JO81qj");
|
||||
add_test_location(51.5, 17.5, "JO81sm");
|
||||
add_test_location(51.6, 17.6, "JO81to");
|
||||
add_test_location(51.7, 17.7, "JO81uq");
|
||||
add_test_location(51.8, 17.8, "JO81vt");
|
||||
add_test_location(51.9, 17.9, "JO81wv");
|
||||
add_test_location(51.99, 17.99, "JO81xx");
|
||||
|
||||
add_test_location(51.1205, 17.0261, "JO81mc");
|
||||
add_test_location(37.1104, -5.4932, "IM77gc");
|
||||
add_test_location(-30.5377, 22.8516, "KF19kl");
|
||||
|
|
Ładowanie…
Reference in New Issue