store originating call of objects in table

storage_ts_index
Georg Lukas 2010-12-22 01:59:11 +01:00
rodzic 97f82ec4cd
commit 43ddb3989c
3 zmienionych plików z 8 dodań i 6 usunięć

Wyświetl plik

@ -82,15 +82,15 @@ object AprsPacket {
double2microdeg(comp.map(_-33).reduceLeft(_*91+_)/190463.0 - 180)
}
def parseReport(report : String) : (String, Int, Int, String, String) = {
def parseReport(report : String) : (String, Int, Int, String, String, String) = {
report match {
case PositionRegex(call, _, lat, sym1, lon, sym2, comment) =>
(call, coord2microdeg(lat), coord2microdeg(lon), sym1+sym2, comment)
(call, coord2microdeg(lat), coord2microdeg(lon), sym1+sym2, comment, null)
case PositionCompRegex(call, _, sym1comp, latcomp, loncomp, sym2, _, comment) =>
val sym1 = if ('a' <= sym1comp(0) && sym1comp(0) <= 'j') (sym1comp(0) - 'a' + '0').toChar else sym1comp
(call, compressed2lat(latcomp), compressed2lon(loncomp), sym1+sym2, comment)
(call, compressed2lat(latcomp), compressed2lon(loncomp), sym1+sym2, comment, null)
case ObjectRegex(call, objcall, lat, sym1, lon, sym2, comment) =>
(objcall.trim(), coord2microdeg(lat), coord2microdeg(lon), sym1+sym2, comment)
(objcall.trim(), coord2microdeg(lat), coord2microdeg(lon), sym1+sym2, comment, call)
}
}

Wyświetl plik

@ -226,7 +226,7 @@ class StationOverlay(icons : Drawable, context : Context, db : StorageDatabase)
def addStation(post : String) {
try {
val (call, lat, lon, sym, comment) = AprsPacket.parseReport(post)
val (call, lat, lon, sym, comment, origin) = AprsPacket.parseReport(post)
Log.d(TAG, "got %s(%d, %d)%s -> %s".format(call, lat, lon, sym, comment))
addStation(new Station(new GeoPoint(lat, lon), call, comment, sym))
} catch {

Wyświetl plik

@ -126,7 +126,7 @@ class StorageDatabase(context : Context) extends
def addPosition(ts : Long, message : String) {
try {
val (call, lat, lon, sym, comment) = AprsPacket.parseReport(message)
val (call, lat, lon, sym, comment, origin) = AprsPacket.parseReport(message)
val cv = new ContentValues()
cv.put(Position.TS, ts.asInstanceOf[java.lang.Long])
cv.put(Position.CALL, call.toUpperCase)
@ -134,6 +134,8 @@ class StorageDatabase(context : Context) extends
cv.put(Position.LON, lon.asInstanceOf[java.lang.Integer])
cv.put(Position.SYMBOL, sym)
cv.put(Position.COMMENT, comment)
if (origin != null)
cv.put(Position.ORIGIN, origin)
Log.d(TAG, "got %s(%d, %d)%s -> %s".format(call, lat, lon, sym, comment))
getWritableDatabase().insertOrThrow(Position.TABLE, Position.CALL, cv)
} catch {