Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
weather stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
fulton committed Nov 25, 2019
1 parent 3f4585e commit fd2fe05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
Binary file modified bin/jar/Ara-Server.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions src/main/java/com/andromeda/araserver/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private Run(int port) throws IOException {
parser = ParserFactory.create(model);
keyWord = new KeyWord(is);
System.out.println(" reeeeesut");
System.out.println(" " +new SortWords(keyWord, "where is a starbucks near me").getNNS(parser));


}
// Static function, to be run on start.
Expand All @@ -81,6 +81,7 @@ public static void main(String[] args) {
@Override
//If connected to
public NanoHTTPD.Response serve(NanoHTTPD.IHTTPSession session) {

//RSS feed type, if any
int tag;
//URI passed from client
Expand All @@ -95,7 +96,7 @@ public NanoHTTPD.Response serve(NanoHTTPD.IHTTPSession session) {
//Start the Hello function
else if (sessionUri.startsWith("/hi")) main2 = new Hello().hello();
else if (sessionUri.startsWith("/yelpclient")) main2 = new Locdec().main(sessionUri, keyWord, parser);
else if (sessionUri.startsWith("/weat")) main2 = new Weather().getWeatherNow(sessionUri);
else if (sessionUri.startsWith("/weath")) main2 = new Weather().getWeatherNow(sessionUri);
else if (sessionUri.startsWith("/search")) {
main2 = new GetInfo().main(sessionUri);
} else if (sessionUri.startsWith("/math")) main2 = new Equations().main(sessionUri);
Expand Down
21 changes: 9 additions & 12 deletions src/main/java/com/andromeda/araserver/skills/Weather.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,19 @@ class Weather {
when {
pair.startsWith("log") -> log = pair.replace("log=", "")
pair.startsWith("lat") -> lat = pair.replace("lat=", "")
else -> term = pair.replace("/yelpclient/", "")
else -> term = pair.replace("/weath/", "")
}
}
val urlGrid = URL("https://api.weather.gov/points/$lat,$log")
val urlGridData = urlGrid.readText()
var json = JsonParser().parse(urlGridData)
val links = URL(json.asJsonObject.getAsJsonObject("properties").get("forecast").asString)
val finalData = links.readText()
json = JsonParser().parse(finalData)
val dataSet = json.asJsonObject.getAsJsonObject("properties").getAsJsonArray("periods")
val temp = dataSet[0].asJsonObject.get("temperature").asInt.toString()
val foreCast = dataSet[0].asJsonObject.get("shortForecast").asString
val full = dataSet[0].asJsonObject.get("detailedForecast").asString
val urlGrid = URL("https://api.darksky.net/forecast/7b7fd158d8733db19ddac66bb71132b2/$lat,$log")
println(urlGrid.toString())
val finalData = urlGrid.readText()
val json = JsonParser().parse(finalData)
val dataSet = json.asJsonObject.getAsJsonObject("currently")
val temp = dataSet.asJsonObject.get("temperature").asInt.toString()
val foreCast = dataSet.asJsonObject.get("summary").asString
val title = "$temp and $foreCast"

val toReturn = OutputModel(title,full, "", "", full, "");
val toReturn = OutputModel(title,"", "", "", title, "");
return Gson().toJson(toReturn)


Expand Down

0 comments on commit fd2fe05

Please sign in to comment.