itlookslike

package module
v0.0.0-...-87a0c73 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2016 License: MIT Imports: 12 Imported by: 0

README

It looks like ...

はじめに

定期的に Yahoo! の気象情報API を取得して少し先の天気をなんとなく予報します。

動作環境

Google App Engine を想定しています。

API

デプロイ先のルートアクセスでフィードを返します。 /update で更新をします。

デプロイ方法

GAE のアプリケーションキーを取得して app.yaml を書いてください。 Yahoo! デベロッパーネットワーク でアカウントを取得しアプリケーション ID を取得して config.go を書いてください。

その後、

goapp deploy

でデプロイされるはずです。10 分ごとに cron で取得に行きます。

Documentation

Index

Constants

View Source
const ApiUrl = "http://weather.olp.yahooapis.jp/v1/place?coordinates=%s&appid=%s"
View Source
const AppId = "あなたのアプリケーション ID"

http://developer.yahoo.co.jp/ で取得したあなたのアプリケーション ID

View Source
const Coordinates = "139.691764,35.689661"

予報位置。api のパラメーター。デフォルトでは都庁のあたりです

View Source
const FeedUri = "http://weather.yahoo.co.jp/weather/jp/13/4410/13104.html"
View Source
const RainThreshould = 0.5

雨と判断する下限値 mm/h

View Source
const SpotName = "新宿"

予報位置。表示用

Variables

This section is empty.

Functions

This section is empty.

Types

type RainStatus

type RainStatus int
const (
	NoRain RainStatus = iota // 降っていない

	BeginRain
	LightRain    // 小雨 数時間続いても1mm未満の雨
	SoftRain     // 弱い雨 3mm未満
	ModerateRain // やや強い雨 10mm以上20mm未満
	HeavyRain    // 強い雨 20mm以上
	EndRain

	BeginForecastRain
	ForecastSoftRain     // 弱い雨 3mm未満
	ForecastModerateRain // やや強い雨 10mm以上20mm未満
	ForecastHeavyRain    // 強い雨 20mm以上
	EndForecastRain
)

type Result

type Result struct {
	UpdatedTime int64 // 前回の更新時刻 Unix time
	RainTime    int64 // 最後に実際に雨が降っていた時刻 Unix time
	Status      RainStatus
	Text        string
}

前回の情報

type StoredData

type StoredData struct {
	Serialized []byte
}

フィードの出力用

type WeatherInfo

type WeatherInfo struct {
	Type     string  // observation or forecast
	Time     int64   // Unix time
	Rainfall float64 // mm/h
}

取得した気象情報

type WeatherInfos

type WeatherInfos []WeatherInfo

予報時刻でのソート用

func (WeatherInfos) Len

func (w WeatherInfos) Len() int

func (WeatherInfos) Less

func (w WeatherInfos) Less(i, j int) bool

func (WeatherInfos) Swap

func (w WeatherInfos) Swap(i, j int)

Jump to

Keyboard shortcuts

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