luftkvalitet

package module
v0.0.0-...-fd1eb43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2017 License: MIT Imports: 8 Imported by: 1

README

Luftkvalitet

Go package to get air quality data from api.nilu.no. It supports retrieval of: up to date data (latest measurements); historical data; available areas, components, stations and aqis; and air quality forecasts.

Example

For more examples have a look at gonum-plot-example, polluteman or in example/.

Get current air quality measurements from Tromsø:

package main

import (
	"fmt"

	"github.com/fjukstad/luftkvalitet"
)

func main() {

	areas := []string{"Tromsø"}

	m, err := luftkvalitet.GetMeasurements(luftkvalitet.Filter{Areas: areas})
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(m)
}

produces (on 4.12.2016 19:44 EST):

[{{{Troms og Finnmark Tromsø Tromsø} {69.67957 18.95402} Tverrforbindelsen} NO0085A PM10 2016-12-05 00:00:00 +0100 +0100 2016-12-05 01:00:00 +0100 +0100 10.34 µg/m³ 1 6ee86e} {{{Troms og Finnmark Tromsø Tromsø} {69.65625 18.96372} Hansjordnesbukta} NO0079A PM10 2016-12-05 00:00:00 +0100 +0100 2016-12-05 01:00:00 +0100 +0100 11.44 µg/m³ 1 6ee86e} {{{Troms og Finnmark Tromsø Tromsø} {69.65625 18.96372} Hansjordnesbukta} NO0079A PM2.5 2016-12-05 00:00:00 +0100 +0100 2016-12-05 01:00:00 +0100 +0100 5.1 µg/m³ 1 6ee86e} {{{Troms og Finnmark Tromsø Tromsø} {69.65625 18.96372} Hansjordnesbukta} NO0079A NO2 2016-12-05 00:00:00 +0100 +0100 2016-12-05 01:00:00 +0100 +0100 -0.0864654577 µg/m³ 1 6ee86e}]

you get the idea?

Acknowledgements

The data belongs to The Norwegian Institute for Air Research (NILU), see luftkvalitet.info and nilu.no for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetComponents

func GetComponents() ([]string, error)

Types

type Aqi

type Aqi struct {
	Index            int     `json:"index"`
	FromValue        float64 `json:"fromValue"`
	ToValue          float64 `json:"toValue"`
	Color            string  `json:"color"`
	Text             string  `json:"text"`
	ShortDescription string  `json:"shortDescription"`
	Description      string  `json:"description"`
}

type AqiResult

type AqiResult struct {
	Component string `json:"component"`
	Unit      string `json:"unit"`
	Aqis      []Aqi  `json:"aqis"`
}

func GetAqis

func GetAqis() ([]AqiResult, error)

type Area

type Area struct {
	Zone         string `json:"zone"`
	Municipality string `json:"municipality"`
	Area         string `json:"area"`
}

func GetAreas

func GetAreas() ([]Area, error)

type Filter

type Filter struct {
	Areas      []string
	Stations   []string
	Components []string
	Within     Point
	Nearest    Point
	FromTime   time.Time
	ToTime     time.Time
}

type Forecast

type Forecast struct {
	Index        int    `json:"index"`
	Description  string `json:"description"`
	ForecastDate string `json:"forecastDate"`
	TimeOfDay    int    `json:"timeOfDay"`
}

type HistoricalResult

type HistoricalResult struct {
	Area
	Station
	Eoi       string `json:"eoi"`
	Component string `json:"component"`
	Location
	Measurements []Measurement `json:"values"`
}

func GetHistorical

func GetHistorical(f Filter) ([]HistoricalResult, error)

type Location

type Location struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

type Measurement

type Measurement struct {
	Station
	Eoi       string    `json:"eoi"`
	Component string    `json:"component"`
	FromTime  time.Time `json:"fromTime"`
	ToTime    time.Time `json:"toTime"`
	Value     float64   `json:"value"`
	Unit      string    `json:"unit"`
	Index     int       `json:"index"`
	Color     string    `json:"color"`
}

func GetMeasurements

func GetMeasurements(f Filter) ([]Measurement, error)

type Point

type Point struct {
	Location
	Radius float64
}

type Result

type Result struct {
	Area
	Today    []Forecast `json:"today"`
	Tomorrow []Forecast `json:"tomorrow"`
}

func GetForecasts

func GetForecasts(f Filter) ([]Result, error)

type Station

type Station struct {
	Area
	Location
	Station string `json:"station"`
}

func GetStations

func GetStations() ([]Station, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL