Skip to content

Commit

Permalink
55931-elys
Browse files Browse the repository at this point in the history
  • Loading branch information
ELY M committed Jan 6, 2025
1 parent 3ae7952 commit b284981
Show file tree
Hide file tree
Showing 26 changed files with 533 additions and 235 deletions.
Binary file added DOC/GEO/RawFiles/american_samoa
Binary file not shown.
Binary file added DOC/GEO/RawFiles/guam
Binary file not shown.
Binary file added DOC/GEO/RawFiles/mariana
Binary file not shown.
Binary file added DOC/GEO/RawFiles/statev2_50
Binary file not shown.
Binary file added DOC/GEO/RawFiles/usvi
Binary file not shown.
2 changes: 0 additions & 2 deletions DOC/Todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

## Features

* [ADD] text for Soundings
* [ADD] migrate Nexrad/Wfo sites to Sites/Site framework
* [ADD] edge-to-edge
- https://developer.android.com/about/versions/15/behavior-changes-15#ux
- https://developer.android.com/develop/ui/compose/layouts/insets
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ android {
}

dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.1'
// https://developer.android.com/jetpack/androidx/versions
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7'
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="55926"
android:versionName="55926-elys">
android:versionCode="55931"
android:versionName="55931-elys">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/java/joshuatee/wx/misc/HourlyActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ class HourlyActivity : BaseActivity() {
graphCard.setCardBackgroundColor(Color.BLACK)
graph = findViewById(R.id.graph)
graphCard.visibility = View.GONE
// cardVerticalText = CardVerticalText(this, 5, toolbar)
cardVerticalText = CardVerticalText2(this, toolbar)
box.addWidget(cardVerticalText)
cardVerticalText.connect { scrollView.scrollTo(0, 0) }
Expand All @@ -119,15 +118,6 @@ class HourlyActivity : BaseActivity() {
} else {
UtilityHourlyOldApi.getStringForActivity(htmlShare[1])
}
// cardVerticalText.set(
// listOf(
// hourly.time,
// hourly.temp,
// hourly.windSpeed,
// hourly.windDir,
// hourly.conditions
// )
// )
cardVerticalText.set(hourly.data)
plotData()
if (UIPreferences.hourlyShowGraph) {
Expand Down
104 changes: 62 additions & 42 deletions app/src/main/java/joshuatee/wx/radar/CanvasMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,16 @@ object CanvasMain {
}

fun addCanvasItems(
context: Context,
bitmapCanvas: Bitmap,
projectionType: ProjectionType,
radarSite: String,
citySize: Int,
context: Context,
bitmapCanvas: Bitmap,
projectionType: ProjectionType,
radarSite: String,
citySize: Int,
) {
// FIXME use this instead of radarSite and projectionType
val projectionNumbers = ProjectionNumbers(radarSite, projectionType)
val countyProvider = projectionType === ProjectionType.WX_RENDER_48 || projectionType === ProjectionType.WX_RENDER
val countyProvider =
projectionType === ProjectionType.WX_RENDER_48 || projectionType === ProjectionType.WX_RENDER
val cityProvider = true
val windBarbProvider = projectionType.isMercator
val stormMotionProvider = projectionType.isMercator
Expand All @@ -112,45 +113,49 @@ object CanvasMain {
}
if (RadarGeometry.dataByType[RadarGeometryTypeEnum.HwLines]!!.isEnabled) {
CanvasDraw.geometry(
projectionType,
bitmapCanvas,
radarSite,
RadarGeometryTypeEnum.HwLines,
geometryData.highways
projectionType,
bitmapCanvas,
radarSite,
RadarGeometryTypeEnum.HwLines,
geometryData.highways
)
}
if (RadarPreferences.cities && cityProvider) {
CanvasDraw.cities(projectionType, bitmapCanvas, projectionNumbers, citySize)
}
CanvasDraw.geometry(
projectionType,
bitmapCanvas,
radarSite,
RadarGeometryTypeEnum.StateLines,
geometryData.stateLines
projectionType,
bitmapCanvas,
radarSite,
RadarGeometryTypeEnum.StateLines,
geometryData.stateLines
)
if (RadarGeometry.dataByType[RadarGeometryTypeEnum.LakeLines]!!.isEnabled) {
CanvasDraw.geometry(
projectionType,
bitmapCanvas,
radarSite,
RadarGeometryTypeEnum.LakeLines,
geometryData.lakes
projectionType,
bitmapCanvas,
radarSite,
RadarGeometryTypeEnum.LakeLines,
geometryData.lakes
)
}
if (countyProvider) {
if (RadarGeometry.dataByType[RadarGeometryTypeEnum.CountyLines]!!.isEnabled) {
CanvasDraw.geometry(
projectionType,
bitmapCanvas,
radarSite,
RadarGeometryTypeEnum.CountyLines,
geometryData.counties
projectionType,
bitmapCanvas,
radarSite,
RadarGeometryTypeEnum.CountyLines,
geometryData.counties
)
}
}
if (PolygonType.LOCDOT.pref) {
CanvasDraw.locationDotForCurrentLocation(projectionType, bitmapCanvas, projectionNumbers)
CanvasDraw.locationDotForCurrentLocation(
projectionType,
bitmapCanvas,
projectionNumbers
)
}
if (PolygonType.WIND_BARB.pref && windBarbProvider) {
CanvasWindbarbs.draw(context, projectionType, bitmapCanvas, radarSite, true, 5)
Expand Down Expand Up @@ -187,7 +192,9 @@ object CanvasMain {
val mxCnt = 151552
val stateLinesFileResId = R.raw.statev2
var stateRelativeBuffer: ByteBuffer = ByteBuffer.allocateDirect(0)
val countState = 200000 // v3 205748
// val countState = 200000 // v3 205748
val countState =
234828 // 2025_01_05 in support of USVI/AS, not sure why old value was 200000 and not 205748
var hwRelativeBuffer: ByteBuffer = ByteBuffer.allocateDirect(0)
val countHw = 862208 // on disk size 3448832 yields 862208
val countHwExt = 770048 // on disk 3080192 yields 770048
Expand All @@ -200,28 +207,36 @@ object CanvasMain {
val lakesFileResId = R.raw.lakesv3
val countyFileResId = R.raw.county
val fileIds = listOf(
lakesFileResId,
hwFileResId,
countyFileResId,
stateLinesFileResId,
canadaResId,
mexicoResId,
hwExtFileResId
lakesFileResId,
hwFileResId,
countyFileResId,
stateLinesFileResId,
canadaResId,
mexicoResId,
hwExtFileResId
)
val countArr = listOf(countLakes, countHw, countCounty, countState, caCnt, mxCnt, countHwExt)
val countArr =
listOf(countLakes, countHw, countCounty, countState, caCnt, mxCnt, countHwExt)
try {
for (type in listOf(
RadarGeometryTypeEnum.HwLines,
RadarGeometryTypeEnum.CountyLines,
RadarGeometryTypeEnum.StateLines,
RadarGeometryTypeEnum.LakeLines
RadarGeometryTypeEnum.HwLines,
RadarGeometryTypeEnum.CountyLines,
RadarGeometryTypeEnum.StateLines,
RadarGeometryTypeEnum.LakeLines
)) {
when (type) {
RadarGeometryTypeEnum.StateLines -> {
stateRelativeBuffer = ByteBuffer.allocateDirect(4 * countState)
stateRelativeBuffer.order(ByteOrder.nativeOrder())
stateRelativeBuffer.position(0)
listOf(3).forEach { loadBuffer(context.resources, fileIds[it], stateRelativeBuffer, countArr[it]) }
listOf(3).forEach {
loadBuffer(
context.resources,
fileIds[it],
stateRelativeBuffer,
countArr[it]
)
}
}

RadarGeometryTypeEnum.HwLines -> {
Expand Down Expand Up @@ -255,7 +270,12 @@ object CanvasMain {
} catch (e: OutOfMemoryError) {
UtilityLog.handleException(e)
}
return GeometryData(hwRelativeBuffer, countyRelativeBuffer, stateRelativeBuffer, lakesRelativeBuffer)
return GeometryData(
hwRelativeBuffer,
countyRelativeBuffer,
stateRelativeBuffer,
lakesRelativeBuffer
)
}

private fun loadBuffer(resources: Resources, fileId: Int, byteBuffer: ByteBuffer, count: Int) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/joshuatee/wx/radar/Metar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ internal object Metar {
metars.forEach { z ->
var validWind = false
var validWindGust = false
if ((z.startsWith("K") || z.startsWith("P")) && !z.contains("NIL")) {
if ((z.startsWith("K") || z.startsWith("P") || z.startsWith("T")) && !z.contains("NIL")) {
val tmpArr2 = RegExp.space.split(z)
val tmpBlob = z.parse(pattern1)
val tdArr = RegExp.slash.split(tmpBlob)
Expand Down
120 changes: 65 additions & 55 deletions app/src/main/java/joshuatee/wx/radar/RadarGeomInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,30 @@ class RadarGeomInfo(val context: Context, private val type: RadarGeometryTypeEnu
// count values below are file size in bytes divided by 4 as these files contain binary packed floats
//

var isEnabled = Utility.readPref(context, prefToken[type]!!, defaultPref[type]!!).startsWith("t")
var isEnabled =
Utility.readPref(context, prefToken[type]!!, defaultPref[type]!!).startsWith("t")
private val lineSizeDefault = 2
var lineSize = Utility.readPrefInt(context, prefTokenLineSize[type]!!, lineSizeDefault).toFloat()
var colorInt = Utility.readPrefInt(context, prefTokenColorInt[type]!!, prefTokenColorIntDefault[type]!!)
var lineSize =
Utility.readPrefInt(context, prefTokenLineSize[type]!!, lineSizeDefault).toFloat()
var colorInt =
Utility.readPrefInt(context, prefTokenColorInt[type]!!, prefTokenColorIntDefault[type]!!)
var lineData: ByteBuffer = ByteBuffer.allocateDirect(0)
var count = typeToCount[type]!!
var fileId = typeToFileName[type]!!

fun update() {
isEnabled = Utility.readPref(context, prefToken[type]!!, defaultPref[type]!!).startsWith("t")
isEnabled =
Utility.readPref(context, prefToken[type]!!, defaultPref[type]!!).startsWith("t")
if (isEnabled && lineData.capacity() == 0) {
loadData(context)
}
lineSize = Utility.readPrefInt(context, prefTokenLineSize[type]!!, lineSizeDefault).toFloat()
colorInt = Utility.readPrefInt(context, prefTokenColorInt[type]!!, prefTokenColorIntDefault[type]!!)
lineSize =
Utility.readPrefInt(context, prefTokenLineSize[type]!!, lineSizeDefault).toFloat()
colorInt = Utility.readPrefInt(
context,
prefTokenColorInt[type]!!,
prefTokenColorIntDefault[type]!!
)
}

private fun initBuffer() {
Expand Down Expand Up @@ -81,74 +90,75 @@ class RadarGeomInfo(val context: Context, private val type: RadarGeometryTypeEnu

companion object {
val typeToCount = mapOf(
RadarGeometryTypeEnum.CaLines to 161792,
RadarGeometryTypeEnum.MxLines to 151552,
RadarGeometryTypeEnum.StateLines to 205748,
RadarGeometryTypeEnum.CountyLines to 212992,
RadarGeometryTypeEnum.HwLines to 862208,
RadarGeometryTypeEnum.HwExtLines to 770048,
RadarGeometryTypeEnum.LakeLines to 503808,
RadarGeometryTypeEnum.CaLines to 161792,
RadarGeometryTypeEnum.MxLines to 151552,
RadarGeometryTypeEnum.StateLines to 234828, // 2025_01_05 was 822992 bytes / 205748 floats
// now 939312 bytes / 234828 floats
RadarGeometryTypeEnum.CountyLines to 212992,
RadarGeometryTypeEnum.HwLines to 862208,
RadarGeometryTypeEnum.HwExtLines to 770048,
RadarGeometryTypeEnum.LakeLines to 503808,
)

val typeToFileName = mapOf(
RadarGeometryTypeEnum.CaLines to R.raw.ca,
RadarGeometryTypeEnum.MxLines to R.raw.mx,
RadarGeometryTypeEnum.StateLines to R.raw.statev2,
RadarGeometryTypeEnum.CountyLines to R.raw.county,
RadarGeometryTypeEnum.HwLines to R.raw.hwv4,
RadarGeometryTypeEnum.HwExtLines to R.raw.hwv4ext,
RadarGeometryTypeEnum.LakeLines to R.raw.lakesv3,
RadarGeometryTypeEnum.CaLines to R.raw.ca,
RadarGeometryTypeEnum.MxLines to R.raw.mx,
RadarGeometryTypeEnum.StateLines to R.raw.statev2,
RadarGeometryTypeEnum.CountyLines to R.raw.county,
RadarGeometryTypeEnum.HwLines to R.raw.hwv4,
RadarGeometryTypeEnum.HwExtLines to R.raw.hwv4ext,
RadarGeometryTypeEnum.LakeLines to R.raw.lakesv3,
)

val prefToken = mapOf(
RadarGeometryTypeEnum.CaLines to "RADAR_CAMX_BORDERS",
RadarGeometryTypeEnum.MxLines to "RADAR_CAMX_BORDERS",
RadarGeometryTypeEnum.StateLines to "RADAR_SHOW_STATELINES",
RadarGeometryTypeEnum.CountyLines to "RADAR_SHOW_COUNTY",
RadarGeometryTypeEnum.HwLines to "COD_HW_DEFAULT",
RadarGeometryTypeEnum.HwExtLines to "RADAR_HW_ENH_EXT",
RadarGeometryTypeEnum.LakeLines to "COD_LAKES_DEFAULT",
RadarGeometryTypeEnum.CaLines to "RADAR_CAMX_BORDERS",
RadarGeometryTypeEnum.MxLines to "RADAR_CAMX_BORDERS",
RadarGeometryTypeEnum.StateLines to "RADAR_SHOW_STATELINES",
RadarGeometryTypeEnum.CountyLines to "RADAR_SHOW_COUNTY",
RadarGeometryTypeEnum.HwLines to "COD_HW_DEFAULT",
RadarGeometryTypeEnum.HwExtLines to "RADAR_HW_ENH_EXT",
RadarGeometryTypeEnum.LakeLines to "COD_LAKES_DEFAULT",
)

val defaultPref = mapOf(
RadarGeometryTypeEnum.CaLines to "false",
RadarGeometryTypeEnum.MxLines to "false",
RadarGeometryTypeEnum.StateLines to "true",
RadarGeometryTypeEnum.CountyLines to "true",
RadarGeometryTypeEnum.HwLines to "true",
RadarGeometryTypeEnum.HwExtLines to "false",
RadarGeometryTypeEnum.LakeLines to "false",
RadarGeometryTypeEnum.CaLines to "false",
RadarGeometryTypeEnum.MxLines to "false",
RadarGeometryTypeEnum.StateLines to "true",
RadarGeometryTypeEnum.CountyLines to "true",
RadarGeometryTypeEnum.HwLines to "true",
RadarGeometryTypeEnum.HwExtLines to "false",
RadarGeometryTypeEnum.LakeLines to "false",
)

// TODO FIXME no separate config for CAMX
val prefTokenLineSize = mapOf(
RadarGeometryTypeEnum.CaLines to "RADAR_STATE_LINESIZE",
RadarGeometryTypeEnum.MxLines to "RADAR_STATE_LINESIZE",
RadarGeometryTypeEnum.StateLines to "RADAR_STATE_LINESIZE",
RadarGeometryTypeEnum.CountyLines to "RADAR_COUNTY_LINESIZE",
RadarGeometryTypeEnum.HwLines to "RADAR_HW_LINESIZE",
RadarGeometryTypeEnum.HwExtLines to "RADAR_HWEXT_LINESIZE",
RadarGeometryTypeEnum.LakeLines to "RADAR_LAKE_LINESIZE",
RadarGeometryTypeEnum.CaLines to "RADAR_STATE_LINESIZE",
RadarGeometryTypeEnum.MxLines to "RADAR_STATE_LINESIZE",
RadarGeometryTypeEnum.StateLines to "RADAR_STATE_LINESIZE",
RadarGeometryTypeEnum.CountyLines to "RADAR_COUNTY_LINESIZE",
RadarGeometryTypeEnum.HwLines to "RADAR_HW_LINESIZE",
RadarGeometryTypeEnum.HwExtLines to "RADAR_HWEXT_LINESIZE",
RadarGeometryTypeEnum.LakeLines to "RADAR_LAKE_LINESIZE",
)

val prefTokenColorInt = mapOf(
RadarGeometryTypeEnum.CaLines to "RADAR_COLOR_STATE",
RadarGeometryTypeEnum.MxLines to "RADAR_COLOR_STATE",
RadarGeometryTypeEnum.StateLines to "RADAR_COLOR_STATE",
RadarGeometryTypeEnum.CountyLines to "RADAR_COLOR_COUNTY",
RadarGeometryTypeEnum.HwLines to "RADAR_COLOR_HW",
RadarGeometryTypeEnum.HwExtLines to "RADAR_COLOR_HW_EXT",
RadarGeometryTypeEnum.LakeLines to "RADAR_COLOR_LAKES",
RadarGeometryTypeEnum.CaLines to "RADAR_COLOR_STATE",
RadarGeometryTypeEnum.MxLines to "RADAR_COLOR_STATE",
RadarGeometryTypeEnum.StateLines to "RADAR_COLOR_STATE",
RadarGeometryTypeEnum.CountyLines to "RADAR_COLOR_COUNTY",
RadarGeometryTypeEnum.HwLines to "RADAR_COLOR_HW",
RadarGeometryTypeEnum.HwExtLines to "RADAR_COLOR_HW_EXT",
RadarGeometryTypeEnum.LakeLines to "RADAR_COLOR_LAKES",
)

val prefTokenColorIntDefault = mapOf(
RadarGeometryTypeEnum.CaLines to Color.rgb(255, 255, 255),
RadarGeometryTypeEnum.MxLines to Color.rgb(255, 255, 255),
RadarGeometryTypeEnum.StateLines to Color.rgb(255, 255, 255),
RadarGeometryTypeEnum.CountyLines to Color.rgb(75, 75, 75),
RadarGeometryTypeEnum.HwLines to Color.rgb(135, 135, 135),
RadarGeometryTypeEnum.HwExtLines to Color.rgb(91, 91, 91),
RadarGeometryTypeEnum.LakeLines to Color.rgb(0, 0, 255),
RadarGeometryTypeEnum.CaLines to Color.rgb(255, 255, 255),
RadarGeometryTypeEnum.MxLines to Color.rgb(255, 255, 255),
RadarGeometryTypeEnum.StateLines to Color.rgb(255, 255, 255),
RadarGeometryTypeEnum.CountyLines to Color.rgb(75, 75, 75),
RadarGeometryTypeEnum.HwLines to Color.rgb(135, 135, 135),
RadarGeometryTypeEnum.HwExtLines to Color.rgb(91, 91, 91),
RadarGeometryTypeEnum.LakeLines to Color.rgb(0, 0, 255),
)
}
}
Loading

0 comments on commit b284981

Please sign in to comment.