diff --git a/build.xml b/build.xml index 45553b2..e893f99 100644 --- a/build.xml +++ b/build.xml @@ -227,6 +227,7 @@ Converting compiled files and external libraries into ${out-folder}/${dex-file}... + diff --git a/src/de/duenndns/aprsdroid/AprsPacket.scala b/src/de/duenndns/aprsdroid/AprsPacket.scala new file mode 100644 index 0000000..1bfe39d --- /dev/null +++ b/src/de/duenndns/aprsdroid/AprsPacket.scala @@ -0,0 +1,30 @@ +package de.duenndns.aprsdroid + +import _root_.android.location.Location + +object AprsPacket { + def splitCoord(c : Double) : (Int, Double, Int) = { + var deg = c.asInstanceOf[Int] + val min = (c - deg)*60 + var letter = 0 + if (deg < 0) { + deg = -deg + letter = 1 + } + (deg, min, letter) + } + + def formatLat(c : Double) : String = { + val (deg, min, letter) = splitCoord(c) + "%02d%05.2f%c".format(deg, min, "NS"(letter)) + } + def formatLon(c : Double) : String = { + val (deg, min, letter) = splitCoord(c) + "%03d%05.2f%c".format(deg, min, "EW"(letter)) + } + + def formatLoc(callsign : String, location : Location) : String = { + callsign + ">APRS:!" + formatLat(location.getLatitude) + "/" + + formatLon(location.getLongitude) + } +}