程序员人生 网站导航

全网、全国最好用的基于经纬度的天气查询、天气预报接口

栏目:互联网时间:2014-11-11 09:01:16
      大家好,我们是中国科学院资源与环境信息系统国家重点实验室的人员(学生)。在软件开发进程中,我们发现,传统获得天气信息的接口大多是基于所谓的天气码,数据源大多来自中国国家气象局;随着移动http://www.wfuyu.com/Internet/的快速发展,大家都希望通过经纬度查询天气信息。
       最开始我们搜索全网,发现谷歌提供了利用经纬度获得天气信息的接口,但是1测试发现,由于“你懂的”缘由,它已没法使用了。国内IT3哥――百度貌似也提供了这么1个接口,但是又是需要神马key啊,验证文件啊等等1堆手续;而且它还限制每天的单个IP的访问次数,更让人讨厌的是,它只提供3天的天气预报信息。其他的接口大多数是通过使人深恶痛绝的天气码获得,基本都不好用。
       我们本着逢山开路,遇水叠桥的精神,痛下决心,利用了点我们实验室所谓的强项――GIS技术,自己制作了天气预报,天气查询接口。天气查询接口支持全国任何地区的天气信息查询,数据精确到区县级别。天气预报接口提供5天以内的天气预报信息。

       下面介绍1下天气接口和其使用方法。天气查询接口为:

http://www.missfeng.com/iserver/services/GetOverallWeatherComponent/restjsr/GetOverallWeather

/"longitude"/"latitude".rjson。这个接口的访问方式为HttpGet,接口中只有两个参数"longitude"和"latitude",替换成你定位取得的经纬度便可。例如:    http://www.missfeng.com/iserver/services/GetOverallWeatherComponent/restjsr/GetOverallWeather/116.3/40.rjson获得的是北京海淀区的天气信息。这个接口要求返回的是1个json,json的格式为:{"weatherinfo":{"city":"海淀","cityid":"101010200","temp1":"14℃","temp2":"9℃","weather":"小雨转阴","img1":"d7.gif","img2":"n2.gif","ptime":"08:00","temp":"12","WD":"北风","WS":"0级","SD":"86%","WSE":"0","time":"09:35","isRadar":"1","Radar":"JC_RADAR_AZ9010_JB","njd":"暂无实况","qy":"1018"}}

         其中:weatherinfo代表天气信息,city代表所在地,cityid是中国气象局给全国县市的编码,temp1代表当地当日最高气温,temp2代表当日当地最低气温,weather代表当日天气状态,img1代表白每天气状态的图标,img2代表夜晚天气状态的图标,图片资源的访问地址为http://m.weather.com.cn/img/d7.gif,其中d7.gif为获得的img;ptime为天气信息发布的时间,temp为发布时的气温,WD为风向,WS为风级,SD为湿度,WSE为风力,time代表雷达图更新时间,isRadar代表是不是有雷达图,Radar代表雷达图的访问地址,njd为能见度信息,qy为当前气压信息。

        天气预报接口为:http://www.missfeng.com/iserver/services/GetDetailedWeatherComponent/restjsr

/GetDetailedWeather/"longitude"/"latitude".rjson,其中"longitude"/"latitude"分别为经度、纬度参数例如:

 http://www.missfeng.com/iserver/services/GetDetailedWeatherComponent/restjsr/GetDetailedWeather/118.3/37.1.rjson。返回的json为:

 ({"time":1414719933,"area":[["山东","12"],["滨州","1211"],["博兴","101121102"]],"weather":[{"date":"2014⑴0⑶1","info":{"day":["7","小雨","18","东北风","微风"],"night":["7","小雨","11","东风","微风"]}},{"date":"2014⑴1-01","info":{"dawn":["7","小雨","11","东风","微风"],"day":["7","小雨","16","西北风","微风"],"night":["7","小雨","9","西北风","3⑷ 级"]}},{"date":"2014⑴1-02","info":{"dawn":["7","小雨","9","西北风","3⑷ 级"],"day":["1","多云","14","西北风","3⑷ 级"],"night":["0","晴","5","西北风","微风"]}},{"date":"2014⑴1-03","info":{"dawn":["0","晴","5","西北风","微风"],"day":["0","晴","17","无延续风向","微风"],"night":["0","晴","5","无延续风向","微风"]}},{"date":"2014⑴1-04","info":{"dawn":["0","晴","5","无延续风向","微风"],"day":["0","晴","18","无延续风向","微风"],"night":["1","多云","8","无延续风向","微风"]}}],"pm25":[]});   
        其中area代表当前的区域,weather代表当前的天气信息,天气信息由day 白天;night 夜晚;和dawn傍晚信息组成,单个信息块里是最低温度,天气,风向,风级的格式,比方["7","小雨","11","东风","微风"]分别是最低温度为7度,天气为小雨,风向为东风,风级为微风。
       以上就是我们提供的天气查询和天气预报接口的介绍和使用方法。如果您有任何疑问欢迎向czgbjy@yeah.net邮箱询问,也能够通过QQ:2649615105询问。
      由于我们的http://www.wfuyu.com/server/是架设在阿里云上,每一年http://www.wfuyu.com/server/的使用费用都比较高,而我们是1群科研
------分隔线----------------------------
------分隔线----------------------------

最新技术推荐