OWMW is an acronym for Open Weather Map Wrapper. With OWMW you can easily gather data about the weather in the area. All you need is a (free) token from OWM.
To install OWMW, you can use VPM.
$ vpm init
$ vpm get https://github.com/Bowero/owmw owmw
module main
import owmw
const (
Token = 'TOKEN'
)
fn main() {
w := owmw.init(Token, 1)
city := w.city_by_name('Rotterdam')
println(city.temperature())
}
$ v run test.v
30.129999
As you see, it is hot nowadays.
To start, you will have to initialize the wrapper with your token:
w := owmw.init(Token, metric)
If you prefer the imperial system, you pass 0
to metric
. For metric systems you pass 1
.
After initializing, you can store a city:
city := owmw.city_by_name('Rotterdam')
city := owmw.city_by_id(2747891)
A least with the IDs can be found on the website of Open Weather Map.
After selecting a city, you can gather data from it.
I am still developing this wrapper, but I wanted to share this before version 1. Be aware that this is an alpha stage and that many things are still missing.
-
Coordinates
.longitude()
: The longitude of the city asf32
.latitude()
: The latitude of the city asf32
-
Weather (An overview of these values can be found here)
.condition_id()
: The condition ID of the weather asint
.description()
: The description of the weather asstring
, can also be determined from the.condition_id()
.description_long()
: The detailed description of the weather asstring
, can also be determined from the.condition_id()
.icon()
: The icon of the weather asstring
, can also be determined from the.condition_id()
-
Main
.temperature()
: The current temperature asf32
.pressure()
: The air pressure asint
.humidity()
: The humidity percentage asint
.min_temperature()
: The minimum temperature asf32
.max_temperature()
: The maximum temperature asf32
-
Wind
.wind_speed()
: The wind speed asf32
.wind_degrees()
: The wind direction in meteorical degrees asint
-
City
.city_id()
: The ID of the city asint
.city_name()
: The name of the city asstring
.country()
: The name of the country of the city asstring
.sunrise()
: The UNIX timestamp of the sunrise asint
.sunset()
: The UNIX timestamp of the sunset asint
-
Miscellaneous
.visible_meters()
: The visibility in meters asint
.cloudiness()
: The cloudiness as percentage asint
.data_calculation()
: The UNIX timestamp at which the data has been calculated asint