{"id":395,"date":"2016-05-01T14:48:41","date_gmt":"2016-05-01T06:48:41","guid":{"rendered":"http:\/\/goyuwei.com\/blog\/?p=395"},"modified":"2016-05-03T18:40:33","modified_gmt":"2016-05-03T10:40:33","slug":"28042016-astronomical-weather-forecast-dev-log-%e5%a4%a9%e6%96%87%e5%a4%a9%e6%b0%94%e9%a2%84%e6%8a%a5%e5%bc%80%e5%8f%91%e6%97%a5%e5%bf%97","status":"publish","type":"post","link":"http:\/\/goyuwei.com\/blog\/?p=395","title":{"rendered":"01\/05\/2016 \u2013 Astronomical Weather Forecast Dev Log \u2013 \u5929\u6587\u5929\u6c14\u9884\u62a5\u5f00\u53d1\u65e5\u5fd7"},"content":{"rendered":"<p style=\"text-align: center;\">\u524d\u671f\u89c4\u5212\u65e5\u5fd7 Previous\u00a0Development Plan \uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/goyuwei.com\/blog\/?p=297\" target=\"_blank\">10\/02\/2016<\/a>\u00a0 &amp; <a href=\"http:\/\/goyuwei.com\/blog\/?p=316\" target=\"_blank\">27\/02\/2016<\/a><\/p>\n<hr \/>\n<p style=\"text-align: center;\">\u540e\u7eed\u5f00\u53d1\u65e5\u5fd7 Development Update\uff1a<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/goyuwei.com\/blog\/?p=403\" target=\"_blank\">03\/05\/2016<\/a><\/p>\n<hr \/>\n<p style=\"text-align: center;\"><a href=\"http:\/\/goyuwei.com\/lab\/astronomy\/weather_forecast\/\" target=\"_blank\">&gt;\u524d\u5f80\u4e2d\u6587\u9884\u62a5\u9875\u9762&lt;<\/a>\u00a0 \u00a0\u00a0 <a href=\"http:\/\/goyuwei.com\/lab\/astronomy\/weather_forecast\/index_en.php\" target=\"_blank\">&gt;Go to the English forecast page&lt;<\/a><\/p>\n<hr \/>\n<p>\u4ee5\u4e0b\u4e3a\u4e3b\u8981\u5f00\u53d1\u5185\u5bb9 The following is the main content\uff1a<\/p>\n<p>\u7531\u4e8e\u516c\u5dee\u67e5\u8be2\u5668\u6838\u5fc3\u5df2\u7ecf\u6bd4\u8f83\u7a33\u5b9a\uff0c\u5269\u4e0b\u7684\u4e3b\u8981\u5de5\u4f5c\u5c31\u662f\u5229\u7528\u96f6\u788e\u65f6\u95f4\u5b8c\u6210\u516c\u5dee\u6570\u636e\u7684\u8f93\u5165\uff0c\u6240\u4ee5\u5f00\u59cb\u7740\u624b\u5b8c\u6210\u5929\u6587\u5929\u6c14\u9884\u62a5\u3002\u5728\u7814\u7a76\u6e05\u695a\u6674\u5929\u949f\u5929\u6c14\u56fe\u8868API\u7684\u8c03\u7528\u65b9\u6cd5\u540e\uff0c\u5f00\u59cb\u7740\u624b\u7814\u7a76\u6839\u636e\u8bbf\u95ee\u8005IP\u83b7\u53d6\u7ecf\u7eac\u5ea6\u4fe1\u606f\u7684\u529e\u6cd5\u3002\u4e0e\u516c\u5dee\u67e5\u8be2\u5668\u4e00\u6837\uff0c\u7531\u4e8e\u6211\u5efa\u7ad9\u7684\u7a7a\u95f4<del>\u4ec5<\/del>\u652f\u6301php\u8bed\u8a00\uff0c\u6240\u4ee5\u5929\u6c14\u9884\u62a5\u9875\u9762\u4e5f\u4f7f\u7528php\u6765\u7f16\u5199\u3002<\/p>\n<p>The core of the tolerance checker has been stable, the rest work is typing the tolerance data which can be done in spare time. I can turn to develop the astronomical weather forecast now. It&#8217;s not time-consuming to understand how to use\u00a07Timer!&#8217;s API, then the method of obtaining coordinate by visitors&#8217;IP address must be figured out. The same reason as the\u00a0tolerance checker, I choose PHP to set up the page due to my website server&#8217;s PHP environment.<\/p>\n<p>\u4e3a\u4e86\u964d\u4f4e\u521d\u671f\u7684\u5b66\u4e60\u96be\u5ea6\u548c\u5f00\u53d1\u96be\u5ea6\uff0c\u5f53\u7136\u4e5f\u8003\u8651\u5230\u6d4b\u8bd5\u7f51\u7edc\u73af\u5883\uff0c\u5730\u7406\u4fe1\u606f\uff08IP-\u7ecf\u7eac\u5ea6\u8f6c\u6362\u548c\u5730\u56fe\uff09\u7684API\u9009\u7528\u4e86\u767e\u5ea6\u800c\u6ca1\u6709\u9009\u7528\u8c37\u6b4c\u3002<\/p>\n<p>For decreasing the study and develop difficulties, and considering about testing web environment, Baidu Map was selected as geography API instead of Google.<\/p>\n<p>\u9996\u5148\u901a\u8fc7<\/p>\n<p>First, by using<\/p>\n<p>[php]<\/p>\n<p>$_SERVER[&quot;REMOTE_ADDR&quot;]<\/p>\n<p>[\/php]<\/p>\n<p>\u6765\u83b7\u5f97\u8bbf\u95ee\u8005IP\u5730\u5740\uff08\u8fd9\u4e5f\u9020\u6210\u4e00\u4e2a\u95ee\u9898\uff0c\u83b7\u53d6\u7684\u662f\u8bbe\u5907\u63a5\u5165\u7f51\u7edc\u670d\u52a1\u5546\u65f6\u7684IP\uff0c\u9020\u6210\u79fb\u52a8\u8bbe\u5907\u901a\u8fc7\u8702\u7a9d\u7f51\u7edc\u63a5\u5165\u6216\u900f\u8fc7VPN\u8bbf\u95ee\u7684\u7528\u6237\u63d0\u4f9b\u7684IP\u662f\u4e0d\u51c6\u786e\u7684\uff0c\u9020\u6210\u5b9a\u4f4d\u9519\u8bef\uff0c\u4e0d\u80fd\u5b9e\u73b0\u201c\u672c\u5730\u201d\u5929\u6c14\u9884\u62a5\uff09<\/p>\n<p>to obtain visitor&#8217;s IP (There&#8217;s problem here. Wrong IP will be fetched if the visitor is using mobile devices through cellular network\u00a0or visiting the web through VPN, because the code can read the Internet service providers&#8217; IP only)<\/p>\n<p>\u63a5\u7740\u5c06IP\u63d0\u4ea4\u7ed9\u767e\u5ea6\u5730\u7406API\uff08\u53ef\u514d\u8d39\u7533\u8bf7\u6709\u9650\u6b21\u6570\u7684\u5e94\u7528\uff0c\u8c03\u7528\u65b9\u6cd5\u8bf7\u53c2\u7167\u767e\u5ea6\u5730\u56feAPI\u7684\u76f8\u5173\u624b\u518c\uff09\uff0c\u83b7\u53d6json\u683c\u5f0f\u7684\u5730\u7406\u4fe1\u606f\uff0c\u5305\u62ec\u5730\u5740\u3001\u7ecf\u7eac\u5ea6\u7b49\u3002<\/p>\n<p>Then hand up the IP to Baidu Map API for returning geography data including address and coordinate in json format.\u00a0Baidu Map API application can be applied for free.<\/p>\n<p>\u89e3\u7801\u8fd4\u56de\u7684\u5730\u7406\u4fe1\u606f\u5e76\u63d0\u53d6\u7ecf\u7eac\u5ea6\u4fe1\u606f\uff0c\u5206\u522b\u63d0\u4ea4\u7ed9\u6674\u5929\u949f\u7684API\uff08\u8c03\u7528\u65b9\u6cd5\u53c2\u89c1\u6674\u5929\u949f\u7684\u624b\u518c\uff09\u548c\u767e\u5ea6\u5730\u56feAPI\uff0c\u83b7\u53d6\u5929\u6c14\u9884\u62a5\u56fe\u8868\u548c\u8bbf\u95ee\u8005\u4f4d\u7f6e\u5730\u56fe\u3002<\/p>\n<p>Decode the json and pick out\u00a0the\u00a0coordinate, exchange the weather chart and map image by\u00a07Timer!&#8217;s API and Baidu Map API.<\/p>\n<p>\u518d\u7ed9\u9875\u9762\u7a0d\u5fae\u7f8e\u5316\u4e00\u4e0b\uff0c\u6210\u54c1\u5982\u56fe1\u3002<\/p>\n<p>Beautify the page, it works! (As Fig.1)<\/p>\n<p><a href=\"http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/05\/20160501-weatherforecast.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-399 aligncenter\" src=\"http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/05\/20160501-weatherforecast.jpg\" alt=\"20160501-weatherforecast\" width=\"1358\" height=\"682\" srcset=\"http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/05\/20160501-weatherforecast.jpg 1358w, http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/05\/20160501-weatherforecast-300x151.jpg 300w, http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/05\/20160501-weatherforecast-768x386.jpg 768w, http:\/\/goyuwei.com\/blog\/wp-content\/uploads\/2016\/05\/20160501-weatherforecast-1024x514.jpg 1024w\" sizes=\"auto, (max-width: 1358px) 100vw, 1358px\" \/><\/a><\/p>\n<p style=\"text-align: center;\">\u56fe.1(Fig.1)<\/p>\n<hr \/>\n<p style=\"text-align: center;\">\u6700\u540e\uff0c\u518d\u6b21\u58f0\u660e\u5229\u7528\u7684\u8d44\u6e90\u5e76\u9e23\u8c22\uff1a<\/p>\n<p style=\"text-align: center;\">\u9884\u62a5\u56fe\u8868\u6765\u6e90: <a href=\"http:\/\/202.127.24.18\/about.php?lang=zh-CN\" target=\"20_black\">\u6674\u5929\u949f<\/a> &#8211; \u5730\u7406\u4fe1\u606f\u5f15\u64ce: <a href=\"http:\/\/www.maxmind.com\/\" target=\"25_black\">MaxMind GeoIP <\/a>&amp; <a href=\"http:\/\/lbsyun.baidu.com\/index.php?title=webapi\" target=\"26_black\">\u767e\u5ea6\u5730\u56fe<\/a><\/p>\n<p style=\"text-align: center;\">Resources used by weather forecast and \u00a0acknowledgements<\/p>\n<p style=\"text-align: center;\">&#8211; Weather Chart Resource: <a href=\"http:\/\/202.127.24.18\/about.php?lang=en\" target=\"20_black\">7Timer!<\/a> &#8211;<\/p>\n<p style=\"text-align: center;\">&#8211; Geography Resource &amp; API: <a href=\"http:\/\/www.maxmind.com\/\" target=\"25_black\">MaxMind GeoIP <\/a>&amp; <a href=\"http:\/\/lbsyun.baidu.com\/index.php?title=webapi\" target=\"26_black\">Baidu Map<\/a> &#8211;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u671f\u89c4\u5212\u65e5\u5fd7 Previous\u00a0Development Plan \uff1a 10\/02\/2016\u00a0 &amp; 27 &hellip; <a href=\"http:\/\/goyuwei.com\/blog\/?p=395\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">01\/05\/2016 \u2013 Astronomical Weather Forecast Dev Log \u2013 \u5929\u6587\u5929\u6c14\u9884\u62a5\u5f00\u53d1\u65e5\u5fd7<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"footnotes":""},"categories":[20,5,21,3],"tags":[],"class_list":["post-395","post","type-post","status-publish","format-aside","hentry","category-astronomy-","category-info-tech-","category-lab-log-","category-site-construction-","post_format-post-format-aside"],"_links":{"self":[{"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=395"}],"version-history":[{"count":0,"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/395\/revisions"}],"wp:attachment":[{"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=395"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/goyuwei.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}