Skip to content

Commit

Permalink
the gps location is location.png image now
Browse files Browse the repository at this point in the history
  • Loading branch information
ELY3M committed Nov 13, 2018
1 parent ba43e55 commit a48a5b6
Show file tree
Hide file tree
Showing 12 changed files with 554 additions and 274 deletions.
9 changes: 2 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="joshuatee.wx"
android:versionCode="55039"
android:versionName="55039"
android:versionCode="55040"
android:versionName="55040"
>

<uses-permission android:name="android.permission.INTERNET" />
Expand Down Expand Up @@ -392,11 +392,6 @@
android:parentActivityName="WX" >
</activity>

<activity
android:name=".radar.Website"
android:parentActivityName="WX" >
</activity>

<receiver android:name="joshuatee.wx.Widget" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/java/joshuatee/wx/models/ModelsNSSLWRFActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ class ModelsNSSLWRFActivity : VideoRecordActivity(), OnClickListener, OnMenuItem
})
spRun = ObjectSpinner(this, this, R.id.spinner_run)
spRun.setOnItemSelectedListener(this)
spSector = ObjectSpinner(this, this, R.id.spinner_sector, UtilityModelNSSLWRFInterface.SECTORS)
spSector = ObjectSpinner(this, this, R.id.spinner_sector, UtilityModelNSSLWRFInterface.sectorsLong)
spSector.setOnItemSelectedListener(this)
spSector.setSelection(Utility.readPref(this, prefSector, UtilityModelNSSLWRFInterface.SECTORS[0]))
drw = ObjectNavDrawer(this, UtilityModelNSSLWRFInterface.LABELS, UtilityModelNSSLWRFInterface.PARAMS)
spSector.setSelection(Utility.readPref(this, prefSector, UtilityModelNSSLWRFInterface.sectorsLong[0]))
drw = ObjectNavDrawer(this, UtilityModelNSSLWRFInterface.labelsNsslWrf, UtilityModelNSSLWRFInterface.paramsNsslWrf)
drw.listView.onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ ->
drw.listView.setItemChecked(position, false)
drw.drawerLayout.closeDrawer(drw.listView)
Expand Down Expand Up @@ -180,14 +180,14 @@ class ModelsNSSLWRFActivity : VideoRecordActivity(), OnClickListener, OnMenuItem
override fun onPreExecute() {
run = spRun.selectedItem.toString()
time = spTime.selectedItem.toString()
if (prefModel == "NCAR_ENSEMBLE") {
//if (prefModel == "NCAR_ENSEMBLE") {
sector = spSector.selectedItem.toString()
}
//}
Utility.writePref(contextg, prefSector, sector)
}

override fun doInBackground(vararg params: String): String {
(0 until numPanes).forEach { displayData.bitmap[it] = UtilityModelNSSLWRFInputOutput.getImage(sector, displayData.param[it], run, time) }
(0 until numPanes).forEach { displayData.bitmap[it] = UtilityModelNSSLWRFInputOutput.getImage(contextg, sector, displayData.param[it], run, time) }
return "Executed"
}

Expand Down Expand Up @@ -297,18 +297,18 @@ class ModelsNSSLWRFActivity : VideoRecordActivity(), OnClickListener, OnMenuItem

private fun setupModel() {
(0 until numPanes).forEach {
displayData.param[it] = UtilityModelNSSLWRFInterface.PARAMS[0]
displayData.param[it] = UtilityModelNSSLWRFInterface.paramsNsslWrf[0]
displayData.param[it] = Utility.readPref(this, prefParam + it.toString(), displayData.param[it])
displayData.paramLabel[it] = UtilityModelNSSLWRFInterface.LABELS[0]
displayData.paramLabel[it] = UtilityModelNSSLWRFInterface.labelsNsslWrf[0]
displayData.paramLabel[it] = Utility.readPref(this, prefParamLabel + it.toString(), displayData.paramLabel[it])

}
if (!UtilityModels.parmInArray(UtilityModelNSSLWRFInterface.PARAMS, displayData.param[0])) {
if (!UtilityModels.parmInArray(UtilityModelNSSLWRFInterface.paramsNsslWrf, displayData.param[0])) {
displayData.param[0] = "speed500_mean"
displayData.paramLabel[0] = "500 mb Wind/Height"
}
if (numPanes > 1)
if (!UtilityModels.parmInArray(UtilityModelNSSLWRFInterface.PARAMS, displayData.param[1])) {
if (!UtilityModels.parmInArray(UtilityModelNSSLWRFInterface.paramsNsslWrf, displayData.param[1])) {
displayData.param[1] = "speed500_mean"
displayData.paramLabel[1] = "500 mb Wind/Height"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,38 @@ package joshuatee.wx.models

import android.content.Context
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.AnimationDrawable

import joshuatee.wx.external.UtilityStringExternal
import joshuatee.wx.util.UtilityImgAnim
import joshuatee.wx.util.UtilityTime
import joshuatee.wx.util.UtilityImg

import joshuatee.wx.Extensions.*
import joshuatee.wx.RegExp

internal object UtilityModelNSSLWRFInputOutput {

val baseUrl = "https://cams.nssl.noaa.gov"

val runTime: RunTimeData
get() {
val runTimeData = RunTimeData()

val runData = RunTimeData()
val htmlRunstatus = (baseUrl).getHtml()
val html = htmlRunstatus.parse("\\{model: \"fv3_nssl\",(rd: .[0-9]{8}\",rt: .[0-9]{4}\",)")
val day = html.parse("rd:.(.*?),.*?").replace("\"", "")
val time = html.parse("rt:.(.*?)00.,.*?").replace("\"", "")
val mostRecentRun = day + time
runData.listRunAdd(mostRecentRun)
runData.listRunAddAll(UtilityTime.genModelRuns(mostRecentRun, 12, "yyyyMMddHH"))
runData.mostRecentRun = mostRecentRun
return runData

// FIXME standardize on listRunAdd,listRunAddAll or appendListRun

/*val runTimeData = RunTimeData()
val htmlRunstatus = "http://wrf.nssl.noaa.gov/newsite/".getHtml()
val currentRun = htmlRunstatus.parse("<p class=\"selected\"><a href=\"index.php.date=([0-9]{8}).amp")
runTimeData.listRunClear()
Expand All @@ -45,11 +63,44 @@ internal object UtilityModelNSSLWRFInputOutput {
if (currentRun != "") {
runTimeData.timeStrConv = currentRun.parse(RegExp.ncarEnsPattern2)
}
return runTimeData
return runTimeData*/
}

fun getImage(context: Context, sectorF: String, param: String, runF: String, timeF: String): Bitmap {

// FIXME
val modelF = "WRF"
val time = timeF.split(" ")[0]
var sectorIndex = 0
if (sectorF==""){
sectorIndex = 0
} else {
sectorIndex = UtilityModelNSSLWRFInterface.sectorsLong.indexOf(sectorF)
}
val sector = UtilityModelNSSLWRFInterface.sectors[sectorIndex]
val baseLayerUrl = "https://cams.nssl.noaa.gov/graphics/blank_maps/spc_" + sector + ".png"
var modelPostfix = "_nssl"
//var model = om.model.lowercased()
var model = modelF.toLowerCase()
if (modelF=="HRRRV3") {
modelPostfix = ""
}
if (modelF == "WRF_3KM") {
model = "wrf_nssl_3km"
modelPostfix = ""
}
val year = runF.substring(0, 4)
val month = runF.substring(4, 6)
val day = runF.substring(6, 8)
val hour = runF.substring(8, 10)
val url = baseUrl + "/graphics/models/" + model + modelPostfix + "/" + year + "/" + month + "/" +
day + "/" + hour + "00/f0" + time + "00/" + param + ".spc_" + sector.toLowerCase() + ".f0" + time + "00.png"
val baseLayer = baseLayerUrl.getImage()
val prodLayer = url.getImage()
val consolidatedImage = UtilityImg.addColorBG(context, UtilityImg.mergeImages(context, prodLayer, baseLayer), Color.WHITE)
return consolidatedImage

fun getImage(sectorF: String, param: String, runF: String, time: String): Bitmap {
var sector = sectorF
/*var sector = sectorF
var run = runF
val timeLocal = UtilityStringExternal.truncate(time, 2)
var runLast2 = ""
Expand All @@ -64,12 +115,12 @@ internal object UtilityModelNSSLWRFInputOutput {
runLast2 = ""
}
val url = "http://wrf.nssl.noaa.gov/$run/$runLast2$sector/$param$timeLocal.png"
return url.getImage()
return url.getImage()*/
}

fun getAnimation(context: Context, sector: String, param: String, run: String, spinnerTimeValue: Int, listTime: List<String>): AnimationDrawable {
if (spinnerTimeValue == -1) return AnimationDrawable()
val bmAl = (spinnerTimeValue until listTime.size).mapTo(mutableListOf()) { k -> getImage(sector, param, run, listTime[k].split(" ").dropLastWhile { it.isEmpty() }[0]) }
val bmAl = (spinnerTimeValue until listTime.size).mapTo(mutableListOf()) { k -> getImage(context, sector, param, run, listTime[k].split(" ").dropLastWhile { it.isEmpty() }[0]) }
return UtilityImgAnim.getAnimationDrawableFromBMList(context, bmAl)
}
}
Loading

0 comments on commit a48a5b6

Please sign in to comment.