备份Notify.App.hfWeather

//hfx 第一代接口
namespace Notify.App.hfWeather
{
    public class hfx_atstronomy
    {
        private string key = ""; //
        const string api_host = "https://api.qweather.com";
        const string free_api_host = "https://devapi.qweather.com";
        public string api_url { get; private set; }
        public string host_url { get; private set; }

        public hfx_atstronomy(string key)
        {
            this.key = key;
            this.host_url = free_api_host;
        }
        public hfx_atstronomy(string key, api_host_type type)
        {
            this.key = key;
            switch (type)
            {
                case api_host_type.free:
                    this.host_url = free_api_host;
                    break;
                case api_host_type.pay:
                    this.host_url = api_host;
                    break;
            }
        }
        public string astronomy_sun(string date, string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/sun?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + location;
            this.api_url = this.host_url + $"/v7/astronomy/sun?key={key}&lang=zh&date={date}&location={location}";
            return this.api_url;
        }
        /// <summary>
        /// 日出日落
        /// </summary>
        /// <param name="date"></param>
        /// <param name="locationid"></param>
        /// <returns></returns>
        public string astronomy_sun_byid(string date, string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/sun?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/astronomy/sun?key={key}&lang=zh&date={date}&location={locationid}";
            return this.api_url;
        }
        public string astronomy_sun_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/sun?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/astronomy/sun?key={key}&lang=zh&date={DateTime.Now.ToString("yyyyMMdd")}&location={locationid}";
            return this.api_url;
        }
        public string astronomy_sun_byid(int locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/sun?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/astronomy/sun?key={key}&lang=zh&date={DateTime.Now.ToString("yyyyMMdd")}&location={locationid.ToString()}";
            return this.api_url;
        }
        public string astronomy_sun_byposition(string date, string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/sun?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + lng + "," + lat;
            this.api_url = this.host_url + $"/v7/astronomy/sun?key={key}&lang=zh&date={date}&location={lng},{lat}";
            return this.api_url;
        }
        public string astronomy_moon(string date, string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/moon?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + location;
            this.api_url = this.host_url + $"/v7/astronomy/moon?key={key}&lang=zh&date={date}&location={location}";
            return this.api_url;
        }
        public string astronomy_moon_byid(string date, string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/moon?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/astronomy/moon?key={key}&lang=zh&date={date}&location={locationid}";
            return this.api_url;
        }
        public string astronomy_moon_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/moon?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/astronomy/moon?key={key}&lang=zh&date={DateTime.Now.ToString("yyyMMdd")}&location={locationid}";
            return this.api_url;
        }
        public string astronomy_moon_byid(int locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/moon?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/astronomy/moon?key={key}&lang=zh&date={DateTime.Now.ToString("yyyMMdd")}&location={locationid.ToString()}";
            return this.api_url;
        }
        public string astronomy_moon_byposition(string date, string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/moon?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + lng + "," + lat;
            this.api_url = this.host_url + $"/v7/astronomy/moon?key={key}&lang=zh&date={date}&location={lng},{lat}";
            return this.api_url;
        }
        /// <summary>
        /// 太阳高度角,收费应用,仅可使用付费主机。
        /// </summary>
        /// <param name="location"></param>
        /// <param name="date"></param>
        /// <param name="time"></param>
        /// <param name="tz"></param>
        /// <param name="alt"></param>
        /// <returns></returns>
        public string solarangle(string location, string date, string time, string tz, string alt)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/solar-elevation-angle?"
            //  + "key=" + key + "&lang=zh" + "&location=" + location + "&date=" + date + "&time=" + time + "&tz=" + tz + "&alt=" + alt;
            this.host_url = api_host;
            this.api_url = this.host_url + $"/v7/astronomy/solar-elevation-angle?key={key}&lang=zh&location={location}&date={date}&time={time}&tz={tz}&alt={alt}";
            return this.api_url;
        }
        /// <summary>
        /// 太阳高度角,收费应用,仅可使用付费主机。
        /// </summary>
        /// <param name="lng"></param>
        /// <param name="lat"></param>
        /// <param name="date"></param>
        /// <param name="time"></param>
        /// <param name="tz"></param>
        /// <param name="alt"></param>
        /// <returns></returns>
        public string solarangle_byposition(string lng, string lat, string date, string time, string tz, string alt)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/solar-elevation-angle?"
            //  + "key=" + key + "&lang=zh" + "&location=" + lng + "," + lat + "&date=" + date + "&time=" + time + "&tz=" + tz + "&alt=" + alt;
            //this.host_url = api_host;
            this.api_url = this.host_url + $"/v7/astronomy/solar-elevation-angle?key={key}&lang=zh&location={lng},{lat}&date={date}&time={time}&tz={tz}&alt={alt}";
            return this.api_url;
        }
    }
    public enum api_host_type
    {
        free,
        pay
    }
    public class hfx
    {
        private string key = ""; //32 bit chars
                                 //adcode \ 城市名,如北京 \beijing,拼音或英文,支持模糊查找
        const string api_host = "https://api.qweather.com";
        const string free_api_host = "https://devapi.qweather.com";
        public string api_url { get; private set; }
        public string host_url { get; private set; }
        public hfx(string key)
        {
            this.key = key;
            this.host_url = free_api_host;
        }
        
        public hfx(string key, api_host_type type)
        {
            this.key = key;

            switch (type)
            {
                case api_host_type.free:
                    this.host_url = free_api_host;
                    break;
                case api_host_type.pay:
                    this.host_url = api_host;
                    break;
            }
        }
        public string geocity_byadcode(string adcode)
        {
            //string api = "https://geoapi.qweather.com/v2/city/lookup?"
            //  + "key=" + key + "&lang=zh&num=20" + "&Range=cn" + "&location=" + adcode;
            this.api_url = $"https://geoapi.qweather.com/v2/city/lookup?key={key}&lang=zh&num=20&location={adcode}";
            this.host_url= "https://geoapi.qweather.com";
            return this.api_url;
        }
        /// <summary>
        /// 根据城市名获取城市信息
        /// </summary>
        /// <param name="adcode"></param>
        /// <param name="num">1-20</param>
        /// <returns></returns>
        public string geocity_byadcode(string adcode,int num)
        {
            //string api = "https://geoapi.qweather.com/v2/city/lookup?"
            //  + "key=" + key + "&lang=zh&num=20" + "&Range=cn" + "&location=" + adcode;
            this.api_url = $"https://geoapi.qweather.com/v2/city/lookup?key={key}&lang=zh&num={num}&location={adcode}";
            this.host_url = "https://geoapi.qweather.com";
            return this.api_url;
        }
        public string geocity_byname2(string name, string adm, string range = "cn")
        {
            //string api = "https://geoapi.qweather.com/v2/city/lookup?"
            //  + "key=" + key + "&lang=zh&num=20" + "&Range=" + range
            //  + "&location=" + name + "&adm=" + adm;
            this.api_url = $"https://geoapi.qweather.com//v2/city/lookup?key={key}&lang=zh&num=20&Range={range}&location={name}&adm={adm}";
            this.host_url = "https://geoapi.qweather.com";
            return this.api_url;
        }
        public string geocity_byposition(string longitude, string latitude)
        {
            //string api = "https://geoapi.qweather.com/v2/city/lookup?"
            //  + "key=" + key + "&lang=zh&num=20" + "&location=" + longitude + "," + latitude;
            this.api_url = $"https://geoapi.qweather.com/v2/city/lookup?key={key}&lang=zh&num=20&location={longitude},{latitude}";
            this.host_url = "https://geoapi.qweather.com";
            return this.api_url;
        }
        public string geocity_bylocation(string location, string range = "cn")
        {
            //string api = "https://geoapi.qweather.com/v2/city/lookup?"
            //  + "key=" + key + "&lang=zh&Range=cn&num=20" + "&location=" + location;
            this.api_url = $"https://geoapi.qweather.com/v2/city/lookup?key={key}&lang=zh&Range={range}&num=20&location={location}";
            this.host_url = "https://geoapi.qweather.com";
            return this.api_url;
        }
        public string geocity_bylocationid(string locationid)
        {
            //string api = "https://geoapi.qweather.com/v2/city/lookup?"
            //  + "key=" + key + "&lang=zh&num=20" + "&location=" + locationid;
            this.api_url = $"https://geoapi.qweather.com/v2/city/lookup?key={key}&lang=zh&num=20&location={locationid}";
            this.host_url = "https://geoapi.qweather.com";
            return this.api_url;
        }

        //number取值范围1-20,默认返回10个结果。
        public string topcity(int number = 20, string iso3166country = "cn")
        {
            if (iso3166country == string.Empty)
                iso3166country = "cn";
            if (number < 1 || number > 20)
                number = 10;
            //string api = "https://geoapi.qweather.com/v2/city/top?"
            //  + "key=" + key + "&lang=zh" + "&range=" + iso3166country + "&number=" + number;
            this.api_url = $"https://geoapi.qweather.com/v2/city/top?key={key}&lang=zh&range={iso3166country}&number={number}";
            this.host_url = "https://geoapi.qweather.com";
            return this.api_url;
        }
        public string lookupPOI(string type, string location, int number = 20)
        {
            if (number < 1 || number > 20)
                number = 10;
            //string api = "https://geoapi.qweather.com/v2/poi/lookup?"
            //+ "key=" + key + "&lang=zh" + "&type=" + type + "&location=" + location + "&number=" + number;
            this.api_url = $"https://geoapi.qweather.com/v2/poi/lookup?key={key}&lang=zh&type={type}&location={location}&number={number}";
            this.host_url = "https://geoapi.qweather.com";
            return this.api_url;
        }
        public string lookupPOI_byid(string type, string locationid, int number = 20)
        {
            if (number < 1 || number > 20)
                number = 10;
            //string api = "https://geoapi.qweather.com/v2/poi/lookup?"
            //    + "key=" + key + "&lang=zh" + "&type=" + type + "&location=" + locationid + "&number=" + number;
            this.api_url = $"https://geoapi.qweather.com/v2/poi/lookup?key={key}&lang=zh&type={type}&location={locationid}&number={number}";

            this.host_url = "https://geoapi.qweather.com";
            return this.api_url;
        }
        public string lookupPOI_byadcode(string type, string adcode, int number = 20)
        {
            if (number < 1 || number > 20)
                number = 10;
            //string api = "https://geoapi.qweather.com/v2/poi/lookup?" + "key=" + key + "&lang=zh" + "&type=" + type + "&location=" + adcode + "&number=" + number;
            this.api_url = $"https://geoapi.qweather.com/v2/poi/lookup?key={key}&lang=zh&type={type}&location={adcode}&number={number}";

            this.host_url = "https://geoapi.qweather.com";
            return this.api_url;
        }
        //location为经纬度
        public string rangePOI(string type, string location, int radius = 5, int number = 20)
        {
            if (number < 1 || number > 20)
                number = 10;
            if (radius < 1 || radius > 50)
                radius = 5;
            //string api = "https://geoapi.qweather.com/v2/poi/v2/poi/range?"
            //  + "key=" + key + "&lang=zh" + "&type=" + type + "&number=" + number + "&radius=" + radius + "&location=" + location;
            this.api_url = $"https://geoapi.qweather.com/v2/poi/v2/poi/range?key={key}&lang=zh&type={type}&number={number}&radius={radius}&location={location}";
            this.host_url = "https://geoapi.qweather.com";
            return this.api_url;
        }
        public string rangePOI_byposition(string type, string lng, string lat, int radius = 5, int number = 20)
        {
            if (number < 1 || number > 20)
                number = 10;
            if (radius < 1 || radius > 50)
                radius = 5;
            //string api = "https://geoapi.qweather.com/v2/poi/v2/poi/range?"
            //  + "key=" + key + "&lang=zh" + "&type=" + type + "&number=" + number + "&radius=" + radius + "&location=" + lng + "," + lat;
            this.api_url = $"https://geoapi.qweather.com/v2/poi/v2/poi/range?key={key}&lang=zh&type={type}&number={number}&radius={radius}&location={lng},{lat}";
            this.host_url = "https://geoapi.qweather.com";
            return this.api_url;
        }
        public string weather_now_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/now?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + locationid;

            this.api_url=this.host_url + $"/v7/weather/now?key={key}&lang=zh&unit=m&location={locationid}";
            return this.api_url;
        }
        //location为经纬度
        public string weather_now_bylocation(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/now?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + location;
            
            this.api_url =this.host_url+ $"/v7/weather/now?key={key}&lang=zh&unit=m&location={location}";
            return this.api_url;
        }
        public string weather_now_bylocation(int locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/now?key=key + "&lang=zh&unit=m" + "&location=" + location;

            this.api_url = this.host_url + $"/v7/weather/now?key={key}&lang=zh&unit=m&location={locationid.ToString()}";
            return this.api_url;
        }
        public string weather_now_bypostion(string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/now?"
            //      + "key=" + key + "&lang=zh&unit=m" + "&location=" + lng + "," + lat;
            this.api_url =this.host_url+ $"/v7/weather/now?key={key}&lang=zh&unit=m&location={lng},{lat}";
            return this.api_url;
        }
        public string weather_3d_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/3d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + locationid;
            this.api_url =this.host_url+ $"/v7/weather/3d?key={key}&lang=zh&unit=m&location={locationid}";
            return this.api_url;
        }
        public string weather_3d_bylocation(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/3d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + location;
            this.api_url =this.host_url+ $"/v7/weather/3d?key={key}&lang=zh&unit=m&location={location}";
            return this.api_url;
        }
        public string weather_3d_bypostion(string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/3d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + lng + "," + lat;
            this.api_url =this.host_url+ $"/v7/weather/3d?key={key}&lang=zh&unit=m&location={lng},{lat}";
            return this.api_url;
        }
        public string weather_7d_bylocation(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/3d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + location;
            this.api_url=this.host_url+ $"/v7/weather/7d?key={key}&lang=zh&unit=m&location={location}";
            return this.api_url;
        }
        public string weather_7d_bypostion(string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/7d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + lng + "," + lat;
            this.api_url =this.host_url+ $"/v7/weather/7d?key={key}&lang=zh&unit=m&location={lng},{lat}";
            return this.api_url;
        }
        public string weather_7d_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/7d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + locationid;
            this.api_url=this.host_url+ $"/v7/weather/7d?key={key}&lang=zh&unit=m&location={locationid}";
            return this.api_url;
        }
        public string weather_10d_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/10d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/weather/10d?key={key}&lang=zh&unit=m&location={locationid}";
            return this.api_url;
        }
        public string weather_15d_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/15d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/weather/15d?key={key}&lang=zh&unit=m&location={locationid}";
            return this.api_url;
        }
        public string weather_30d_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/30d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/weather/30d?key={key}&lang=zh&unit=m&location={locationid}";
            return this.api_url;
        }
        public string weather_24h_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/24h?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + locationid;
            this.api_url=this.host_url+ $"/v7/weather/24h?key={key}&lang=zh&unit=m&location={locationid}";
            return this.api_url;
        }
        public string weather_24h_bypostion(string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/24h?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + lng + "," + lat;
            this.api_url =this.host_url+ $"/v7/weather/24h?key={key}&lang=zh&unit=m&location={lng},{lat}";
            return this.api_url;
        }
        public string weather_24h_bylocation(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/24h?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + location;
            this.api_url = this.host_url + $"/v7/weather/24h?key={key}&lang=zh&unit=m&location={location}";
            return this.api_url;
        }
        public string weather_72h_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/72h?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/weather/72h?key={key}&lang=zh&unit=m&location={locationid}";
            return this.api_url;
        }
        public string weather_168h_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/weather/168h?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/weather/168h?key={key}&lang=zh&unit=m&location={locationid}";
            return this.api_url;
        }

        public string rain_5m(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/minutely/5m?"
            //  + "key=" + key + "&lang=zh" + "&location=" + location;
            this.api_url=this.host_url+$"/v7/minutely/5m?key={key}&lang=zh&location={location}";
            return this.api_url;
        }
        public string rain_5m_byposition(string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/minutely/5m?"
            //  + "key=" + key + "&lang=zh" + "&location=" + lng + "," + lat;
            this.api_url=this.host_url+ $"/v7/minutely/5m?key={key}&lang=zh&location={lng},{lat}";
            return this.api_url;
        }
        public string gridweather_now(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/grid-weather/now?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + location;
            this.api_url=this.host_url+ $"/v7/grid-weather/now?key={key}&lang=zh&unit=m&location={location}";
            return this.api_url;
        }
        public string gridweather_now_byposition(string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/grid-weather/now?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + lng + "," + lat;
            this.api_url=this.host_url+ $"/v7/grid-weather/now?key={key}&lang=zh&unit=m&location={lng},{lat}";
            return this.api_url;
        }
        public string gridweather_3d(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/grid-weather/3d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + location;
            this.api_url=this.host_url+ $"/v7/grid-weather/3d?key={key}&lang=zh&unit=m&location={location}";
            return this.api_url;
        }
        public string gridweather_3d_byposition(string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/grid-weather/3d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + lng + "," + lat;
            this.api_url=this.host_url+ $"/v7/grid-weather/3d?key={key}&lang=zh&unit=m&location={lng},{lat}";
            return this.api_url;
        }
        public string gridweather_7d(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/grid-weather/7d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + location;
            this.api_url = this.host_url + $"/v7/grid-weather/7d?key={key}&lang=zh&unit=m&location={location}";
            return this.api_url;
        }
        public string gridweather_7d_byposition(string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/grid-weather/7d?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + lng + "," + lat;
            this.api_url = this.host_url + $"/v7/grid-weather/7d?key={key}&lang=zh&unit=m&location={lng},{lat}";
            return this.api_url;
        }
        public string gridweather_24h(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/grid-weather/24h?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + location;
            this.api_url = this.host_url + $"/v7/grid-weather/24h?key={key}&lang=zh&unit=m&location={location}";
            return this.api_url;
        }
        public string gridweather_24h_byposition(string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/grid-weather/24h?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + lng + "," + lat;
            this.api_url = this.host_url + $"/v7/grid-weather/24h?key={key}&lang=zh&unit=m&location={lng},{lat}";
            return this.api_url;
        }
        public string gridweather_72h(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/grid-weather/72h?"
            //  + "key=" + key + "&lang=zh&unit=m" + "&location=" + location;
            this.api_url = this.host_url + $"/v7/grid-weather/72h?key={key}&lang=zh&unit=m&location={location}";
            return this.api_url;
        }
        public string warning_list(string range_iso3166)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/warning/now?"
            //  + "key=" + key + "&lang=zh" + "&location=" + range_iso3166;
            this.api_url = this.host_url + $"/v7/warning/now?key={key}&lang=zh&location={range_iso3166}";
            return this.api_url;
        }
        public string warning_now(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/warning/now?"
            //  + "key=" + key + "&lang=zh" + "&location=" + location;
            this.api_url = this.host_url + $"/v7/warning/now?key={key}&lang=zh&location={location}";
            return this.api_url;
        }
        public string warning_now_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/warning/now?"
            //  + "key=" + key + "&lang=zh" + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/warning/now?key={key}&lang=zh&location={locationid}";
            return this.api_url;
        }
        public string warning_now_byposition(string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/warning/now?"
            //  + "key=" + key + "&lang=zh" + "&location=" + lng + "," + lat;
            this.api_url = this.host_url + $"/v7/warning/now?key={key}&lang=zh&location={lng},{lat}";
            return this.api_url;
        }
        public string indices_today(string type, string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/indices/1d?"
            //  + "key=" + key + "&lang=zh" + "&type=" + type + "&location=" + location;
            this.api_url = this.host_url + $"/v7/indices/1d?key={key}&lang=zh&type={type}&location={location}";
            return this.api_url;
        }
        public string indices_today_byid(string type, string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            string api = "https://devapi.qweather.com/v7/indices/1d?"
              + "key=" + key + "&lang=zh" + "&type=" + type + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/indices/1d?key={key}&lang=zh&type={type}&location={locationid}";
            return this.api_url;
        }
        public string indices_today_byposition(string type, string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/indices/1d?"
            //  + "key=" + key + "&lang=zh" + "&type=" + type + "&location=" + lng + "," + lat;
            this.api_url = this.host_url + $"/v7/indices/1d?key={key}&lang=zh&type={type}&location={lng},{lat}";
            return this.api_url;
        }
        public string indices_3d(string type, string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/indices/3d?"
            //  + "key=" + key + "&lang=zh" + "&type=" + type + "&location=" + location;
            this.api_url = this.host_url + $"/v7/indices/3d?key={key}&lang=zh&type={type}&location={location}";
            return this.api_url;
        }
        public string indices_3d_byid(string type, string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/indices/3d?"
            //  + "key=" + key + "&lang=zh" + "&type=" + type + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/indices/3d?key={key}&lang=zh&type={type}&location={locationid}";
            return this.api_url;
        }
        public string indices_3d_byposition(string type, string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/indices/3d?"
            //  + "key=" + key + "&lang=zh" + "&type=" + type + "&location=" + lng + "," + lat;
            this.api_url = this.host_url + $"/v7/indices/3d?key={key}&lang=zh&type={type}&location={lng},{lat}";
            return this.api_url;
        }
        public string air_now(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/air/now?"
            //  + "key=" + key + "&lang=zh" + "&location=" + location;
            this.api_url = this.host_url + $"/v7/air/now?key={key}&lang=zh&location={location}";
            return this.api_url;
        }
        public string air_now_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/air/now?"
            //  + "key=" + key + "&lang=zh" + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/air/now?key={key}&lang=zh&location={locationid}";
            return this.api_url;
        }
        public string air_now_byid(int locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/air/now?"
            //  + "key=" + key + "&lang=zh" + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/air/now?key={key}&lang=zh&location={locationid.ToString()}";
            return this.api_url;
        }
        public string air_now_byposition(string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/air/now?"
            //  + "key=" + key + "&lang=zh" + "&location=" + lng + "," + lat;
            this.api_url = this.host_url + $"/v7/air/now?key={key}&lang=zh&location={lng},{lat}";
            return this.api_url;
        }
        public string air_5d(string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/air/5d?"
            //  + "key=" + key + "&lang=zh" + "&location=" + location;
            this.api_url = this.host_url + $"/v7/air/5d?key={key}&lang=zh&location={location}";
            return this.api_url;
        }
        public string air_5d_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/air/5d?"
            //  + "key=" + key + "&lang=zh" + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/air/5d?key={key}&lang=zh&location={locationid}";
            return this.api_url;
        }
        public string air_5d_byposition(string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/air/5d?"
            //  + "key=" + key + "&lang=zh" + "&location=" + lng + "," + lat;
            this.api_url = this.host_url + $"/v7/air/5d?key={key}&lang=zh&location={lng},{lat}";
            return this.api_url;
        }
        public enum hfx_unit_type
        {
            m,  //公制单位
            i   //英制单位
        }
        public string historical_weather(string locationid,string date,string lang="zh",string unit="m")
        {
            this.host_url = api_host;
            this.api_url = this.host_url + $"/v7/historical/weather?key={this.key}&location={locationid}&date={date}&lang={lang}&unit={unit}";
            return this.api_url;
        }
        public string historical_air(string locationid, string date, string lang = "zh", string unit = "m")
        {
            this.host_url = api_host;
            this.api_url = this.host_url + $"/v7/historical/air?key={this.key}&location={locationid}&date={date}&lang={lang}&unit={unit}";
            return this.api_url;
        }
        public enum hfx_tropical_basin
        {
            AL,//North Atlantic 北大西洋
            EP,//Eastern Pacific 东太平洋
            NP,//NorthWest Pacific 西北太平洋
            SP,//SouthWestern Pacific 西南太平洋
            NI,//North Indian 北印度洋
            SI //South Indian 南印度洋
        }
        public string tropical_stormlist(hfx_tropical_basin basin, string year)
        {
            this.host_url = api_host;
            this.api_url = this.host_url + $"/v7/historical/tropical/storm-list?key={this.key}&basin={basin.ToString()}&year={year}";
            return this.api_url;
        }
        public string tropical_stormlist(string basin,string year)
        {
            this.host_url = api_host;
            this.api_url = this.host_url + $"/v7/historical/tropical/storm-list?key={this.key}&basin={basin}&year={year}";
            return this.api_url;
        }
        public string tropical_stormforecast(string stormid)
        {
            this.host_url= api_host;
            //'https://api.qweather.com/v7/tropical/storm-forecast?stormid=NP_2106'
            this.api_url = this.host_url + $"/v7/tropical/storm-forecast?key={this.key}&stormid={stormid}";
            return this.api_url;
        }
        public string tropical_stormtrack(string stormid)
        {
            this.host_url=api_host;
            this.api_url = this.host_url + $"/v7/tropical/storm-track?key={this.key}&stormid={stormid}";
            return this.api_url;
        }
        public string astronomy_sun(string date, string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/sun?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + location;
            this.api_url = this.host_url + $"/v7/astronomy/sun?key={key}&lang=zh&date={date}&location={location}";
            return this.api_url;
        }
        /// <summary>
        /// 收费接口,未来10天全球潮流数据,包括潮流流速和流向。
        /// </summary>
        /// <param name="location">潮流站点或潮汐站点,还有经纬度</param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string ocean_tide(string location,string date)
        {
            this.host_url = api_host;
            this.api_url = this.host_url + $"/v7/ocean/tide?key={key}&lang=zh&date={date}&location={location}";
            return this.api_url;
        }
        public string ocean_currents(string location,string date)
        {
            this.host_url = api_host;
            //'https://api.qweather.com/v7/ocean/currents?location=P66981&date=20210310'
            this.api_url = this.host_url + $"/v7/ocean/currents?key={key}&lang=zh&date={date}&location={location}";
            return this.api_url;
        }
        public string solarradiation_24h(string location)
        {
            this.host_url = api_host;
            //'https://api.qweather.com/v7/solar-radiation/24h?location=116.41,39.92'
            this.api_url = this.host_url + $"/v7/solar-radiation/24h?key={key}&location={location}";
            return this.api_url;
        }
        public string solarradiation_24h(string lon,string lat)
        {
            this.host_url = api_host;
            //'https://api.qweather.com/v7/solar-radiation/24h?location=116.41,39.92'
            this.api_url = this.host_url + $"/v7/solar-radiation/24h?key={key}&location={lon},{lat}";
            return this.api_url;
        }
        public string solarradiation_24h(float lon, float lat)
        {
            this.host_url = api_host;
            //'https://api.qweather.com/v7/solar-radiation/24h?location=116.41,39.92'
            this.api_url = this.host_url + $"/v7/solar-radiation/24h?key={key}&location={lon},{lat}";
            return this.api_url;
        }
        public string solarradiation_72h(string location)
        {
            this.host_url = api_host;
            //'https://api.qweather.com/v7/solar-radiation/72h?location=116.41,39.92'
            this.api_url = this.host_url + $"/v7/solar-radiation/72h?key={key}&location={location}";
            return this.api_url;
        }
        public string solarradiation_72h(string lon,string lat)
        {
            this.host_url = api_host;
            //'https://api.qweather.com/v7/solar-radiation/72h?location=116.41,39.92'
            this.api_url = this.host_url + $"/v7/solar-radiation/72h?key={key}&location={lon},{lat}";
            return this.api_url;
        }
        public string solarradiation_72h(float lon, float lat)
        {
            this.host_url = api_host;
            //'https://api.qweather.com/v7/solar-radiation/72h?location=116.41,39.92'
            this.api_url = this.host_url + $"/v7/solar-radiation/72h?key={key}&location={lon},{lat}";
            return this.api_url;
        }
        /// <summary>
        /// 日出日落
        /// </summary>
        /// <param name="date"></param>
        /// <param name="locationid"></param>
        /// <returns></returns>
        public string astronomy_sun_byid(string date, string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/sun?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/astronomy/sun?key={key}&lang=zh&date={date}&location={locationid}";
            return this.api_url;
        }
        public string astronomy_sun_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/sun?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/astronomy/sun?key={key}&lang=zh&date={DateTime.Now.ToString("yyyyMMdd")}&location={locationid}";
            return this.api_url;
        }
        public string astronomy_sun_byid(int locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/sun?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/astronomy/sun?key={key}&lang=zh&date={DateTime.Now.ToString("yyyyMMdd")}&location={locationid.ToString()}";
            return this.api_url;
        }
        public string astronomy_sun_byposition(string date, string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/sun?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + lng + "," + lat;
            this.api_url = this.host_url + $"/v7/astronomy/sun?key={key}&lang=zh&date={date}&location={lng},{lat}";
            return this.api_url;
        }
        public string astronomy_moon(string date, string location)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/moon?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + location;
            this.api_url = this.host_url + $"/v7/astronomy/moon?key={key}&lang=zh&date={date}&location={location}";
            return this.api_url;
        }
        public string astronomy_moon_byid(string date, string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/moon?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/astronomy/moon?key={key}&lang=zh&date={date}&location={locationid}";
            return this.api_url;
        }
        public string astronomy_moon_byid(string locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/moon?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/astronomy/moon?key={key}&lang=zh&date={DateTime.Now.ToString("yyyMMdd")}&location={locationid}";
            return this.api_url;
        }
        public string astronomy_moon_byid(int locationid)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/moon?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + locationid;
            this.api_url = this.host_url + $"/v7/astronomy/moon?key={key}&lang=zh&date={DateTime.Now.ToString("yyyMMdd")}&location={locationid.ToString()}";
            return this.api_url;
        }
        public string astronomy_moon_byposition(string date, string lng, string lat)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/moon?"
            //  + "key=" + key + "&lang=zh" + "&date=" + date + "&location=" + lng + "," + lat;
            this.api_url = this.host_url + $"/v7/astronomy/moon?key={key}&lang=zh&date={date}&location={lng},{lat}";
            return this.api_url;
        }
        /// <summary>
        /// 太阳高度角,收费应用,仅可使用付费主机。
        /// </summary>
        /// <param name="location"></param>
        /// <param name="date"></param>
        /// <param name="time"></param>
        /// <param name="tz"></param>
        /// <param name="alt"></param>
        /// <returns></returns>
        public string solarangle(string location, string date, string time, string tz, string alt)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/solar-elevation-angle?"
            //  + "key=" + key + "&lang=zh" + "&location=" + location + "&date=" + date + "&time=" + time + "&tz=" + tz + "&alt=" + alt;
            this.host_url=api_host;
            this.api_url = this.host_url + $"/v7/astronomy/solar-elevation-angle?key={key}&lang=zh&location={location}&date={date}&time={time}&tz={tz}&alt={alt}";
            return this.api_url;
        }
        /// <summary>
        /// 太阳高度角,收费应用,仅可使用付费主机。
        /// </summary>
        /// <param name="lng"></param>
        /// <param name="lat"></param>
        /// <param name="date"></param>
        /// <param name="time"></param>
        /// <param name="tz"></param>
        /// <param name="alt"></param>
        /// <returns></returns>
        public string solarangle_byposition(string lng, string lat, string date, string time, string tz, string alt)
        {
            //如果是免费订阅,将上述API Host更改为devapi.qweather.com。
            //string api = "https://devapi.qweather.com/v7/astronomy/solar-elevation-angle?"
            //  + "key=" + key + "&lang=zh" + "&location=" + lng + "," + lat + "&date=" + date + "&time=" + time + "&tz=" + tz + "&alt=" + alt;
            //this.host_url = api_host;
            this.api_url = this.host_url + $"/v7/astronomy/solar-elevation-angle?key={key}&lang=zh&location={lng},{lat}&date={date}&time={time}&tz={tz}&alt={alt}";
            return this.api_url;
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Risehuxyc

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值