| @@ 28-54 (lines=27) @@ | ||
| 25 | __credits__ = [] |
|
| 26 | ||
| 27 | ||
| 28 | def dec2dm_lat(dec): |
|
| 29 | """Converts DecDeg to APRS Coord format. |
|
| 30 | See: http://ember2ash.com/lat.htm |
|
| 31 | ||
| 32 | Source: http://stackoverflow.com/questions/2056750 |
|
| 33 | ||
| 34 | Example: |
|
| 35 | >>> test_lat = 37.7418096 |
|
| 36 | >>> aprs_lat = dec2dm_lat(test_lat) |
|
| 37 | >>> aprs_lat |
|
| 38 | '3744.51N' |
|
| 39 | """ |
|
| 40 | dec_min = apex.aprs.decimaldegrees.decimal2dm(dec) |
|
| 41 | ||
| 42 | deg = dec_min[0] |
|
| 43 | abs_deg = abs(deg) |
|
| 44 | ||
| 45 | if not deg == abs_deg: |
|
| 46 | suffix = 'S' |
|
| 47 | else: |
|
| 48 | suffix = 'N' |
|
| 49 | ||
| 50 | retval = ''.join([str(abs_deg), "%.2f" % dec_min[1], suffix]) |
|
| 51 | if sys.version_info < (3, 0): |
|
| 52 | retval = unicodedata.normalize('NFKD', retval).encode('ascii', 'ignore') |
|
| 53 | ||
| 54 | return retval |
|
| 55 | ||
| 56 | ||
| 57 | def dec2dm_lng(dec): |
|
| @@ 57-81 (lines=25) @@ | ||
| 54 | return retval |
|
| 55 | ||
| 56 | ||
| 57 | def dec2dm_lng(dec): |
|
| 58 | """Converts DecDeg to APRS Coord format. |
|
| 59 | See: http://ember2ash.com/lat.htm |
|
| 60 | ||
| 61 | Example: |
|
| 62 | >>> test_lng = -122.38833 |
|
| 63 | >>> aprs_lng = dec2dm_lng(test_lng) |
|
| 64 | >>> aprs_lng |
|
| 65 | '12223.30W' |
|
| 66 | """ |
|
| 67 | dec_min = apex.aprs.decimaldegrees.decimal2dm(dec) |
|
| 68 | ||
| 69 | deg = dec_min[0] |
|
| 70 | abs_deg = abs(deg) |
|
| 71 | ||
| 72 | if not deg == abs_deg: |
|
| 73 | suffix = 'W' |
|
| 74 | else: |
|
| 75 | suffix = 'E' |
|
| 76 | ||
| 77 | retval = ''.join([str(abs_deg), "%.2f" % dec_min[1], suffix]) |
|
| 78 | if sys.version_info < (3, 0): |
|
| 79 | retval = unicodedata.normalize('NFKD', retval).encode('ascii', 'ignore') |
|
| 80 | ||
| 81 | return retval |
|
| 82 | ||
| 83 | ||
| 84 | def decode_aprs_ascii_frame(ascii_frame): |
|