baidu

package
v1.0.215 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogTable = "baidu"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *ClientConfig) (*Client, error)

NewClient 创建实例化

func (*Client) ConfigSLogClientFun added in v1.0.162

func (c *Client) ConfigSLogClientFun(apiSLogFun golog.ApiSLogFun)

ConfigSLogClientFun 日志配置

func (*Client) DefaultHttp added in v1.0.177

func (c *Client) DefaultHttp()

DefaultHttp 默认请求

func (*Client) Geocoding added in v1.0.130

func (c *Client) Geocoding(ctx context.Context, address string, notMustParams ...gorequest.Params) (*GeocodingResult, error)

Geocoding 地理编码服务 https://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-geocoding

func (*Client) GetAk added in v1.0.126

func (c *Client) GetAk() string

func (*Client) LocationIp added in v1.0.126

func (c *Client) LocationIp(ctx context.Context, ip string, notMustParams ...gorequest.Params) (*LocationIpResult, error)

LocationIp 普通IP定位 https://lbsyun.baidu.com/index.php?title=webapi/ip-api

func (*Client) ReverseGeocoding added in v1.0.130

func (c *Client) ReverseGeocoding(ctx context.Context, location string, notMustParams ...gorequest.Params) (*ReverseGeocodingResult, error)

ReverseGeocoding 全球逆地理编码服务 https://lbsyun.baidu.com/index.php?title=webapi/guide/webservice-geocoding-abroad

func (*Client) SetHttp added in v1.0.177

func (c *Client) SetHttp(app *gorequest.App)

SetHttp 配置请求

func (*Client) Weather added in v1.0.126

func (c *Client) Weather(ctx context.Context, districtId string, notMustParams ...gorequest.Params) (*WeatherResult, error)

Weather 国内天气查询服务 https://lbsyun.baidu.com/index.php?title=webapi/weather

type ClientConfig added in v1.0.126

type ClientConfig struct {
	Ak string
}

ClientConfig 实例配置

type GeocodingResponse added in v1.0.130

type GeocodingResponse struct {
	Status int `json:"status"`
	Result struct {
		Location struct {
			Lng float64 `json:"lng"`
			Lat float64 `json:"lat"`
		} `json:"location"`
		Precise       int    `json:"precise"`
		Confidence    int    `json:"confidence"`
		Comprehension int    `json:"comprehension"`
		Level         string `json:"level"`
	} `json:"result"`
}

type GeocodingResult added in v1.0.130

type GeocodingResult struct {
	Result GeocodingResponse  // 结果
	Body   []byte             // 内容
	Http   gorequest.Response // 请求
}

type LocationIpResponse added in v1.0.126

type LocationIpResponse struct {
	Address string `json:"address"` // 详细地址信息
	Content struct {
		AddressDetail struct {
			Province     string `json:"province"` // 省份
			City         string `json:"city"`     // 城市
			District     string `json:"district"`
			Street       string `json:"street"`
			StreetNumber string `json:"street_number"`
			CityCode     int    `json:"city_code"` // 百度城市代码
			Adcode       string `json:"adcode"`
		} `json:"address_detail"`
		Address string `json:"address"` // 简要地址信息
		Point   struct {
			X string `json:"x"` // 当前城市中心点经度
			Y string `json:"y"` // 当前城市中心点纬度
		} `json:"point"`
	} `json:"content"`
	Status int `json:"status"`
}

type LocationIpResult added in v1.0.126

type LocationIpResult struct {
	Result LocationIpResponse // 结果
	Body   []byte             // 内容
	Http   gorequest.Response // 请求
}

type ReverseGeocodingResponse added in v1.0.130

type ReverseGeocodingResponse struct {
	Status int `json:"status"`
	Result struct {
		Location struct {
			Lng float64 `json:"lng"`
			Lat float64 `json:"lat"`
		} `json:"location"`
		FormattedAddress string `json:"formatted_address"`
		Business         string `json:"business"`
		AddressComponent struct {
			Country         string `json:"country"`
			CountryCode     int    `json:"country_code"`
			CountryCodeIso  string `json:"country_code_iso"`
			CountryCodeIso2 string `json:"country_code_iso2"`
			Province        string `json:"province"`
			City            string `json:"city"`
			CityLevel       int    `json:"city_level"`
			District        string `json:"district"`
			Town            string `json:"town"`
			TownCode        string `json:"town_code"`
			Distance        string `json:"distance"`
			Direction       string `json:"direction"`
			Adcode          string `json:"adcode"`
			Street          string `json:"street"`
			StreetNumber    string `json:"street_number"`
		} `json:"addressComponent"`
		Pois               []interface{} `json:"pois"`
		Roads              []interface{} `json:"roads"`
		PoiRegions         []interface{} `json:"poiRegions"`
		SematicDescription string        `json:"sematic_description"`
		CityCode           int           `json:"cityCode"`
	} `json:"result"`
}

type ReverseGeocodingResult added in v1.0.130

type ReverseGeocodingResult struct {
	Result ReverseGeocodingResponse // 结果
	Body   []byte                   // 内容
	Http   gorequest.Response       // 请求
}

type WeatherResponse added in v1.0.126

type WeatherResponse struct {
	Status int `json:"status"`
	Result struct {
		Location struct {
			Country  string `json:"country"`  // 国家名称
			Province string `json:"province"` // 省份名称
			City     string `json:"city"`     // 城市名称
			Name     string `json:"name"`     // 区县名称
			Id       string `json:"id"`       // 区县id
		} `json:"location"` // 地理位置信息
		Now struct {
			Text      string  `json:"text"`       // 天气现象
			Temp      int     `json:"temp"`       // 温度(℃)
			FeelsLike int     `json:"feels_like"` // 体感温度(℃)
			Rh        int     `json:"rh"`         // 相对湿度(%)
			WindClass string  `json:"wind_class"` // 风力等级
			WindDir   string  `json:"wind_dir"`   // 风向描述
			Prec1h    float64 `json:"prec_1h"`    // 1小时累计降水量(mm)
			Clouds    int     `json:"clouds"`     // 云量(%)
			Vis       int     `json:"vis"`        // 能见度(m)
			Aqi       int     `json:"aqi"`        // 空气质量指数数值
			Pm25      int     `json:"pm25"`       // pm2.5浓度(μg/m3)
			Pm10      int     `json:"pm10"`       // pm10浓度(μg/m3)
			No2       int     `json:"no2"`        // 二氧化氮浓度(μg/m3)
			So2       int     `json:"so2"`        // 二氧化硫浓度(μg/m3)
			O3        int     `json:"o3"`         // 臭氧浓度(μg/m3)
			Co        float64 `json:"co"`         // 一氧化碳浓度(mg/m3)
			Uptime    string  `json:"uptime"`     // 数据更新时间,北京时间
		} `json:"now"` // 实况数据
		Alert []struct {
			Type  string `json:"type"`  // 预警事件类型
			Level string `json:"level"` // 预警事件等级
			Title string `json:"title"` // 预警标题
			Desc  string `json:"desc"`  // 预警详细提示信息
		} `json:"alert"` // 气象预警数据
		Indexes []struct {
			Name   string `json:"name"`   // 生活指数中文名称
			Brief  string `json:"brief"`  // 生活指数概要说明
			Detail string `json:"detail"` // 生活指数详细说明
		} `json:"indexes"` // 生活指数数据
		Forecasts []struct {
			Date      string `json:"date"`       // 日期,北京时区
			Week      string `json:"week"`       // 星期,北京时区
			High      int    `json:"high"`       // 最高温度(℃)
			Low       int    `json:"low"`        // 最低温度(℃)
			WcDay     string `json:"wc_day"`     // 白天风力
			WcNight   string `json:"wc_night"`   // 晚上风力
			WdDay     string `json:"wd_day"`     // 白天风向
			WdNight   string `json:"wd_night"`   // 晚上风向
			TextDay   string `json:"text_day"`   // 白天天气现象
			TextNight string `json:"text_night"` // 晚上天气现象
		} `json:"forecasts"` // 预报数据
		ForecastHours []struct {
			Text      string  `json:"text"`       // 天气现象
			TempFc    int     `json:"temp_fc"`    // 温度(℃)
			WindClass string  `json:"wind_class"` // 风力等级
			WindDir   string  `json:"wind_dir"`   // 风向描述
			Rh        int     `json:"rh"`         // 相对湿度
			Prec1h    float64 `json:"prec_1h"`    // 1小时累计降水量(mm)
			Clouds    int     `json:"clouds"`     // 云量(%)
			DataTime  string  `json:"data_time"`  // 数据时间
		} `json:"forecast_hours"` // 未来24小时逐小时预报
	} `json:"result"`
	Message string `json:"message"`
}

type WeatherResult added in v1.0.126

type WeatherResult struct {
	Result WeatherResponse    // 结果
	Body   []byte             // 内容
	Http   gorequest.Response // 请求
}

Jump to

Keyboard shortcuts

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