⛈️ Go packages for accessing Meteologix/Kachelmann Wetter/WeatherUS data
Go to file
2023-06-23 12:36:17 +02:00
.github Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
assets Added logo by Maria Letta integrated it with README.md 2023-05-21 11:29:05 +02:00
LICENSES Initial checkin 2023-05-12 12:44:27 +02:00
.gitignore Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
.golangci.toml Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
astroinfo.go Added sunrise data 2023-05-30 14:29:31 +02:00
astroinfo_test.go Added tests for sunrise 2023-05-30 15:57:16 +02:00
CODE_OF_CONDUCT.md Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
codecov.yml Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
condition.go Completed condition 2023-06-07 10:10:37 +02:00
condition_test.go Fixed REUSE 2023-06-07 10:12:38 +02:00
CONTRIBUTING.md Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
curweather.go Added PressureQFE to current weather 2023-06-23 12:35:52 +02:00
curweather_test.go Added PressureQFE to current weather 2023-06-23 12:35:52 +02:00
datatype.go Added WindGust to current weather 2023-06-23 12:05:40 +02:00
datatype_test.go Added tests for astronomical data. Let's merge this for now as 0.0.7 2023-05-28 23:31:53 +02:00
datetime.go Added sunrise data 2023-05-30 14:29:31 +02:00
direction.go Added weather symbol to current weather 2023-05-24 22:00:47 +02:00
doc.go Bump version to v0.1.0 2023-06-23 12:36:17 +02:00
geolocation.go Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
geolocation_test.go Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
go.mod Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
httpclient.go Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
httpclient_test.go Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
humidity.go Added weather symbol to current weather 2023-05-24 22:00:47 +02:00
LICENSE Initial commit 2023-05-12 10:14:31 +02:00
meteologix.go Added weather symbol to current weather 2023-05-24 22:00:47 +02:00
meteologix_test.go Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
observation.go Added PressureQFE to current weather 2023-06-23 12:35:52 +02:00
observation_test.go Added WindGust to current weather 2023-06-23 12:05:40 +02:00
precipitation.go Added weather symbol to current weather 2023-05-24 22:00:47 +02:00
pressure.go Added weather symbol to current weather 2023-05-24 22:00:47 +02:00
radiation.go Added weather symbol to current weather 2023-05-24 22:00:47 +02:00
README.md Update Discord link 2023-05-23 18:50:40 +02:00
SECURITY.md Create SECURITY.md 2023-05-21 11:42:35 +02:00
sonar-project.properties Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
source.go Added REUSE header to source.go 2023-05-22 17:15:07 +02:00
source_test.go More testing and Dewpoint added to curweather.go 2023-05-23 20:35:00 +02:00
speed.go Switch from kn to m/s as default unit for Speed types 2023-06-23 11:52:36 +02:00
station.go Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
station_test.go Added CODE_OF_CONDUCT.md, CONTRIBUTING.md and updated mail address in CopyrightText 2023-05-21 11:46:23 +02:00
temperature.go Added weather symbol to current weather 2023-05-24 22:00:47 +02:00

go-meteologix - Go packages for accessing Meteologix/Kachelmann Wetter/WeatherUS data

GoDoc codecov Go Report Card #go-meteologix on Discord REUSE status buy ma a coffee

go-meteologx logo

This package is still WIP

This Go package provides simple bindings to the Meteologix/Kachelmann-Wetter API. It provides access to "Stations", "Current Weather" and "Forecast". An API key or username/password pair is required to access the endpoints. An API key can be configured in your account settings.

go-meteologix follows idiomatic Go style and best practice. It's only dependency is the Go Standard Library.

For Geolocation lookups, the package makes use of the OpenStreetMap Nominatim API. This requires no API key.

Usage

The library is fully documented using the execellent GoDoc functionality. Check out the full reference on pkg.go.dev for details.

Examples

GeoLocation lookup

This program uses the OSM Nominatim API to lookup the GeoLocation data for Berlin, Germany. On success it will return the Latitude and Longitude fields.

package main

import (
	"fmt"
	"os"

	"github.com/wneessen/go-meteologix"
)

func main() {
	c := meteologix.New()
	gl, err := c.GetGeoLocationByName("Berlin, Germany")
	if err != nil {
		fmt.Println("GeoLocation lookup failed", err)
		os.Exit(1)
	}
	fmt.Printf("GeoLocation - Latitude: %f, Longitude: %f\n", gl.Latitude,
		gl.Longitude)
}

Lookup stations at a specific geolocation

This program makes use of the GeoLocation support in the package. It looks up the GeoLocation of the location in question and queries the Kachelmann API for the station nearest to that location. The returned list of stations is sorted by distance to the provided GeoLocation. In our example we will return the first station in that list.

package main

import (
	"fmt"
	"os"

	"github.com/wneessen/go-meteologix"
)

func main() {
	c := meteologix.New(meteologix.WithAPIKey(os.Getenv("API_KEY")))
	sl, err := c.StationSearchByLocation("Berlin, Germany")
	if err != nil {
		fmt.Printf("station lookup failed: %s", err)
		os.Exit(1)
	}
	if len(sl) > 0 {
		fmt.Printf("Station no. 1: %+v", sl[0])
	}
}

Get latest station observation by station ID

This program takes a station ID and looks up the latest station observation data and returns the Observation type. This type then has lots of methods to access the observation data. In our example we will print out the formatted values for the current temperature and the dewpoint.

package main

import (
	"fmt"
	"math"
	"os"

	"github.com/wneessen/go-meteologix"
)

func main() {
	c := meteologix.New(meteologix.WithAPIKey(os.Getenv("API_KEY")))
	o, err := c.ObservationLatestByStationID("H744")
	if err != nil {
		fmt.Printf("station lookup failed: %s", err)
		os.Exit(1)
	}
	fmt.Printf("Temperature at station: %s\n", o.Temperature())
	if !math.IsNaN(o.Temperature().Value()) {
		fmt.Printf("Temperature at station in F: %s\n", o.Temperature().FahrenheitString())
    }
	if o.Dewpoint().IsAvailable() {
		fmt.Printf("Dewpoint in Fahrenheit: %s\n", o.Dewpoint().FahrenheitString())
	}
}

Get latest station observation by location

This program takes a location string, searches for the weather station with the shortest distancen and looks up the station's latest observation data. We then print out the temperature in C and F, as well as the station name and the time of the measurement (if the data point is available from that station).

package main

import (
	"fmt"
	"os"

	"github.com/wneessen/go-meteologix"
)

func main() {
	c := meteologix.New(meteologix.WithAPIKey(os.Getenv("API_KEY")))
	o, s, err := c.ObservationLatestByLocation("Ehrenfeld, Germany")
	if err != nil {
		fmt.Printf("Failed: %s\n", err)
		os.Exit(1)
	}
	if o.Temperature().IsAvailable() {
		fmt.Printf("Temperature at %s: %s/%s (time of measurement: %s)\n",
			s.Name, o.Temperature(), o.Temperature().FahrenheitString(),
			o.Temperature().DateTime().Local().Format("15:04h"))
	}
}

Authors/Contributors

go-meteologix was authored and developed by Winni Neessen.

Big thanks to the following people, for contributing to the go-meteologix project (either in form of code, reviewing code, writing documenation or contributing in any other form):