├── www
├── 232824201.lock
├── 232833288.lock
├── 232834270.lock
├── 232835115.lock
├── 232838131.lock
├── 232824201-memory.js
├── 232833288-memory.js
├── 232834270-memory.js
├── 232835115-memory.js
├── 232838131-memory.js
├── ko-rock.txt
├── ou-toyo.txt
├── wkym.txt
├── ku-yos.txt
├── minopu.html
├── shizuoka.html
├── ibaraki.html
├── private.html
├── roppongi.html
├── tokyo-shinagawa.html
├── wakayama.html
├── hyogo.html
├── chiba.html
├── osaka.html
├── kyoto.html
├── tokyo.html
├── minopu.js
├── kobe-kei.js
└── kyoto-krp.js
├── README.md
├── src
├── sample
│ ├── flow.png
│ ├── kinki0120110527T1920_detail.png
│ ├── kinki0120110527T1925_detail.png
│ ├── kinki0120110527T1930_detail.png
│ ├── kinki0120110527T1935_detail.png
│ ├── kinki0120110527T1940_detail.png
│ ├── kinki0120110527T1920_detail.png.gif
│ ├── kinki0120110527T1925_detail.png.gif
│ ├── kinki0120110527T1930_detail.png.gif
│ ├── kinki0120110527T1935_detail.png.gif
│ └── kinki0120110527T1940_detail.png.gif
├── Makefile
├── lib
│ ├── oauth.php
│ ├── location.php
│ └── location.php.encrypted
├── forecast.php
├── misc.hpp
├── twitter.php
├── image.hpp
├── radar-diff.cpp
├── twitter.php.encrypted
└── radar-convert.cpp
└── .gitignore
/www/232824201.lock:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/www/232833288.lock:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/www/232834270.lock:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/www/232835115.lock:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/www/232838131.lock:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/www/232824201-memory.js:
--------------------------------------------------------------------------------
1 | {"footer":"#osaka","per":811467}
--------------------------------------------------------------------------------
/www/232833288-memory.js:
--------------------------------------------------------------------------------
1 | {"footer":"#kyoto","per":811467}
--------------------------------------------------------------------------------
/www/232834270-memory.js:
--------------------------------------------------------------------------------
1 | {"per":811467,"footer":"#kobe"}
--------------------------------------------------------------------------------
/www/232835115-memory.js:
--------------------------------------------------------------------------------
1 | {"per":811467,"footer":"#tokyo"}
--------------------------------------------------------------------------------
/www/232838131-memory.js:
--------------------------------------------------------------------------------
1 | {"per":811467,"footer":"#wakayama"}
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # rainynine
2 | To preserve programs as historical material
3 |
--------------------------------------------------------------------------------
/src/sample/flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imos/rainynine/master/src/sample/flow.png
--------------------------------------------------------------------------------
/src/sample/kinki0120110527T1920_detail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imos/rainynine/master/src/sample/kinki0120110527T1920_detail.png
--------------------------------------------------------------------------------
/src/sample/kinki0120110527T1925_detail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imos/rainynine/master/src/sample/kinki0120110527T1925_detail.png
--------------------------------------------------------------------------------
/src/sample/kinki0120110527T1930_detail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imos/rainynine/master/src/sample/kinki0120110527T1930_detail.png
--------------------------------------------------------------------------------
/src/sample/kinki0120110527T1935_detail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imos/rainynine/master/src/sample/kinki0120110527T1935_detail.png
--------------------------------------------------------------------------------
/src/sample/kinki0120110527T1940_detail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imos/rainynine/master/src/sample/kinki0120110527T1940_detail.png
--------------------------------------------------------------------------------
/src/sample/kinki0120110527T1920_detail.png.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imos/rainynine/master/src/sample/kinki0120110527T1920_detail.png.gif
--------------------------------------------------------------------------------
/src/sample/kinki0120110527T1925_detail.png.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imos/rainynine/master/src/sample/kinki0120110527T1925_detail.png.gif
--------------------------------------------------------------------------------
/src/sample/kinki0120110527T1930_detail.png.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imos/rainynine/master/src/sample/kinki0120110527T1930_detail.png.gif
--------------------------------------------------------------------------------
/src/sample/kinki0120110527T1935_detail.png.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imos/rainynine/master/src/sample/kinki0120110527T1935_detail.png.gif
--------------------------------------------------------------------------------
/src/sample/kinki0120110527T1940_detail.png.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imos/rainynine/master/src/sample/kinki0120110527T1940_detail.png.gif
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files
2 | *.slo
3 | *.lo
4 | *.o
5 | *.obj
6 |
7 | # Precompiled Headers
8 | *.gch
9 | *.pch
10 |
11 | # Compiled Dynamic libraries
12 | *.so
13 | *.dylib
14 | *.dll
15 |
16 | # Fortran module files
17 | *.mod
18 |
19 | # Compiled Static libraries
20 | *.lai
21 | *.la
22 | *.a
23 | *.lib
24 |
25 | # Executables
26 | *.exe
27 | *.out
28 | *.app
29 |
--------------------------------------------------------------------------------
/src/Makefile:
--------------------------------------------------------------------------------
1 | CXX=g++
2 | CXXFLAGS=-O3 -g -Wall
3 | DEFINES=-DNDEBUG -DOPTIMIZE
4 | CPPCOMPILE=$(CXX) $(CXXFLAGS) $(DEFINES)
5 | commands=opticalflow opticalflow-openmp radar-convert radar-diff
6 |
7 | all: $(addprefix ~/bin/,$(commands))
8 | clean:
9 | rm $(addprefix ~/bin/,$(commands))
10 | ~/bin/%-openmp: %.cpp misc.hpp
11 | $(CPPCOMPILE) -o $@ $(filter %.cpp,$<) -fopenmp
12 | ~/bin/%: %.cpp misc.hpp
13 | $(CPPCOMPILE) -o $@ $(filter %.cpp,$<)
14 | misc.hpp: image.hpp
15 |
--------------------------------------------------------------------------------
/www/ko-rock.txt:
--------------------------------------------------------------------------------
1 | http://chart.apis.google.com/chart?cht=lc&chs=1000x250&chtt=%E7%A5%9E%E6%88%B8%E5%A4%A7%E5%AD%A6%E5%85%AD%E7%94%B2%E5%8F%B0%E3%82%AD%E3%83%A3%E3%83%B3%E3%83%91%E3%82%B9%E3%81%AB%E3%81%8A%E3%81%91%E3%82%8B%E9%99%8D%E6%B0%B4%E7%A2%BA%E7%8E%87&chg=12.5,25,1,5&chxt=x,y&chco=55AAFF&chm=B,99FFFF,0,0,0|B,003399,1,0,0|B,339900,2,0,0|B,FFFF00,3,0,0|B,D98D40,4,0,0|B,FF0000,5,0,0|B,9900CC,6,0,0|V,FF0000,0,5.6:5.6,2&chxl=0:|19:09|19:19|19:29|19:39|19:49|1:|0%25|25%25|50%25|75%25|100%25&chd=t:0,0,0,0,0,0,0,0,0,3,5,10,13,17,21,29,32,39,80,87,90,90,92,94,93,93,92,92,92,92,91,93,91,94,91,92,92,93,92,92,92,91,90,90,91,91|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2 |
--------------------------------------------------------------------------------
/www/ou-toyo.txt:
--------------------------------------------------------------------------------
1 | http://chart.apis.google.com/chart?cht=lc&chs=1000x250&chtt=%E5%A4%A7%E9%98%AA%E5%A4%A7%E5%AD%A6%E8%B1%8A%E4%B8%AD%E3%82%AD%E3%83%A3%E3%83%B3%E3%83%91%E3%82%B9%E3%81%AB%E3%81%8A%E3%81%91%E3%82%8B%E9%99%8D%E6%B0%B4%E7%A2%BA%E7%8E%87&chg=12.5,25,1,5&chxt=x,y&chco=55AAFF&chm=B,99FFFF,0,0,0|B,003399,1,0,0|B,339900,2,0,0|B,FFFF00,3,0,0|B,D98D40,4,0,0|B,FF0000,5,0,0|B,9900CC,6,0,0|V,FF0000,0,5.6:5.6,2&chxl=0:|19:09|19:19|19:29|19:39|19:49|1:|0%25|25%25|50%25|75%25|100%25&chd=t:100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,99,99,98,99,99,98,98,98,97,97,98,97,96,96,96,95,95,95,94,94,93,93,91,91,88,83,75,68|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2 |
--------------------------------------------------------------------------------
/www/wkym.txt:
--------------------------------------------------------------------------------
1 | http://chart.apis.google.com/chart?cht=lc&chs=1000x250&chtt=%E5%92%8C%E6%AD%8C%E5%B1%B1%E5%A4%A7%E5%AD%A6%E3%81%AB%E3%81%8A%E3%81%91%E3%82%8B%E9%99%8D%E6%B0%B4%E7%A2%BA%E7%8E%87&chg=12.5,25,1,5&chxt=x,y&chco=55AAFF&chm=B,99FFFF,0,0,0|B,003399,1,0,0|B,339900,2,0,0|B,FFFF00,3,0,0|B,D98D40,4,0,0|B,FF0000,5,0,0|B,9900CC,6,0,0|V,FF0000,0,5.6:5.6,2&chxl=0:|19:09|19:19|19:29|19:39|19:49|1:|0%25|25%25|50%25|75%25|100%25&chd=t:100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100|1,0,0,0,0,0,0,0,0,0,1,1,5,14,67,78,77,34,18,20,22,27,40,77,84,81,59,36,20,16,12,11,11,11,10,10,10,10,10,10,8,9,8,8,9,7|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2 |
--------------------------------------------------------------------------------
/www/ku-yos.txt:
--------------------------------------------------------------------------------
1 | http://chart.apis.google.com/chart?cht=lc&chs=1000x250&chtt=%E4%BA%AC%E9%83%BD%E5%A4%A7%E5%AD%A6%E5%90%89%E7%94%B0%E3%82%AD%E3%83%A3%E3%83%B3%E3%83%91%E3%82%B9%E3%81%AB%E3%81%8A%E3%81%91%E3%82%8B%E9%99%8D%E6%B0%B4%E7%A2%BA%E7%8E%87&chg=12.5,25,1,5&chxt=x,y&chco=55AAFF&chm=B,99FFFF,0,0,0|B,003399,1,0,0|B,339900,2,0,0|B,FFFF00,3,0,0|B,D98D40,4,0,0|B,FF0000,5,0,0|B,9900CC,6,0,0|V,FF0000,0,5.6:5.6,2&chxl=0:|19:09|19:19|19:29|19:39|19:49|1:|0%25|25%25|50%25|75%25|100%25&chd=t:100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,99,99,99,99|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
2 |
--------------------------------------------------------------------------------
/www/minopu.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
45 |
46 |
47 |
48 | つくばみのぷう動物病院における降水確率
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/www/shizuoka.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
45 |
46 |
47 |
48 | 山喜旅館における降水確率
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/www/ibaraki.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
45 |
46 |
47 |
48 | 茨城県つくばにおける降水確率
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/www/private.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
45 |
46 |
47 |
48 | 東大阪における降水確率
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/www/roppongi.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ないんたん天気予報@六本木ヒルズ
6 |
7 |
8 |
46 |
47 |
48 |
49 | 六本木ヒルズにおける降水確率
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/www/tokyo-shinagawa.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ないんたん天気予報@品川駅
6 |
7 |
8 |
46 |
47 |
48 |
49 | 品川駅における降水確率
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/www/wakayama.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
49 |
50 |
51 |
52 | 和歌山大学における降水確率
53 |
54 |
55 |
56 | 和歌山市駅における降水確率
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/www/hyogo.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
49 |
50 |
51 |
52 | 神戸大学六甲キャンパスにおける降水確率
53 |
54 |
55 |
56 | 次世代スーパーコンピュータ京における降水確率
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/www/chiba.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
49 |
50 |
51 |
52 | 東京大学柏キャンパスにおける降水確率
53 |
54 |
55 |
56 | 幕張における降水確率
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/www/osaka.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ないんたん天気予報@大阪
6 |
7 |
8 |
9 |
10 |
54 |
55 |
56 |
57 | 大阪大学豊中キャンパスにおける降水確率
58 |
59 |
60 |
61 | 大阪大学吹田キャンパスにおける降水確率
62 |
63 |
64 | 大阪大学中之島センターにおける降水確率
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/www/kyoto.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
ないんたん天気予報@京都
6 |
7 |
8 |
9 |
10 |
11 |
58 |
59 |
60 |
61 | 京都大学吉田キャンパスにおける降水確率
62 |
63 |
64 |
65 | 京都大学桂キャンパスにおける降水確率
66 |
67 |
68 |
69 | 京都大学宇治キャンパスにおける降水確率
70 |
71 |
72 |
73 | KRPにおける降水確率
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/www/tokyo.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
ないんたん天気予報@東京
6 |
7 |
8 |
9 |
10 |
11 |
58 |
59 |
60 |
66 |
67 | 東京大学本郷キャンパスにおける降水確率
68 |
69 |
70 |
71 | 東京大学駒場キャンパスにおける降水確率
72 |
73 |
74 |
75 | 東京工業大学大岡山キャンパスにおける降水確率
76 |
77 |
78 |
79 | 六本木ヒルズにおける降水確率
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/src/lib/oauth.php:
--------------------------------------------------------------------------------
1 | .
18 | */
19 |
20 | /*******************************************************************************
21 | OAuth 関数 (OAuth Functions)
22 |
23 | 定義の必要な定数 (Constants Required):
24 | OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET.
25 | *******************************************************************************/
26 |
27 | /*******************************************************************************
28 | oauth_request 関数 (oauth_request function)
29 |
30 | 導入 (Introduction):
31 | OAuthで接続し内容を取得する関数. (A function to get contents via OAuth.)
32 |
33 | 説明 (Description):
34 | string oauth_request($url [, $param = array() [, $method = 'GET']])
35 |
36 | OAuthで接続可能な $url に対してパラメータ $param を用いて
37 | HTTPメソッド $method で接続し,得られた内容を返します.
38 |
39 | Return the content from the $url by the HTTP method $method with $param.
40 |
41 | 制限事項 (Restriction):
42 | $url にはチルダまたは空白文字列を含むことはできません.
43 |
44 | $url cannot contain any tilde or space.
45 | *******************************************************************************/
46 |
47 | function oauth_request($url, $param = array(), $method = 'GET') {
48 | // Add necessary parameters
49 | $param += array(
50 | 'oauth_consumer_key' => OAUTH_CONSUMER_KEY,
51 | 'oauth_signature_method' => 'HMAC-SHA1',
52 | 'oauth_timestamp' => time(),
53 | 'oauth_nonce' => md5(microtime() . $_SERVER['REMOTE_ADDR']),
54 | 'oauth_version' => '1.0');
55 |
56 | // Sort parameters by key
57 | uksort($param, 'strnatcmp');
58 |
59 | // Generate seeds for HMAC Hash
60 | $key = OAUTH_CONSUMER_SECRET . "&$param[oauth_token_secret]";
61 | unset($param['oauth_token_secret']);
62 | $data = "$method&" . urlencode($url) . "&" .
63 | urlencode(strtr(http_build_query($param),
64 | array('%7E' => '~', '+' => '%20')));
65 |
66 | // Replace signature into HMAC Hash
67 | $hash = base64_encode(hash_hmac('sha1', $data, $key, true));
68 | $param['oauth_signature'] = $hash;
69 |
70 | // Get the content
71 | $param = http_build_query($param);
72 | if ($method == 'GET') return file_get_contents("$url?$param");
73 | $header = array("Content-Type: application/x-www-form-urlencoded",
74 | "Content-Length: " . strlen($param));
75 | $context = array("http" => array("method" => "POST",
76 | "header" => implode("\r\n", $header), "content" => $param));
77 | return file_get_contents($url, false, stream_context_create($context));
78 | }
79 |
--------------------------------------------------------------------------------
/src/forecast.php:
--------------------------------------------------------------------------------
1 |
2 | require_once('lib/location.php');
3 |
4 | function xband_time($location) {
5 | $url = "http://www.river.go.jp/xbandradar/rdimg/$location/nowcast/$location-timedata01.html";
6 | if (!preg_match('%(\d{4}/\d\d/\d\d)\s+(\d\d:\d\d)%',
7 | file_get_contents($url), $match)) return 'HOST_IS_DOWN';
8 | return strtotime($match[1] . ' ' . $match[2]);
9 | }
10 |
11 | function xband_url($time, $location) {
12 | $time = intval($time / 60) * 60;
13 | $sixhour = sprintf("%02d00", intval(date('H', $time) / 6) * 6);
14 | return "http://www.river.go.jp/xbandradar/rdimg/$location/" .
15 | date('Ymd', $time) . '/' . $sixhour . '/' . $location .
16 | date('Ymd', $time) . 'T' . date('Hi', $time) . '_detail.png';
17 | }
18 |
19 | function xband_flow($time, $location) {
20 | if ($time < strtotime('2011/01/01'))
21 | die(date('Y/m/d H:i:s', $time) . " is too old.\n");
22 | $target_code = date('Hi', $time);
23 | if ($time < @filemtime(
24 | "/tmp/forecast/$location-$target_code-flow.png")) return true;
25 | if (!is_dir('/tmp/forecast')) mkdir('/tmp/forecast');
26 | for ($shift = -10; $shift <= 0; $shift += 2) {
27 | $target_time = $time + $shift * 60;
28 | $target_code = date('Hi', $target_time);
29 | $files[] = "/tmp/forecast/$location-$target_code.gif";
30 | if ($target_time < @filemtime(
31 | "/tmp/forecast/$location-$target_code.gif")) continue;
32 | echo "Loading $target_code...\n";
33 | if ($location == 'kanto11') {
34 | file_put_contents("/tmp/forecast/$location-$target_code-base.png",
35 | file_get_contents(xband_url($target_time, $location)));
36 | exec("convert -crop '100%x100%+0+2730' " .
37 | "/tmp/forecast/$location-$target_code-base.png " .
38 | "/tmp/forecast/$location-$target_code.png ");
39 | } else {
40 | file_put_contents("/tmp/forecast/$location-$target_code.png",
41 | file_get_contents(xband_url($target_time, $location)));
42 | }
43 | exec("~/bin/radar-convert -s 0.20254 -l xband " .
44 | "-o /tmp/forecast/$location-$target_code.gif " .
45 | "/tmp/forecast/$location-$target_code.png");
46 | if (!is_readable(
47 | "/tmp/forecast/$location-$target_code.gif")) {
48 | die("$location-$target_code.gif is not found.\n");
49 | }
50 | }
51 | $files = array_reverse($files);
52 | echo "Calculating flow...\n";
53 | $target_code = date('Hi', $time);
54 | echo "~/bin/opticalflow -b 5 -s 2.5 -i white -a 0.3 " .
55 | "-o /tmp/forecast/$location-$target_code-flow.png " .
56 | implode(' ', $files);
57 | exec("~/bin/opticalflow -b 5 -s 2.5 -i white -a 0.3 " .
58 | "-o /tmp/forecast/$location-$target_code-flow.png " .
59 | implode(' ', $files));
60 | return is_readable("/tmp/forecast/$location-$target_code-flow.png");
61 | }
62 |
63 | function ninetan_forecast($time, $location, $position, $data) {
64 | $prob = array();
65 | foreach (explode("\n", $data) as $line) {
66 | $line = preg_split('%\s+%', $line);
67 | if (count($line) < 6) continue;
68 | if ($line[0]) {
69 | $prob[intval($line[0] / 2)]['x'] = (float)$line[1];
70 | $prob[intval($line[0] / 2)]['y'] = (float)$line[2];
71 | }
72 | for ($j = 4; $j < count($line); $j += 2) {
73 | $color = (intval($line[$j]) & 0xf0) >> 8;
74 | if ($color == 15) continue;
75 | $prob[intval($line[0] / 2)][$color] += intval($line[$j + 1]);
76 | $prob[intval($line[0] / 2)]['sum'] += intval($line[$j + 1]);
77 | }
78 | }
79 | foreach ($prob as $key => $val) {
80 | for ($i = 0; $i < 8; $i++) {
81 | $prob[$key][$i] = $prob[$key][$i] / $prob[$key]['sum'];
82 | }
83 | }
84 | ksort($prob);
85 | foreach ($prob as $key => $val) {
86 |
87 | }
88 | }
89 |
90 | function xband_forecast($time, $location) {
91 | global $locations;
92 | xband_flow($time, $location);
93 | $target_code = date('Hi', $time);
94 | foreach ($locations[$location] as $position => $value) {
95 | if (!$value) continue;
96 | echo "Calculating $position...\n";
97 | exec("~/bin/opticalflow -b 5 -s 2.5 -z 0.08 -d 0.25 " .
98 | "-f /tmp/forecast/$location-$target_code-flow.png " .
99 | "/tmp/forecast/$location-$target_code.gif " .
100 | "-x {$value['location']['x']} -y {$value['location']['y']} " .
101 | "> /tmp/forecast/$location-$target_code-$position.txt");
102 | }
103 | }
104 |
105 | function xband($location = 'kinki01') {
106 | $time = xband_time($location);
107 | xband_forecast($time, $location);
108 | }
109 |
110 | xband('kinki01');
111 | xband('kanto11');
112 |
--------------------------------------------------------------------------------
/src/misc.hpp:
--------------------------------------------------------------------------------
1 | #ifndef __MISC_HPP
2 | #define __MISC_HPP
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include