{"id":403,"date":"2016-05-03T18:05:04","date_gmt":"2016-05-03T10:05:04","guid":{"rendered":"http:\/\/goyuwei.com\/blog\/?p=403"},"modified":"2016-05-03T19:09:51","modified_gmt":"2016-05-03T11:09:51","slug":"03052016-astronomical-weather-forecast-ver-2-%e5%a4%a9%e6%96%87%e5%a4%a9%e6%b0%94%e9%a2%84%e6%8a%a52-0%e7%89%88","status":"publish","type":"post","link":"https:\/\/goyuwei.com\/blog\/?p=403","title":{"rendered":"03\/05\/2016 \u2013 Astronomical Weather Forecast Ver2.0 \u2013 \u5929\u6587\u5929\u6c14\u9884\u62a52.0\u7248"},"content":{"rendered":"<p style=\"text-align: center;\"><a href=\"http:\/\/goyuwei.com\/blog\/?p=395\" target=\"_blank\">&gt;Astronomical Weather Forecast Dev Log \u2013 \u5929\u6587\u5929\u6c14\u9884\u62a5\u5f00\u53d1\u65e5\u5fd7&lt;<\/a><\/p>\n<hr \/>\n<p>1.0\u7248\u672c\u7531IP\u83b7\u53d6\u7ecf\u7eac\u5ea6\u6ca1\u591a\u5927\u95ee\u9898\uff0c\u4f46\u662f\u767e\u5ea6\u5730\u56feAPI\u53ea\u80fd\u63d0\u4f9b\u4e1c\u4e9a\u5730\u533a\u57ce\u5e02\u7684\u7ecf\u7eac\u5ea6\u4fe1\u606f\uff0c\u7136\u800c\u6674\u5929\u949f\u53ef\u4ee5\u63d0\u4f9b\u5168\u7403\u7edd\u5927\u90e8\u5206\u5730\u533a\u7684\u9884\u62a5\u4fe1\u606f\uff0c\u6240\u4ee5\u4e0d\u592a\u5339\u914d\u3002\u6309\u7167\u6674\u5929\u949f\u4ecb\u7ecd\u4e2d\uff0c\u5176\u672c\u8eab\u6240\u4f7f\u7528\u7684\u7ecf\u7eac\u5ea6\u4fe1\u606f\u4e3b\u8981\u53d6\u81ea\u8c37\u6b4c\u548cGeoIP\u3002\u6211\u51b3\u5b9a\u5c06\u7ecf\u7eac\u5ea6\u4fe1\u606f\u5f15\u64ce\u6362\u6210GeoIP\u3002<\/p>\n<p>Version 1.0 worked well, but it can provide forecast of East Asian cities due to the Baidu Map API area limit. It was a little wasteful for\u00a07Timer!&#8217;s global\u00a0 forecast. Reading from\u00a07Timer!&#8217;s introduction, coordinate resources what it is using are Google and GeoIP. I decided to changed into GeoIP as well.<\/p>\n<p>\u8c03\u7528\u65b9\u6cd5\u4e5f\u4e0d\u590d\u6742\uff0c\u5c31\u662f\u9700\u8981\u524d\u5f80<a href=\"http:\/\/www.maxmind.com\/\" target=\"25_black\">MaxMind<\/a>\u4e0b\u8f7d\u5f00\u6e90\u7684\u5168\u7403\u57ce\u5e02\u5730\u7406\u4fe1\u606f\u5305\uff0c\u7136\u540e\u4e0a\u4f20\u5230\u7f51\u7ad9\u76ee\u5f55\u4e2d\u8fdb\u884c\u8c03\u7528\u3002<\/p>\n<p>It was not\u00a0complicated, all I should do is downloading open source global cities geography data pack and uploading to my website\u00a0directory.<\/p>\n<p>\u5177\u4f53\u8c03\u7528\u8bed\u53e5\u6bd4\u8f83\u7b80\u5355<\/p>\n<p>The data pack function is called by<\/p>\n<p>[php]<\/p>\n<p>$gi = geoip_open(&quot;GeoLiteCity.dat&quot;,GEOIP_STANDARD);<br \/>\n$record = geoip_record_by_addr($gi,$ip);<\/p>\n<p>[\/php]<\/p>\n<p>\u5176\u4e2d\u7684$ip\u5373\u5df2\u7ecf\u83b7\u53d6\u5230\u7684\u8bbf\u95ee\u8005IP\u5730\u5740\u3002\u8c03\u7528\u540e\uff0c\u9700\u8981\u7684\u5730\u5740\u3001\u7ecf\u7eac\u5ea6\u3001\u65f6\u533a\u7b49\u4fe1\u606f\u4ece$record\u4e2d\u63d0\u53d6\u5373\u53ef\u3002<\/p>\n<p>$ip is the IP address fetched from visitor. The address, coordinate and time zone information can be picked out\u00a0after the function is called.<\/p>\n<p>\u5176\u4ed6\u5185\u5bb9\u5e76\u6ca1\u6709\u4ec0\u4e48\u4fee\u6539\u3002<\/p>\n<p>The other parts of the forecast core code has not been changed.<\/p>\n<p>\u4e0d\u8fc7\u4e3a\u4e86\u7b26\u5408GoYuwei.Com\u7684\u300e\u53cc\u8bed\u300f\u7279\u5f81\uff0c\u591a\u5f04\u4e86\u4e2a\u82f1\u6587\u7248\u754c\u9762\u3002\u4e0d\u8fc7\u7531\u4e8e\u5e76\u975e\u4e13\u4e1a\uff0c\u8fd8\u53ea\u80fd\u662f\u4e2d\u3001\u82f1\u53cc\u8bed\u5206\u4e3a\u4e24\u4e2a\u9875\u9762\uff0c\u8fd9\u4e5f\u63d0\u4f9b\u4e86\u5951\u673a\uff0c\u4e0b\u6b21\u53ef\u4ee5\u5b66\u4e60php\u7684\u591a\u8bed\u79cd\u9875\u9762\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n<p>Pages are\u00a0in Chinese&amp;English and GoYuwei.Com is called &#8216;bilingual website&#8217;. I created a English version of the forecast. However, they are in two page files. There will be chance I can learn more about PHP and present the\u00a0bilingual page in one web file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&gt;Astronomical Weather Forecast Dev Log \u2013 \u5929\u6587\u5929\u6c14\u9884\u62a5\u5f00\u53d1\u65e5\u5fd7&#038; &hellip; <a href=\"https:\/\/goyuwei.com\/blog\/?p=403\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">03\/05\/2016 \u2013 Astronomical Weather Forecast Ver2.0 \u2013 \u5929\u6587\u5929\u6c14\u9884\u62a52.0\u7248<\/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],"tags":[],"class_list":["post-403","post","type-post","status-publish","format-aside","hentry","category-astronomy-","category-info-tech-","category-lab-log-","post_format-post-format-aside"],"_links":{"self":[{"href":"https:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/goyuwei.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=403"}],"version-history":[{"count":0,"href":"https:\/\/goyuwei.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/403\/revisions"}],"wp:attachment":[{"href":"https:\/\/goyuwei.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/goyuwei.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/goyuwei.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}