Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Example Use of WeatherConnector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SOFT Core
SOFT 160
Example Use of WeatherConnector
Commits
8851fcf7
Commit
8851fcf7
authored
3 years ago
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
added example code
parent
26f3ea9e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/edu/unl/cse/soft160/weatherexample/WeatherExample.java
+41
-0
41 additions, 0 deletions
...va/edu/unl/cse/soft160/weatherexample/WeatherExample.java
src/main/resources/weather/unl-oct24-0917.json
+59
-0
59 additions, 0 deletions
src/main/resources/weather/unl-oct24-0917.json
with
100 additions
and
0 deletions
src/main/java/edu/unl/cse/soft160/weatherexample/WeatherExample.java
0 → 100644
+
41
−
0
View file @
8851fcf7
package
edu.unl.cse.soft160.weatherexample
;
import
java.util.Date
;
import
edu.unl.cse.soft160.json_connections.connection.RestConnection
;
import
edu.unl.cse.soft160.json_connections.connector.OpenWeatherConnector
;
import
java.io.IOException
;
import
java.util.Calendar
;
public
class
WeatherExample
{
public
static
long
getEpochTime
(
int
year
,
int
month
,
int
day
,
int
hour
,
int
minute
,
int
second
)
{
Date
date
=
new
Calendar
.
Builder
()
.
setDate
(
year
,
month
,
day
)
.
setTimeOfDay
(
hour
,
minute
,
second
)
.
build
().
getTime
();
return
date
.
getTime
()
/
1000
;
}
public
static
void
main
(
String
...
args
)
{
String
apiKey
=
""
;
try
{
apiKey
=
RestConnection
.
getApiKey
(
"openweathermap"
);
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
// OpenWeatherConnector connector = new OpenWeatherConnector("weather", apiKey);
OpenWeatherConnector
connector
=
new
OpenWeatherConnector
(
"weather"
);
try
{
// connector.retrieveData("zip=68588");
connector
.
retrieveData
(
"unl-oct24-0917.json"
);
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
System
.
out
.
println
(
"It feels like: "
+
connector
.
getFeelsLike
());
System
.
out
.
println
(
"Date of report: "
+
connector
.
getTimestamp
());
System
.
out
.
println
(
"Epoch Time: "
+
getEpochTime
(
2021
,
Calendar
.
OCTOBER
,
24
,
9
,
17
,
33
));
}
}
This diff is collapsed.
Click to expand it.
src/main/resources/weather/unl-oct24-0917.json
0 → 100644
+
59
−
0
View file @
8851fcf7
{
"rain"
:
{
"1h"
:
0.11
},
"visibility"
:
8047
,
"timezone"
:
-18000
,
"main"
:
{
"temp"
:
281.25
,
"temp_min"
:
279.77
,
"humidity"
:
96
,
"pressure"
:
1003
,
"feels_like"
:
279.92
,
"temp_max"
:
282.33
},
"clouds"
:
{
"all"
:
90
},
"sys"
:
{
"country"
:
"US"
,
"sunrise"
:
1635079694
,
"sunset"
:
1635118400
,
"id"
:
2017531
,
"type"
:
2
},
"dt"
:
1635085053
,
"coord"
:
{
"lon"
:
-96.6928
,
"lat"
:
40.8206
},
"weather"
:
[
{
"icon"
:
"50d"
,
"description"
:
"mist"
,
"main"
:
"Mist"
,
"id"
:
701
},
{
"icon"
:
"10d"
,
"description"
:
"light rain"
,
"main"
:
"Rain"
,
"id"
:
500
},
{
"icon"
:
"11d"
,
"description"
:
"thunderstorm with light rain"
,
"main"
:
"Thunderstorm"
,
"id"
:
200
}
],
"name"
:
"Lincoln"
,
"cod"
:
200
,
"id"
:
0
,
"base"
:
"stations"
,
"wind"
:
{
"deg"
:
43
,
"speed"
:
2.24
,
"gust"
:
4.92
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment