03/05/2016 – Astronomical Weather Forecast Ver2.0 – 天文天气预报2.0版

>Astronomical Weather Forecast Dev Log – 天文天气预报开发日志<


1.0版本由IP获取经纬度没多大问题,但是百度地图API只能提供东亚地区城市的经纬度信息,然而晴天钟可以提供全球绝大部分地区的预报信息,所以不太匹配。按照晴天钟介绍中,其本身所使用的经纬度信息主要取自谷歌和GeoIP。我决定将经纬度信息引擎换成GeoIP。

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 7Timer!’s global  forecast. Reading from 7Timer!’s introduction, coordinate resources what it is using are Google and GeoIP. I decided to changed into GeoIP as well.

调用方法也不复杂,就是需要前往MaxMind下载开源的全球城市地理信息包,然后上传到网站目录中进行调用。

It was not complicated, all I should do is downloading open source global cities geography data pack and uploading to my website directory.

具体调用语句比较简单

The data pack function is called by

[php]

$gi = geoip_open("GeoLiteCity.dat",GEOIP_STANDARD);
$record = geoip_record_by_addr($gi,$ip);

[/php]

其中的$ip即已经获取到的访问者IP地址。调用后,需要的地址、经纬度、时区等信息从$record中提取即可。

$ip is the IP address fetched from visitor. The address, coordinate and time zone information can be picked out after the function is called.

其他内容并没有什么修改。

The other parts of the forecast core code has not been changed.

不过为了符合GoYuwei.Com的『双语』特征,多弄了个英文版界面。不过由于并非专业,还只能是中、英双语分为两个页面,这也提供了契机,下次可以学习php的多语种页面实现方法。

Pages are in Chinese&English and GoYuwei.Com is called ‘bilingual website’. 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 bilingual page in one web file.

01/05/2016 – Astronomical Weather Forecast Dev Log – 天文天气预报开发日志

前期规划日志 Previous Development Plan :

10/02/2016  & 27/02/2016


后续开发日志 Development Update:

03/05/2016


>前往中文预报页面<     >Go to the English forecast page<


以下为主要开发内容 The following is the main content:

由于公差查询器核心已经比较稳定,剩下的主要工作就是利用零碎时间完成公差数据的输入,所以开始着手完成天文天气预报。在研究清楚晴天钟天气图表API的调用方法后,开始着手研究根据访问者IP获取经纬度信息的办法。与公差查询器一样,由于我建站的空间支持php语言,所以天气预报页面也使用php来编写。

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’s not time-consuming to understand how to use 7Timer!’s API, then the method of obtaining coordinate by visitors’IP address must be figured out. The same reason as the tolerance checker, I choose PHP to set up the page due to my website server’s PHP environment.

为了降低初期的学习难度和开发难度,当然也考虑到测试网络环境,地理信息(IP-经纬度转换和地图)的API选用了百度而没有选用谷歌。

For decreasing the study and develop difficulties, and considering about testing web environment, Baidu Map was selected as geography API instead of Google.

首先通过

First, by using

[php]

$_SERVER["REMOTE_ADDR"]

[/php]

来获得访问者IP地址(这也造成一个问题,获取的是设备接入网络服务商时的IP,造成移动设备通过蜂窝网络接入或透过VPN访问的用户提供的IP是不准确的,造成定位错误,不能实现“本地”天气预报)

to obtain visitor’s IP (There’s problem here. Wrong IP will be fetched if the visitor is using mobile devices through cellular network or visiting the web through VPN, because the code can read the Internet service providers’ IP only)

接着将IP提交给百度地理API(可免费申请有限次数的应用,调用方法请参照百度地图API的相关手册),获取json格式的地理信息,包括地址、经纬度等。

Then hand up the IP to Baidu Map API for returning geography data including address and coordinate in json format. Baidu Map API application can be applied for free.

解码返回的地理信息并提取经纬度信息,分别提交给晴天钟的API(调用方法参见晴天钟的手册)和百度地图API,获取天气预报图表和访问者位置地图。

Decode the json and pick out the coordinate, exchange the weather chart and map image by 7Timer!’s API and Baidu Map API.

再给页面稍微美化一下,成品如图1。

Beautify the page, it works! (As Fig.1)

20160501-weatherforecast

图.1(Fig.1)


最后,再次声明利用的资源并鸣谢:

预报图表来源: 晴天钟 – 地理信息引擎: MaxMind GeoIP & 百度地图

Resources used by weather forecast and  acknowledgements

– Weather Chart Resource: 7Timer!

– Geography Resource & API: MaxMind GeoIP & Baidu Map

 

10/04/2016 – Plus-minus Notation Display Failure – 正负号显示问题

>Tolerance Checker Development Log – 极限偏差查询器开发日志<

最近的主要工作室录入极限偏差数据库,一直都进展的比较顺利,但是今天录入到JS/js公差带的时候遇到了一点问题,JS/js带的极限偏差是±值,一般比较便捷的记法就是±x,但是我以此格式录入的数据库最后查询出来发生了错误,显示如图1。

What I am doing recently is recording data, there was no problem until plus-minus notation display failure came out. When I met the JS/js tolerance zone, numbers are displayed  with ‘±’ ahead, which is like ±x. But the plus-minus notation became ‘?’ as Fig.1.

20160410-Plus-minus Notation Display Failure

图.1(Fig.1)

目前我猜测的可能是在查询的某个环节出了问题:

I think it must be an error at following stage:

  1. php excel reader工具不支持正负号;
  2. 字符集对正负号的支持问题;
  3. 查询器默认字体或者字体库的支持问题。
  1. php excel reader does not support plus-minus notation;
  2. character set does not support plus-minus notation;
  3. fonts of the checker/page do not support plus-minus notation.

由于这个问题无伤大雅,我暂时用比较简单的办法略过这个问题:用+/-来代替±。

Nevertheless, it is not a serious error and I decide to replace the ‘±’ with ‘+/-‘ temporarily.

 

D693-77.03-飞虎队队员眼中的中国1944-1945-China in the Eyes of Flying Tigers 1944-1945

出版物封面

Cover of Publication

 

出版物名称

Name of Publication

飞虎队队员眼中的中国1944-1945

China in the Eyes of Flying Tigers 1944-1945

著者 Author (美)艾伦·拉森(H. Allen Larsen)

(美)威廉.迪柏(William L. Dibble)

出版单位 Publisher 上海文化出版社(英文版)/上海锦绣文章出版社(中文版)

Shanghai Culture Publishing House(English Version)

Shanghai Brilliant Publishing House(Chinese Version)

简介

Introduction/ Abstract

书中选录的二百余幅图片,真实记录了飞虎队老战士艾伦.拉森先生和他故去的战友威廉.迪柏先生于1944-1945年期间,在中国所拍摄到的当时中国和中国人民的珍贵画面,以及他们与中国人民共同战斗的难忘经历。这些具有重要文献价值的珍贵历史照片,足以填补中国抗战历史时期彩色摄影的空白,更重要的是,它们展现了中美两国人民当年在面对共同的敌人日本法西斯侵略时,同仇敌忾,并肩战斗,谱写友谊的一段光荣历史。

The book is a photography collection shot by flying tigers during 1944-1945, and it records the actual historical pictures of china and Chinese people as well as their unforgettable memory with Chinese people fighting together. These pictures reflect Chinese society at that special period in the eyes of especial people, and have a higher historical value.

个人书评

Personal Book Review

绝大部分男孩都对军事和历史充满兴趣,比如我就一直经常了解关于二战的历史和故事。中美两国作为二战中的主要参战国以及盟国,曾经产生出许多令人敬佩的故事,这就包括美国援华飞行队——飞虎队的故事。飞虎队的故事可以讲上不止知三天三夜,但与飞虎队有关的相册集锦往往能做到一图胜前言,这本书就是一个历史讲述者,让读者从一个方面了解战争的残酷,人性的光辉,历史的瞬间。

Most boys have a similar habit on military and history. For me, I still keep my interest in WWII stories. China and United State are both main countries and allies fought together in the terrible decades, honorable events and people were shining in those years, including Flying Tigers, the American Volunteer Group. Details of them can be written with millions of words on thousands of pages, but photos taken by the participants will tell the readers with truth, about the moments in history, the cruelties of war, and the glory of human nature.

ISBN/ISSN 9787807407676 (English Version)

9787545204995(中文版)

出版日期

Date of Publication

2010年4月1日(中文版)

June 1, 2012(English Version)

出版地

Place of Publication

上海

Shanghai

中图分类号

CLC Code

D693.9-64 中图法分类名称

CLC Category

社会生活-中国-1944~1945-摄影集
国际十进分类号

UDC Code

77.03 国际十进分类名称

UDC Category

Documentary photography. Photographic records and their interpretation;

纪录片摄影、摄影记录及其解读

 

书刊定价

Price of Publication

CNY48.00

USD72.11

书刊语言

Language

简体中文

English

购买正版

Purchase of Authorized Edition

 Amazon.com(US)

Amazon.cn

17/03/2016 – Tolerance Checker Development Log– 极限偏差查询器开发日志

前期规划日志 Previous Development Plan :

>10/02/2016<

>08/03/2016<


后续开发日志 Development Update:

>10/04/2016<


>前往查询器 Use the checker<

以下为主要开发内容 The following is the main content:

近几日完成了查询器的主要开发工作并上线测试。

Main development work has been finished on these days, and the tolerance checker has been launched into beta test.

首先是确认了需要使用的php excel reader工具,资源来自SourceForge上的一个项目:<PHP-ExcelReader> ;调用方法参考了搜索到的这篇日志:<PHP ExcelReader用法>

First, excel reader tool has been selected. It is a SourceForge project:<PHP-ExcelReader>, and I find a Chinese user manual by this link:<PHP ExcelReader用法>

其调用方法是:

How to invoke the PHP-ExcelReader:

[php]
require_once ‘Excel/reader.php’;
$data = new Spreadsheet_Excel_Reader(); /*invoking reader*/
$data->setOutputEncoding(‘UTF-8’); /*text output encoding*/
$data->read(‘db.xls’); /*read the excel sheet*/

echo $data->sheets[0][‘cells’][i][j]; /*read the (i,j)cell
and output data*/
[/php]

这个基本结构是针对查固定路径的单个excel表格的,我先编写了一个3行3列excel表格进行测试,表单通过post形式将需要的单元格位置(i,j)将表单信息告知excel_reader,reader返回查询数据:

The basic code structure of this tool is used to read a single work sheet in one .xls file by solid path. So I created a 3*3 excel sheet for test. Html form choices with (i,j) cell position are sent to excel_reader by ‘post’ method, which would return and print out the checking result by code below.

[php]

echo $data->sheets[0][‘cells’][$_POST["row"]][$_POST["column"]];

[/php]

测试结果如图1, 成功!进入下一步开发。

Test was successful as fig.1! Next step.

20160317-checker_devlop_log-1

图.1(Fig.1)

根据日志>2<中图2的逻辑与文件结构,需要查询不同路径下不同xls的文件,路径由表单输出的数据决定,所以excel_reader读取路径处不能再填写定值,故在这之前定义了一个变量$path, 同样采取post的形式获取表单数据并编写路径,然后让reader读取$path路径:

According to logic and files structure posted on fig.2 of log >2< , the checker must visit different folders and pick out the exact .xls database file from dozens of them. In other words, the file path and the name of file should be variables. So I define a $path variable which get message from the form by post method as well. And the reader will read the $path instead of solid path.

[php]

$path="db/".$_POST["type"]."/".$_POST["zone"].".xls";

……

$data->read($path);

[/php]

由于我只在一个文件夹里存放了一个db.xls文件,当我在表单选择了一个空路径的时候或者我没有填写完所有表单项却提交了表单,reader返回了”The filename …….xls is not readable”的错误信息,我意识到整个单选表单必须填写完成才能提交。搜索了许多方法,一开始发现需要通过js等工具进行表单验证,弹出提醒框等等等。踏破铁鞋无觅处得来全不费工夫,html5直接提供了表单必填的验证,在input里添上短短一句便可:

I uploaded only one db.xls file to the database folder, then I found a problem when I select a wrong path or leave some form blank —— reader told me that ‘The filename …….xls is not readable’. And I realized I must set something for form correction. So many methods told me to use js code or else when the exactly excellent answer is so simple that you should write only 2 word in the <input>, thanks to html5 :

[html]

required="required"

[/html]

剩下的就让浏览器来做就好了,如图2

The rest of the work? Browsers will do for you as fig.2!

20160317-checker_devlop_log-2

图.2(Fig.2)

显然,如上图,我用div把表单框起来并稍微美化了一下。

Obviously, I beautified the page by <div> tag.

主要的问题都解决了,就把表单修改为正式的极限偏差查询器项目,然后上传了一个完整数据的.xls数据表,极限偏差查询器正式进入线上beta测试!

Works done and problems solved. The html form was changed into real tolerance checker type. And I uploaded the first database .xls file with useful tolerance data. It is beta test now!

20160317-checker_devlop_log-3

下一阶段的工作目标:

Plan for next version:

  1. 由于我获得的极限偏差表是纸质的,所以所有数据必须手动创建.xls文件,需要实现公差查询的基本功能,这个是主要任务也是工作量最大的任务。
  2. 学会一些CSS的内容,将查询器美化一下。
  3. 学会一些Jquery、ajax的内容,将跳转显示查询结果改为在主页刷新显示查询结果,即客户端只需要显示index,同时包含表单和查询结果显示框,表单不断复用。
  1. Tolerance data I own is on papers. If the tolerance can function as a real one, I must type the data into computer by hand and edit .xls files manually. Hard work but necessary.
  2. Learn something about CSS and use it to beatify the checker’s page.
  3. Learn something about Jquery, ajax or else. The codes can refresh the checker index page without jumping into others. Which means, the index contain the html form and the result display on same page, visitor can reuse the form and read the result on same page, without clicking “Back to index and check again”.