Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

13
LINES

< > BotCompany Repo | #1018188 // openWeatherMap_maxTempForecast (Celsius)

JavaX fragment (include)

static Map<S, Int> openWeatherMap_maxTempForecast(S cityName) {
  S url = "http://api.openweathermap.org/data/2.5/forecast";
  S xml = loadPageWithParams(url, APPID := openWeatherMapAPIKey(), q := cityName, mode := "xml");
  new TreeMap<S, Int> maxPerDay;
  for (L<S> tTime : findContainerOrEmptyTag(xml, "time")) {
    S from = tagParam(tTime, "from");
    S day = takeFirst(from, lastIndexOf(from, "T"));
    L<S> tTemperature = first(findContainerOrEmptyTag(tTime, "temperature"));
    int maxTemp = iround(kelvinToCelsius(parseDouble(tagParam(tTemperature, "max"))));
    maxPerDay.put(day, max(maxTemp, toInt(maxPerDay.get(day))));
  }
  ret maxPerDay;
}

Author comment

Began life as a copy of #1013973

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018188
Snippet name: openWeatherMap_maxTempForecast (Celsius)
Eternal ID of this version: #1018188/1
Text MD5: 06177d5cc12f06cacf5da408acc9c045
Author: stefan
Category: javax / networking
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-08 11:19:28
Source code size: 671 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 344 / 375
Referenced in: [show references]