@@ -164,7 +164,7 @@ object DownloadText {
164164 || prod == " UVICAC"
165165 || prod == " RWRMX"
166166 || prod.startsWith(" TPT" ) -> {
167- val product = prod.substring( 0 , 3 )
167+ val product = prod.take( 3 )
168168 val site = prod.substring(3 )
169169 val url =
170170 " https://forecast.weather.gov/product.php?site=NWS&issuedby=$site &product=$product &format=txt&version=1&glossary=0"
@@ -173,7 +173,7 @@ object DownloadText {
173173 }
174174
175175 prod.startsWith(" GLF" ) -> {
176- val product = prod.substring( 0 , 3 )
176+ val product = prod.take( 3 )
177177 val site = prod.substring(3 ).replace(" %" , " " )
178178 val url =
179179 " https://forecast.weather.gov/product.php?site=NWS&issuedby=$site &product=$product &format=txt&version=1&glossary=0"
@@ -264,7 +264,7 @@ object DownloadText {
264264 }
265265
266266 prod.startsWith(" RWR" ) -> {
267- val product = prod.substring( 0 , 3 )
267+ val product = prod.take( 3 )
268268 val location = prod.substring(3 ).replace(" %" , " " )
269269 val state = WfoSites .getState(location)
270270 val url =
@@ -275,7 +275,7 @@ object DownloadText {
275275 }
276276
277277 prod.startsWith(" NSH" ) || (prod.startsWith(" RTP" ) && prod.length == 6 ) -> {
278- val product = prod.substring( 0 , 3 )
278+ val product = prod.take( 3 )
279279 val location = prod.substring(3 ).replace(" %" , " " )
280280 val url =
281281 " https://forecast.weather.gov/product.php?site=$location &issuedby=$location &product=$product "
@@ -284,7 +284,7 @@ object DownloadText {
284284 }
285285
286286 prod.startsWith(" RTP" ) && prod.length == 5 -> {
287- val product = prod.substring( 0 , 3 )
287+ val product = prod.take( 3 )
288288 val location = prod.substring(3 , 5 ).replace(" %" , " " )
289289 val url =
290290 GlobalVariables .NWS_API_URL + " /products/types/$product /locations/$location "
@@ -312,7 +312,7 @@ object DownloadText {
312312 // Feb 8 2020 Sat
313313 // The NWS API for text products has been unstable Since Wed Feb 5
314314 // resorting to alternatives
315- val t1 = prod.substring( 0 , 3 )
315+ val t1 = prod.take( 3 )
316316 val t2 = prod.substring(3 ).replace(" %" , " " )
317317 if (USE_NWS_API ) {
318318 val url = GlobalVariables .NWS_API_URL + " /products/types/$t1 /locations/$t2 "
@@ -397,7 +397,7 @@ object DownloadText {
397397
398398 fun byProduct (prodF : String , version : Int ): String {
399399 val prod = prodF.uppercase(Locale .US )
400- val t1 = prod.substring( 0 , 3 )
400+ val t1 = prod.take( 3 )
401401 val t2 = prod.substring(3 )
402402 val url =
403403 " https://forecast.weather.gov/product.php?site=NWS&product=$t1 &issuedby=$t2 &version=$version "
0 commit comments