Skip to content

Commit

Permalink
55934-elys
Browse files Browse the repository at this point in the history
  • Loading branch information
ELY M committed Jan 19, 2025
1 parent dfb6ec2 commit ba51314
Show file tree
Hide file tree
Showing 33 changed files with 3,398 additions and 5,159 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.15.0'
implementation 'androidx.media:media:1.7.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.recyclerview:recyclerview:1.4.0'
// graphview source code was merged locally into project on 2023-12-30
// implementation 'com.jjoe64:graphview:4.2.2'

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="55932"
android:versionName="55932-elys">
android:versionCode="55934"
android:versionName="55934-elys">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/joshuatee/wx/MyApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import java.util.concurrent.TimeUnit
import joshuatee.wx.audio.UtilityTts
import joshuatee.wx.objects.PolygonWatch
import joshuatee.wx.objects.PolygonType
import joshuatee.wx.radar.Metar
import joshuatee.wx.radar.RadarGeometry
import joshuatee.wx.radar.NexradUtil
import joshuatee.wx.radarcolorpalettes.ColorPalettes
Expand Down Expand Up @@ -124,6 +125,7 @@ class MyApplication : Application() {
TypedValue.complexToDimensionPixelSize(tv.data, res.displayMetrics)
}
initPreferences(this)
Metar.initialize(this)
Location.refreshLocationData(this)
UtilityTts.loadTts(applicationContext)
loadGeomAndColorBuffers(this)
Expand Down Expand Up @@ -200,6 +202,6 @@ class MyApplication : Application() {
}

private fun getInitialPreferenceString(pref: String, initValue: String): String =
preferences.getString(pref, initValue) ?: initValue
preferences.getString(pref, initValue) ?: initValue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ class LocationFragment : Fragment() {
}

private fun getCc() {
currentConditions = CurrentConditions(MyApplication.appContext, Location.currentLocation)
currentConditions = CurrentConditions(Location.currentLocation)
currentConditions.timeCheck(MyApplication.appContext)
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/joshuatee/wx/misc/ForecastActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class ForecastActivity : BaseActivity() {
}

private fun downloadCc() {
currentConditions = CurrentConditions(this, latLon)
currentConditions = CurrentConditions(latLon)
currentConditions.timeCheck(this)
}

Expand Down
17 changes: 7 additions & 10 deletions app/src/main/java/joshuatee/wx/misc/NwsObsSitesActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import android.view.MenuItem
import java.util.Locale
import joshuatee.wx.R
import joshuatee.wx.ui.BaseActivity
import joshuatee.wx.util.UtilityIO
import joshuatee.wx.common.GlobalArrays
import joshuatee.wx.objects.Route
import joshuatee.wx.radar.Metar
Expand Down Expand Up @@ -60,7 +59,7 @@ class NwsObsSitesActivity : BaseActivity() {
menu.findItem(R.id.action_lastused).title = "Last Used: " + Utility.readPref(
this,
prefToken,
Metar.findClosestObservation(this, Location.latLon).codeName
Metar.findClosestObservation(Location.latLon).codeName
)
return super.onPrepareOptionsMenu(menu)
}
Expand Down Expand Up @@ -111,21 +110,19 @@ class NwsObsSitesActivity : BaseActivity() {
}

private fun getContent() {
val text = UtilityIO.readTextFileFromRaw(resources, R.raw.stations_us4)
val lines = text.split("\n")
val listCity = mutableListOf<String>()
listOf(listIds).forEach {
it.clear()
}
listCity.add("..Back to state list")
listIds.add("..Back to state list")
val listSort =
lines.filter { it.startsWith(stateSelected.uppercase(Locale.US)) }.toMutableList()
listSort.sort()
Metar.sites.sites.filter { it.fullName.startsWith(stateSelected.uppercase(Locale.US)) }
.toMutableList()
listSort.sortBy { it.fullName }
listSort.forEach {
val items = it.split(",")
listCity.add(items[2] + ": " + items[1])
listIds.add(items[2])
listCity.add(it.codeAndName)
listIds.add(it.codeName)
}
objectRecyclerView.refreshList(listCity)
siteDisplay = true
Expand All @@ -137,7 +134,7 @@ class NwsObsSitesActivity : BaseActivity() {
Utility.readPref(
this,
prefToken,
Metar.findClosestObservation(this, Location.latLon).codeName
Metar.findClosestObservation(Location.latLon).codeName
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ object NotificationLocal {
if (Location.locations[locationIndex].ccNotification) {
val locLabel = " current conditions"
val label = "(" + Location.getName(locationIndex) + ")" + locLabel
val currentConditions = CurrentConditions(context, locationIndex)
val currentConditions = CurrentConditions(locationIndex)
currentConditions.timeCheck(context)
val text = currentConditions.data + GlobalVariables.newline + currentConditions.status
val notifier =
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/joshuatee/wx/objects/PolygonType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ enum class PolygonType(
RadarPreferences.swo,
RadarPreferences.swoLineSize.toFloat()
),
FIRE(
RadarPreferences.colorHi,
"FIRE",
RadarPreferences.fire,
RadarPreferences.swoLineSize.toFloat()
),
WPC_FRONTS(
RadarPreferences.colorHi,
"WPC_FRONTS",
Expand Down Expand Up @@ -149,9 +155,10 @@ enum class PolygonType(
STI.pref = RadarPreferences.sti
TVS.pref = RadarPreferences.tvs
HI.pref = RadarPreferences.hailIndex
HAIL_LABELS.pref = RadarPreferences.hailSizeLabel
HAIL_LABELS.pref = RadarPreferences.hailSizeLabel
OBS.pref = RadarPreferences.obs
SWO.pref = RadarPreferences.swo
FIRE.pref = RadarPreferences.fire
USERPOINTS.pref = RadarPreferences.userPoints
MCD.color = RadarPreferences.colorMcd
MPD.color = RadarPreferences.colorMpd
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/joshuatee/wx/objects/Sites.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ class Sites(
return sites[0].codeName
}

fun getNearestSite(latLon: LatLon, order: Int = 0): Site {
for (site in sites) {
site.distance = LatLon.distance(latLon, site.latLon).toInt()
}
sites.sortBy { it.distance }
return sites[order]
}

// FIXME TODO
// fun getNearestList(latLon: LatLon, count: Int = 5): List<String> {
// for (site in sites) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/joshuatee/wx/radar/CanvasMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ object CanvasMain {
)
}
if (PolygonType.WIND_BARB.pref && windBarbProvider) {
CanvasWindbarbs.draw(context, projectionType, bitmapCanvas, radarSite, true, 5)
CanvasWindbarbs.draw(context, projectionType, bitmapCanvas, radarSite, false, 5)
CanvasWindbarbs.draw(projectionType, bitmapCanvas, radarSite, true, 5)
CanvasWindbarbs.draw(projectionType, bitmapCanvas, radarSite, false, 5)
}
if (PolygonType.STI.pref && stormMotionProvider) {
try {
Expand Down
67 changes: 53 additions & 14 deletions app/src/main/java/joshuatee/wx/radar/CanvasWindbarbs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

package joshuatee.wx.radar

import android.content.Context
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Color
Expand All @@ -37,9 +36,15 @@ import joshuatee.wx.util.To

object CanvasWindbarbs {

fun draw(context: Context, projectionType: ProjectionType, bitmap: Bitmap, radarSite: String, isGust: Boolean, index: Int) {
fun draw(
projectionType: ProjectionType,
bitmap: Bitmap,
radarSite: String,
isGust: Boolean,
index: Int
) {
val paintTextSize = 22
Metar.get(context, radarSite, index)
Metar.get(radarSite, index)
val wbCircleXArr = Metar.data[index].x
val wbCircleYArr = Metar.data[index].y
val canvas = Canvas(bitmap)
Expand Down Expand Up @@ -79,12 +84,28 @@ object CanvasWindbarbs {
val degree2 = angle.toDouble()
val startLength = 0.0
var start = ExternalGlobalCoordinates(locXDbl, locYDbl)
var ec = ExternalGeodeticCalculator.calculateEndingGlobalCoordinates(start, 0.0, startLength)
stormList += Projection.computeMercatorNumbers(ec.latitude, ec.longitude * -1, projectionNumbers).toList()
var ec = ExternalGeodeticCalculator.calculateEndingGlobalCoordinates(
start,
0.0,
startLength
)
stormList += Projection.computeMercatorNumbers(
ec.latitude,
ec.longitude * -1,
projectionNumbers
).toList()
start = ExternalGlobalCoordinates(ec.latitude, ec.longitude)
ec = ExternalGeodeticCalculator.calculateEndingGlobalCoordinates(start, degree2 + degreeShift, barbLength * nmScaleFactor * barbLengthScaleFactor)
ec = ExternalGeodeticCalculator.calculateEndingGlobalCoordinates(
start,
degree2 + degreeShift,
barbLength * nmScaleFactor * barbLengthScaleFactor
)
val end = ExternalGlobalCoordinates(ec.latitude, ec.longitude)
stormList += Projection.computeMercatorNumbers(ec.latitude, ec.longitude * -1, projectionNumbers).toList()
stormList += Projection.computeMercatorNumbers(
ec.latitude,
ec.longitude * -1,
projectionNumbers
).toList()
val barbCount = length / 10
var halfBarb = false
var oneHalfBarb = false
Expand All @@ -95,17 +116,31 @@ object CanvasWindbarbs {
oneHalfBarb = true
}
(0 until barbCount).forEach { j ->
ec = ExternalGeodeticCalculator.calculateEndingGlobalCoordinates(end, degree2, barbOffset + startLength + j.toDouble() * arrowSpacing * nmScaleFactor * barbLengthScaleFactor)
stormList += NexradLevel3Common.drawLine(ec, projectionNumbers, degree2 - arrowBend * 2.0, startLength + arrowLength * nmScaleFactor)
ec = ExternalGeodeticCalculator.calculateEndingGlobalCoordinates(
end,
degree2,
barbOffset + startLength + j.toDouble() * arrowSpacing * nmScaleFactor * barbLengthScaleFactor
)
stormList += NexradLevel3Common.drawLine(
ec,
projectionNumbers,
degree2 - arrowBend * 2.0,
startLength + arrowLength * nmScaleFactor
)
}
val halfBarbOffsetFudge = if (oneHalfBarb) nmScaleFactor * 1.0 else 0.0
if (halfBarb) {
ec = ExternalGeodeticCalculator.calculateEndingGlobalCoordinates(
end,
degree2,
barbOffset + halfBarbOffsetFudge + startLength + (barbCount - 1).toDouble() * arrowSpacing * nmScaleFactor * barbLengthScaleFactor
end,
degree2,
barbOffset + halfBarbOffsetFudge + startLength + (barbCount - 1).toDouble() * arrowSpacing * nmScaleFactor * barbLengthScaleFactor
)
stormList += NexradLevel3Common.drawLine(
ec,
projectionNumbers,
degree2 - arrowBend * 2.0,
startLength + arrowLength / 2.0 * nmScaleFactor
)
stormList += NexradLevel3Common.drawLine(ec, projectionNumbers, degree2 - arrowBend * 2.0, startLength + arrowLength / 2.0 * nmScaleFactor)
}
} // if length greater then 4
} // loop over wind barbs
Expand All @@ -118,7 +153,11 @@ object CanvasWindbarbs {
wbCircleXArr.indices.forEach { k ->
if (Metar.data[index].obsArrAviationColor.size > k) {
paint.color = Metar.data[index].obsArrAviationColor[k]
val list = Projection.computeMercatorNumbers(wbCircleXArr[k].toFloat(), wbCircleYArr[k].toFloat(), projectionNumbers)
val list = Projection.computeMercatorNumbers(
wbCircleXArr[k].toFloat(),
wbCircleYArr[k].toFloat(),
projectionNumbers
)
val pixXInit = list[0]
val pixYInit = list[1]
canvas.drawCircle(pixXInit, pixYInit, 5.0f, paint)
Expand Down
Loading

0 comments on commit ba51314

Please sign in to comment.