From 015b3dd46402e11ed47b57650f5a8ed69418a2b0 Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Mon, 22 Oct 2018 12:49:52 +0200 Subject: [PATCH] Service: enforce Locale on SQL and APRS output, fix #186 --- src/AprsPacket.scala | 4 ++-- src/Benchmark.scala | 2 +- src/StorageDatabase.scala | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/AprsPacket.scala b/src/AprsPacket.scala index 172c00d..8aac69c 100644 --- a/src/AprsPacket.scala +++ b/src/AprsPacket.scala @@ -38,7 +38,7 @@ object AprsPacket { def formatAltitude(location : Location) : String = { if (location.hasAltitude) - "/A=%06d".format(m2ft(location.getAltitude)) + "/A=%06d".formatLocal(null, m2ft(location.getAltitude)) else "" } @@ -47,7 +47,7 @@ object AprsPacket { // only report speeds above 2m/s (7.2km/h) if (location.hasSpeed && location.hasBearing) // && location.getSpeed > 2) - "%03d/%03d".format(location.getBearing.asInstanceOf[Int], + "%03d/%03d".formatLocal(null, location.getBearing.asInstanceOf[Int], mps2kt(location.getSpeed)) else "" diff --git a/src/Benchmark.scala b/src/Benchmark.scala index cbea398..25358a6 100644 --- a/src/Benchmark.scala +++ b/src/Benchmark.scala @@ -9,7 +9,7 @@ object Benchmark { block } finally { val exectime = System.currentTimeMillis - start - Log.d(tag, "exectuion time: %.3f s".format(exectime / 1000.0)) + Log.d(tag, "exectuion time: %.3f s".formatLocal(null, exectime / 1000.0)) } } } diff --git a/src/StorageDatabase.scala b/src/StorageDatabase.scala index ab4ac9e..1436ed7 100644 --- a/src/StorageDatabase.scala +++ b/src/StorageDatabase.scala @@ -243,7 +243,7 @@ class StorageDatabase(context : Context) extends cv.put(SPEED, cse.getSpeed().asInstanceOf[java.lang.Integer]) cv.put(COURSE, cse.getCourse().asInstanceOf[java.lang.Integer]) } - Log.d(TAG, "got %s(%d, %d)%s -> %s".format(call, lat, lon, sym, comment)) + Log.d(TAG, "got %s(%d, %d)%s -> %s".formatLocal(null, call, lat, lon, sym, comment)) // replace the full station info in stations table getWritableDatabase().replaceOrThrow(TABLE, CALL, cv) } @@ -284,7 +284,7 @@ class StorageDatabase(context : Context) extends } def getRectStations(lat1 : Int, lon1 : Int, lat2 : Int, lon2 : Int, limit : String) : Cursor = { - Log.d(TAG, "StorageDatabase.getRectStations: %d,%d - %d,%d".format(lat1, lon1, lat2, lon2)) + Log.d(TAG, "StorageDatabase.getRectStations: %d,%d - %d,%d".formatLocal(null, lat1, lon1, lat2, lon2)) // check for areas overflowing between +180 and -180 degrees val QUERY = if (lon1 <= lon2) "LAT >= ? AND LAT <= ? AND LON >= ? AND LON <= ?" else "LAT >= ? AND LAT <= ? AND (LON <= ? OR LON >= ?)" @@ -311,9 +311,9 @@ class StorageDatabase(context : Context) extends def getNeighbors(mycall : String, lat : Int, lon : Int, ts : Long, limit : String) : Cursor = { // calculate latitude correction val corr = (cos(Pi*lat/180000000.0)*cos(Pi*lat/180000000.0)*100).toInt - //Log.d(TAG, "getNeighbors: correcting by %d".format(corr)) + //Log.d(TAG, "getNeighbors: correcting by %d".formatLocal(null, corr)) // add a distance column to the query - val newcols = Station.COLUMNS :+ Station.COL_DIST.format(lat, lat, lon, lon, corr) + val newcols = Station.COLUMNS :+ Station.COL_DIST.formatLocal(null, lat, lat, lon, lon, corr) getReadableDatabase().query(Station.TABLE, newcols, "ts > ? or call = ?", Array(ts.toString, mycall), null, null, "dist", limit) @@ -322,9 +322,9 @@ class StorageDatabase(context : Context) extends def getNeighborsLike(call : String, lat : Int, lon : Int, ts : Long, limit : String) : Cursor = { // calculate latitude correction val corr = (cos(Pi*lat/180000000.0)*cos(Pi*lat/180000000.0)*100).toInt - Log.d(TAG, "getNeighborsLike: correcting by %d".format(corr)) + Log.d(TAG, "getNeighborsLike: correcting by %d".formatLocal(null, corr)) // add a distance column to the query - val newcols = Station.COLUMNS :+ Station.COL_DIST.format(lat, lat, lon, lon, corr) + val newcols = Station.COLUMNS :+ Station.COL_DIST.formatLocal(null, lat, lat, lon, lon, corr) getReadableDatabase().query(Station.TABLE, newcols, "call like ?", Array(call), null, null, "dist", limit) @@ -425,7 +425,7 @@ class StorageDatabase(context : Context) extends val result = if (c.getCount() == 0) 0 else c.getInt(0) + 1 - Log.d(TAG, "createMsgId(%s) = %d".format(call, result)) + Log.d(TAG, "createMsgId(%s) = %d".formatLocal(null, call, result)) c.close() result }