Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- type Data
- type DataSet
- type DataSetType
- type Dataset
- type DatasetService
- type ErrorResponse
- type F36HWCountryLocation
- type F36HWTime
- type FTWCountryLocation
- type FTWDatasetLocation
- type FTWElementValue
- type FTWTime
- type FTWWeatherElement
- type Fields
- type Forecast36HourWeather
- type ForecastTownshipsWeather
- type ForecastsService
- func (s *ForecastsService) Get36HourWeather(ctx context.Context, locationNames, elements []string) (*Forecast36HourWeather, *http.Response, error)
- func (s *ForecastsService) GetTownshipsWeatherByDataId(ctx context.Context, dataId string, locationNames, elements []string) (*ForecastTownshipsWeather, *http.Response, error)
- func (s *ForecastsService) GetTownshipsWeatherByLocations(ctx context.Context, locationIds, locationNames, elements []string) (*ForecastTownshipsWeather, *http.Response, error)
- type Location
- type Parameter
- type Result
- type StationObsElement
- type StationObsElements
- type StationObsLocation
- type StationObsRainfall
- type StationObsResponse
- type StationObsService
- type StationObsWeather
- type TideForecast1MonthOptions
- type TideForecast1MonthResponse
- type TideForecastLocation
- type TideForecastParameter
- type TideForecastTime
- type TideForecastWeatherElement
- type TideForecastsService
Constants ¶
const ( // Data set Ids // 36 hour weather forecasts F36HW = "F-C0032-001" // Townships forecasts FTW2DayYilanCounty = "F-D0047-001" FTW7DayYilanCounty = "F-D0047-003" FTW2DayTaoyuanCity = "F-D0047-005" FTW7DayTaoyuanCity = "F-D0047-007" FTW2DayHsinchuCounty = "F-D0047-009" FTW7DayHsinchuCounty = "F-D0047-011" FTW2DayMiaoliCounty = "F-D0047-013" FTW7DayMiaoliCounty = "F-D0047-015" FTW2DayChanghuaCounty = "F-D0047-017" FTW7DayChanghuaCounty = "F-D0047-019" FTW2DayNantouCounty = "F-D0047-021" FTW7DayNantouCounty = "F-D0047-023" FTW2DayYunlinCounty = "F-D0047-025" FTW7DayYunlinCounty = "F-D0047-027" FTW2DayChiayiCounty = "F-D0047-029" FTW7DayChiayiCounty = "F-D0047-031" FTW2DayPingtungCounty = "F-D0047-033" FTW7DayPingtungCounty = "F-D0047-035" FTW2DayTaitungCounty = "F-D0047-037" FTW7DayTaitungCounty = "F-D0047-039" FTW2DayHualienCounty = "F-D0047-041" FTW7DayHualienCounty = "F-D0047-043" FTW2DayPenghuCounty = "F-D0047-045" FTW7DayPenghuCounty = "F-D0047-047" FTW2DayKeelungCity = "F-D0047-049" FTW7DayKeelungCity = "F-D0047-051" FTW2DayHsinchuCity = "F-D0047-053" FTW7DayHsinchuCity = "F-D0047-055" FTW2DayChiayiCity = "F-D0047-057" FTW7DayChiayiCity = "F-D0047-059" FTW2DayTaipeiCity = "F-D0047-061" FTW7DayTaipeiCity = "F-D0047-063" FTW2DayKaohsiungCity = "F-D0047-065" FTW7DayKaohsiungCity = "F-D0047-067" FTW2DayNewTaipeiCity = "F-D0047-069" FTW7DayNewTaipeiCity = "F-D0047-071" FTW2DayTaichungCity = "F-D0047-073" FTW7DayTaichungCity = "F-D0047-075" FTW2DayTainanCity = "F-D0047-077" FTW7DayTainanCity = "F-D0047-079" FTW2DayLienchiangCounty = "F-D0047-081" FTW7DayLienchiangCounty = "F-D0047-083" FTW2DayKinmenCounty = "F-D0047-085" FTW7DayKinmenCounty = "F-D0047-087" FTW2DayTaiwan = "F-D0047-089" FTW7DayTaiwan = "F-D0047-091" FTWTaiwan = "F-D0047-093" )
const ( // Data set Ids // Weather observation data StationObsWeatherId = "O-A0001-001" // Rainfall observation data StationObsRainfallId = "O-A0002-001" )
const (
// tide forecasts 1 month
Tide1MonthId = "F-A0021-001"
)
Variables ¶
var (
ErrElementNotFound = errors.New("element not found")
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { BaseURL *url.URL UserAgent string // Services Dataset *DatasetService Forecasts *ForecastsService StationObs *StationObsService TideForecasts *TideForecastsService // contains filtered or unexported fields }
A Client manages communication with the CWB API.
func NewClient ¶
NewClient returns a new CWB API client. The token are required for authentication. If a nil httpClient is provided, http.DefaultClient will be used.
type Data ¶
type Data struct { CwbCategory string `json:"cwbCategory"` Datanamefixid string `json:"datanamefixid"` Title string `json:"title"` Description string `json:"description"` FieldDescription string `json:"fieldDescription"` Type string `json:"type"` License string `json:"license"` LicenseURL string `json:"licenseURL"` Cost string `json:"cost"` CostURL string `json:"costURL"` CostLaw string `json:"costLaw"` Organization string `json:"organization"` OrganizationContactName string `json:"organizationContactName"` OrganizationContactPhone string `json:"organizationContactPhone"` OrganizationContactEmail string `json:"organizationContactEmail"` Publisher string `json:"publisher"` PublisherContactName string `json:"publisherContactName"` PublisherContactPhone string `json:"publisherContactPhone"` PublisherContactEmail string `json:"publisherContactEmail"` AccrualPeriodicity string `json:"accrualPeriodicity"` TemporalCoverageFrom string `json:"temporalCoverageFrom,omitempty"` TemporalCoverageTo string `json:"temporalCoverageTo,omitempty"` Issued string `json:"issued"` Modified string `json:"modified"` Spatial string `json:"spatial"` Language string `json:"language"` LandingPage string `json:"landingPage"` Notes string `json:"notes"` }
type DataSet ¶
type DataSet struct { Name string Type DataSetType }
type DataSetType ¶
type DataSetType int
const ( DataSetTypeFTW DataSetType = iota DataSetTypeFTW7Day )
type ErrorResponse ¶
ErrorResponse reports error caused by an API request.
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type F36HWCountryLocation ¶
type F36HWCountryLocation struct { LocationName string `json:"locationName"` WeatherElement []struct { ElementName string `json:"elementName"` Time []struct { StartTime string `json:"startTime"` EndTime string `json:"endTime"` Parameter struct { ParameterName string `json:"parameterName"` ParameterValue *string `json:"parameterValue,omitempty"` ParameterUnit *string `json:"parameterUnit,omitempty"` } `json:"parameter"` } `json:"time"` } `json:"weatherElement"` }
type FTWCountryLocation ¶
type FTWCountryLocation struct { DatasetDescription string `json:"datasetDescription"` LocationsName *string `json:"locationsName,omitempty"` Dataid string `json:"dataid"` Location []FTWDatasetLocation `json:"location"` }
type FTWDatasetLocation ¶
type FTWDatasetLocation struct { LocationName string `json:"locationName"` Geocode string `json:"geocode"` Lat string `json:"lat"` Lon string `json:"lon"` WeatherElement []FTWWeatherElement `json:"weatherElement"` }
type FTWElementValue ¶
type FTWTime ¶
type FTWTime struct { DataTime *string `json:"dataTime,omitempty"` StartTime *string `json:"startTime,omitempty"` EndTime *string `json:"endTime,omitempty"` ElementValue []FTWElementValue `json:"elementValue,omitempty"` Parameter []Parameter `json:"parameter,omitempty"` }
type FTWWeatherElement ¶
type Forecast36HourWeather ¶
type Forecast36HourWeather struct { Success string `json:"success"` Result Result `json:"result"` Records struct { DatasetDescription string `json:"datasetDescription"` Location []F36HWCountryLocation `json:"location"` } `json:"records"` }
type ForecastTownshipsWeather ¶
type ForecastTownshipsWeather struct { Success string `json:"success"` Result Result `json:"result"` Records struct { Locations []FTWCountryLocation `json:"locations"` } `json:"records"` }
type ForecastsService ¶
type ForecastsService service
func (*ForecastsService) Get36HourWeather ¶
func (s *ForecastsService) Get36HourWeather(ctx context.Context, locationNames, elements []string) (*Forecast36HourWeather, *http.Response, error)
Get36HourWeather gets 36-hour weather forecasts.
func (*ForecastsService) GetTownshipsWeatherByDataId ¶
func (s *ForecastsService) GetTownshipsWeatherByDataId(ctx context.Context, dataId string, locationNames, elements []string) (*ForecastTownshipsWeather, *http.Response, error)
GetTownshipsWeatherByDataId gets townships forecasts by data Id. See http://opendata.cwb.gov.tw/datalist for dataId (F-D0047-001 - F-D0047-091).
func (*ForecastsService) GetTownshipsWeatherByLocations ¶
func (s *ForecastsService) GetTownshipsWeatherByLocations(ctx context.Context, locationIds, locationNames, elements []string) (*ForecastTownshipsWeather, *http.Response, error)
GetTownshipsWeatherByLocations gets townships forecasts by locationIds and locationNames.
type Location ¶
func FindLocationByName ¶
type StationObsElement ¶
type StationObsElements ¶
type StationObsElements []StationObsElement
func (StationObsElements) GetByName ¶
func (es StationObsElements) GetByName(name string) (StationObsElement, error)
type StationObsLocation ¶
type StationObsLocation struct { Lat string `json:"lat"` Lon string `json:"lon"` LocationName string `json:"locationName"` StationId string `json:"stationId"` Time struct { ObsTime string `json:"obsTime"` } `json:"time"` WeatherElement StationObsElements `json:"weatherElement"` Parameter []Parameter `json:"parameter"` }
type StationObsRainfall ¶
type StationObsRainfall StationObsResponse
type StationObsResponse ¶
type StationObsResponse struct { Success string `json:"success"` Result Result `json:"result"` Records struct { Location []StationObsLocation `json:"location"` } `json:"records"` }
type StationObsService ¶
type StationObsService service
func (*StationObsService) GetRainfall ¶
func (s *StationObsService) GetRainfall(ctx context.Context, options url.Values) (*StationObsRainfall, *http.Response, error)
GetRainfall gets rainfall observation data.
func (*StationObsService) GetWeather ¶
func (s *StationObsService) GetWeather(ctx context.Context, options url.Values) (*StationObsWeather, *http.Response, error)
GetWeather gets weather observation data.
type StationObsWeather ¶
type StationObsWeather StationObsResponse
type TideForecast1MonthOptions ¶
type TideForecast1MonthOptions struct { Limit int `url:"limit,omitempty"` Offset int `url:"offset,omitempty"` LocationName string `url:"locationName,omitempty"` // see https://opendata.cwb.gov.tw/opendatadoc/MMC/A0021-001.pdf ElementName string `url:"elementName,omitempty"` Sort string `url:"sort,omitempty"` StartTime string `url:"startTime,omitempty"` DataTime string `url:"dataTime,omitempty"` TimeForm string `url:"timeForm,omitempty"` TimeTo string `url:"timeTo,omitempty"` }
type TideForecast1MonthResponse ¶
type TideForecast1MonthResponse struct { Success string `json:"success"` Result Result `json:"result"` Records struct { Dataid string `json:"dataid"` Note string `json:"note"` Location []TideForecastLocation `json:"location"` } `json:"records"` }
type TideForecastLocation ¶
type TideForecastLocation struct { LocationName string `json:"locationName"` StationId string `json:"stationId"` ValidTime []struct { StartTime string `json:"startTime"` EndTime string `json:"endTime"` WeatherElement []TideForecastWeatherElement `json:"weatherElement"` } `json:"validTime"` }
type TideForecastParameter ¶
type TideForecastTime ¶
type TideForecastTime struct { DataTime string `json:"dataTime"` Parameter []TideForecastParameter `json:"parameter"` }
type TideForecastWeatherElement ¶
type TideForecastWeatherElement struct { ElementName string `json:"elementName"` ElementValue *string `json:"elementValue,omitempty"` Time []TideForecastTime `json:"time,omitempty"` }
type TideForecastsService ¶
type TideForecastsService service
func (*TideForecastsService) Get1MonthTide ¶
func (s *TideForecastsService) Get1MonthTide(ctx context.Context, options TideForecast1MonthOptions) (*TideForecast1MonthResponse, *http.Response, error)
Get1MonthTide gets 1 month tide forecasts. see https://opendata.cwb.gov.tw/dist/opendata-swagger.html#/%E9%A0%90%E5%A0%B1/get_v1_rest_datastore_F_A0021_001