⛈️ Go packages for accessing Meteologix/Kachelmann Wetter/WeatherUS data
Go to file
Winni Neessen d6ce76b1ad
All checks were successful
Codecov workflow / run (push) Successful in 1m39s
golangci-lint / lint (push) Successful in 48s
REUSE Compliance Check / test (push) Successful in 4s
SonarQube / Build (push) Successful in 1m40s
Remove sudo usage for jq installation in sonarqube.yml
The use of sudo keyword for installing 'jq' in the SonarQube workflow file, sonarqube.yml, has been removed. This change is due to the fact that the root permission is not necessary during the installation process, adhering better to the principle of least privilege.
2024-02-14 00:50:25 +01:00
.forgejo Remove sudo usage for jq installation in sonarqube.yml 2024-02-14 00:50:25 +01:00
.github Move Github workflows to Forgejo workflows 2024-02-13 22:21:35 +01: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 Update URLs to point to new repository domain 2024-02-11 15:24:46 +01:00
astroinfo.go Remove redundant package comment 2023-06-27 19:37:26 +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 Reformat ConditionMap for better readability 2023-06-27 16:12:22 +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 Remove unused and redundant weather fields 2023-06-27 16:12:38 +02:00
curweather_test.go Added SnowHeight and corrected comments 2023-06-26 12:21:36 +02:00
datatype.go Added SnowHeight and corrected comments 2023-06-26 12:21:36 +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 Update DateTime String method to use Value() 2023-06-27 16:12:59 +02:00
density.go Improve Density type documentation and comments 2023-06-27 16:13:13 +02:00
direction.go Fix typo and improve direction calculations 2023-06-27 16:49:22 +02:00
direction_test.go Add test for findDirection function 2023-06-27 16:48:29 +02:00
doc.go Update package version in doc.go 2023-06-27 19:26:02 +02:00
geolocation.go Handle error in GetGeoLocationByName 2023-06-27 17:15:07 +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 Update URLs to point to new repository domain 2024-02-11 15:24:46 +01:00
height.go Fix Height conversion and update DateTime comment 2023-06-27 17:18:15 +02:00
httpclient.go Add bearer token authentication 2023-08-02 16:08:38 +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 Refine method comments in humidity.go 2023-06-27 18:49:32 +02:00
LICENSE Initial commit 2023-05-12 10:14:31 +02:00
meteologix.go Update URLs to point to new repository domain 2024-02-11 15:24:46 +01:00
meteologix_test.go Add bearer token authentication 2023-08-02 16:08:38 +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 Refine Precipitation's DateTime method comment 2023-06-27 18:57:33 +02:00
pressure.go Refine DateTime function description in pressure.go 2023-06-27 18:59:13 +02:00
radiation.go Update comment for DateTime function in radiation.go 2023-06-27 19:01:37 +02:00
README.md Add mirror repository information to README 2024-02-11 15:27:34 +01: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 Refine comment for DateTime function in speed.go 2023-06-27 19:12:35 +02:00
station.go Update precision constants in station.go 2023-06-27 19:21:24 +02:00
station_test.go Improve error reporting in station_test.go 2023-06-27 18:31:41 +02:00
temperature.go Update DateTime comment for clarity 2023-06-27 19:25:19 +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"

	"src.neessen.cloud/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"

	"src.neessen.cloud/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"

	"src.neessen.cloud/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"

	"src.neessen.cloud/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):

Mirror

Please note that the repository on Github is just a mirror of https://src.neessen.cloud/wneessen/go-meteologix for ease of access and reachability.