forecast

package
v0.0.0-...-d0d54b5 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	YilanCounty = iota
	TaoyuanCounty
	HsinchuCounty
	MiaoliCounty
	ChanghuaCounty
	NantouCounty
	YunlinCounty
	ChiayiCounty
	PingtungCounty
	TaitungCounty
	HualienCounty
	PenghuCounty
	KeelungCity
	HsinchuCity
	ChiayiCity
	TaipeiCity
	KaohsiungCity
	NewTapipeiCity
	TaichungCity
	TainanCity
	LienchiangCounty
	KinmenCounty
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Forecast

type Forecast struct {
	Description        string
	Language           string
	IssueTime          time.Time
	UpdateTime         time.Time
	ContentDescription string
	LocationName       string
}

func (*Forecast) UnmarshalXML

func (f *Forecast) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Location

type Location struct {
	Name      string  `xml:"locationName"`
	Geocode   string  `xml:"geocode"`
	Latitude  float32 `xml:"lat"`
	Longitude float32 `xml:"lon"`
}

type LocationForecast

type LocationForecast struct {
	Location
	WeatherElements []TimelineWeatherElement `xml:"weatherElement"`
}

type Measurement

type Measurement struct {
	Value string `xml:"value"`
	Unit  string `xml:"measures"`
}

type Parameter

type Parameter struct {
	Name  string `xml:"parameterName"`
	Value string `xml:"parameterValue"`
	Unit  string `xml:"parameterUnit"`
}

type Timed

type Timed struct {
	Start time.Time
	End   time.Time
	Data  []interface{}
}

func (*Timed) UnmarshalXML

func (t *Timed) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type TimelineWeatherElement

type TimelineWeatherElement struct {
	Name     string   `xml:"elementName"`
	Timeline []*Timed `xml:"time"`
}

type WeeklyForecast

type WeeklyForecast struct {
	Forecast
	Locations []LocationForecast
}

func GetWeeklyForecast

func GetWeeklyForecast(apiKey string, city int) (f *WeeklyForecast, err error)

func OpenDataToWeeklyForecast

func OpenDataToWeeklyForecast(opendata *cwbdata.CwbOpenData) (*WeeklyForecast, error)
Example
data := testutil.Load("weekly_forecast_sample.xml")
opendata, err := cwbdata.GetOpenDataByData(data)
if err != nil {
	log.Panic(err)
}
wf, err := OpenDataToWeeklyForecast(opendata)
if err != nil {
	log.Panic(err)
}
fmt.Println(wf.Description)
fmt.Println(wf.Language)
fmt.Println(wf.IssueTime.UTC())
fmt.Println(wf.UpdateTime.UTC())
Output:

宜蘭縣未來1週天氣預報
zh-TW
2018-01-13 09:00:00 +0000 UTC
2018-01-13 09:06:00 +0000 UTC

func (*WeeklyForecast) UnmarshalXML

func (wf *WeeklyForecast) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

Jump to

Keyboard shortcuts

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