bom

package
v0.0.0-...-143550a Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

WIP: Tried using goquery / html parser. Doesn't seem to be working; probably go back to encoding/xml and structs.

Index

Constants

This section is empty.

Variables

View Source
var Sample = []Forecast{
	Forecast{
		Date:            "3 Jan",
		Description:     "Hot and sunny",
		ChanceOfRain:    "10%",
		PreciseForecast: nil,
	},
	Forecast{
		Date:               "4 Jan",
		Description:        "Cold and rainy",
		PrecipitationRange: "1-2mm",
		PreciseForecast: &PreciseForecast{
			MaxTemperature: 36,
			MinTemperature: 12,
		},
	},
}
View Source
var WeatherUrl, _ = url.Parse("ftp://ftp2.bom.gov.au/anon/gen/fwo/IDV10450.xml")

Functions

This section is empty.

Types

type BomXmlExtractor

type BomXmlExtractor struct {
	Version  string           `xml:"version,attr"`
	Forecast []BomXmlForecast `xml:"forecast>area"`
}

type BomXmlForecast

type BomXmlForecast struct {
	// Content string `xml:",chardata"`
	Aac            string `xml:"aac,attr"`
	ForecastPeriod []struct {
		Index          int         `xml:"index,attr"`
		StartTimeLocal time.Time   `xml:"start-time-local,attr"`
		EndTimeLocal   time.Time   `xml:"end-time-local,attr"`
		Elements       BomXmlTexts `xml:"element"`
		Text           BomXmlTexts `xml:"text"`
	} `xml:"forecast-period"`
}

type BomXmlText

type BomXmlText struct {
	Content string `xml:",chardata"`
	Type    string `xml:"type,attr"`
}

type BomXmlTexts

type BomXmlTexts []BomXmlText

func (BomXmlTexts) Find

func (t BomXmlTexts) Find(key string) (string, error)

func (BomXmlTexts) GetNum

func (t BomXmlTexts) GetNum(key string) (int, error)

func (BomXmlTexts) ToPreciseForecast

func (t BomXmlTexts) ToPreciseForecast() (*PreciseForecast, error)

type Celcius

type Celcius int

type ErrKeyMissing

type ErrKeyMissing string

func (ErrKeyMissing) Error

func (e ErrKeyMissing) Error() string

type Forecast

type Forecast struct {
	Date               string
	Description        string
	ChanceOfRain       string
	PrecipitationRange string
	*PreciseForecast
}

func Latest

func Latest() ([]Forecast, error)

type PreciseForecast

type PreciseForecast struct {
	MaxTemperature Celcius
	MinTemperature Celcius
}

Jump to

Keyboard shortcuts

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