line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geography::China::Provinces; |
2
|
3
|
|
|
3
|
|
110858
|
use strict; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
126
|
|
3
|
3
|
|
|
3
|
|
10020
|
use utf8; |
|
3
|
|
|
|
|
34
|
|
|
3
|
|
|
|
|
19
|
|
4
|
3
|
|
|
3
|
|
259
|
use warnings; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
189
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
3581
|
use Encode qw(decode_utf8); |
|
3
|
|
|
|
|
43911
|
|
|
3
|
|
|
|
|
4787
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $AREAS = { |
10
|
|
|
|
|
|
|
1 => { en => 'huabei', zh => '华北', }, |
11
|
|
|
|
|
|
|
2 => { en => 'dongbei', zh => '东北', }, |
12
|
|
|
|
|
|
|
3 => { en => 'huadong', zh => '华东', }, |
13
|
|
|
|
|
|
|
4 => { en => 'zhongnan', zh => '中南', }, |
14
|
|
|
|
|
|
|
5 => { en => 'xinan', zh => '西南', }, |
15
|
|
|
|
|
|
|
6 => { en => 'xibei', zh => '西北', }, |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
our $REGION_CATEGORIES = { |
18
|
|
|
|
|
|
|
1 => { en => 'municipality', |
19
|
|
|
|
|
|
|
zh => '直辖市', }, |
20
|
|
|
|
|
|
|
2 => { en => 'province', |
21
|
|
|
|
|
|
|
zh => '省', }, |
22
|
|
|
|
|
|
|
3 => { en => 'autonomous region', |
23
|
|
|
|
|
|
|
zh => '自治区', }, |
24
|
|
|
|
|
|
|
4 => { en => 'special administrative region', |
25
|
|
|
|
|
|
|
zh => '特別行政区', }, |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
our $REGION_CATEGORY_MAP = { |
28
|
|
|
|
|
|
|
'municipality' => 1, |
29
|
|
|
|
|
|
|
'province' => 2, |
30
|
|
|
|
|
|
|
'autonomous_region' => 3, |
31
|
|
|
|
|
|
|
'special_admin_region' => 4, |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
our $REGIONS = [ |
34
|
|
|
|
|
|
|
{ category => 1, iso => '11', gb => 'BJ', abbr => '京', area => 1, |
35
|
|
|
|
|
|
|
en => 'Beijing', zh => '北京市', capital_zh => '北京市', }, |
36
|
|
|
|
|
|
|
{ category => 1, iso => '12', gb => 'TJ', abbr => '津', area => 1, |
37
|
|
|
|
|
|
|
en => 'Tianjin', zh => '天津市', capital_zh => '天津市', }, |
38
|
|
|
|
|
|
|
{ category => 2, iso => '13', gb => 'HE', abbr => '冀', area => 1, |
39
|
|
|
|
|
|
|
en => 'Hebei', zh => '河北省', capital_zh => '石家庄市', }, |
40
|
|
|
|
|
|
|
{ category => 2, iso => '14', gb => 'SX', abbr => '晋', area => 1, |
41
|
|
|
|
|
|
|
en => 'Shanxi', zh => '山西省', capital_zh => '太原市', }, |
42
|
|
|
|
|
|
|
{ category => 3, iso => '15', gb => 'NM', abbr => '蒙', area => 1, |
43
|
|
|
|
|
|
|
en => 'Nei Mongol', zh => '內蒙古自治区', capital_zh => '呼和浩特市', }, |
44
|
|
|
|
|
|
|
{ category => 2, iso => '21', gb => 'LN', abbr => '辽', area => 2, |
45
|
|
|
|
|
|
|
en => 'Liaoning', zh => '辽宁省', capital_zh => '沈阳市', }, |
46
|
|
|
|
|
|
|
{ category => 2, iso => '22', gb => 'JL', abbr => '吉', area => 2, |
47
|
|
|
|
|
|
|
en => 'Jilin', zh => '吉林省', capital_zh => '长春市', }, |
48
|
|
|
|
|
|
|
{ category => 2, iso => '23', gb => 'HL', abbr => '黑', area => 2, |
49
|
|
|
|
|
|
|
en => 'Heilongjiang', zh => '黑龙江省', capital_zh => '哈尔滨市', }, |
50
|
|
|
|
|
|
|
{ category => 1, iso => '31', gb => 'SH', abbr => '沪', area => 3, |
51
|
|
|
|
|
|
|
en => 'Shanghai', zh => '上海市', capital_zh => '上海市', }, |
52
|
|
|
|
|
|
|
{ category => 2, iso => '32', gb => 'JS', abbr => '苏', area => 3, |
53
|
|
|
|
|
|
|
en => 'Jiangsu', zh => '江苏省', capital_zh => '南京市', }, |
54
|
|
|
|
|
|
|
{ category => 2, iso => '33', gb => 'ZJ', abbr => '浙', area => 3, |
55
|
|
|
|
|
|
|
en => 'Zhejiang', zh => '浙江省', capital_zh => '杭州市', }, |
56
|
|
|
|
|
|
|
{ category => 2, iso => '34', gb => 'AH', abbr => '皖', area => 3, |
57
|
|
|
|
|
|
|
en => 'Anhui', zh => '安徽省', capital_zh => '合肥市', }, |
58
|
|
|
|
|
|
|
{ category => 2, iso => '35', gb => 'FJ', abbr => '闽', area => 3, |
59
|
|
|
|
|
|
|
en => 'Fujian', zh => '福建省', capital_zh => '福州市', }, |
60
|
|
|
|
|
|
|
{ category => 2, iso => '36', gb => 'JX', abbr => '赣', area => 3, |
61
|
|
|
|
|
|
|
en => 'Jiangxi', zh => '江西省', capital_zh => '南昌市', }, |
62
|
|
|
|
|
|
|
{ category => 2, iso => '37', gb => 'SD', abbr => '鲁', area => 3, |
63
|
|
|
|
|
|
|
en => 'Shangdong', zh => '山东省', capital_zh => '济南市', }, |
64
|
|
|
|
|
|
|
{ category => 2, iso => '41', gb => 'HA', abbr => '豫', area => 4, |
65
|
|
|
|
|
|
|
en => 'Henan', zh => '河南省', capital_zh => '郑州市', }, |
66
|
|
|
|
|
|
|
{ category => 2, iso => '42', gb => 'HB', abbr => '鄂', area => 4, |
67
|
|
|
|
|
|
|
en => 'Hubei', zh => '湖北省', capital_zh => '武汉市', }, |
68
|
|
|
|
|
|
|
{ category => 2, iso => '43', gb => 'HN', abbr => '湘', area => 4, |
69
|
|
|
|
|
|
|
en => 'Hunan', zh => '湖南省', capital_zh => '长沙市', }, |
70
|
|
|
|
|
|
|
{ category => 2, iso => '44', gb => 'GD', abbr => '粤', area => 4, |
71
|
|
|
|
|
|
|
en => 'Guangdong', zh => '广东省', capital_zh => '广州市', }, |
72
|
|
|
|
|
|
|
{ category => 3, iso => '45', gb => 'GX', abbr => '桂', area => 4, |
73
|
|
|
|
|
|
|
en => 'Guangxi', zh => '广西壮族自治区', capital_zh => '南宁市', }, |
74
|
|
|
|
|
|
|
{ category => 2, iso => '46', gb => 'HI', abbr => '琼', area => 4, |
75
|
|
|
|
|
|
|
en => 'Hainan', zh => '海南省', capital_zh => '海口市', }, |
76
|
|
|
|
|
|
|
{ category => 1, iso => '50', gb => 'CQ', abbr => '渝', area => 5, |
77
|
|
|
|
|
|
|
en => 'Chongqing', zh => '重庆市', capital_zh => '重庆市', }, |
78
|
|
|
|
|
|
|
{ category => 2, iso => '51', gb => 'SC', abbr => '川', area => 5, |
79
|
|
|
|
|
|
|
en => 'Sichuan', zh => '四川省', capital_zh => '成都市', }, |
80
|
|
|
|
|
|
|
{ category => 2, iso => '52', gb => 'GZ', abbr => '黔', area => 5, |
81
|
|
|
|
|
|
|
en => 'Guizhou', zh => '贵州省', capital_zh => '贵阳市', }, |
82
|
|
|
|
|
|
|
{ category => 2, iso => '53', gb => 'YN', abbr => '滇', area => 5, |
83
|
|
|
|
|
|
|
en => 'Yunnan', zh => '云南省', capital_zh => '昆明市', }, |
84
|
|
|
|
|
|
|
{ category => 3, iso => '54', gb => 'XZ', abbr => '藏', area => 5, |
85
|
|
|
|
|
|
|
en => 'Xizang', zh => '西藏自治区', capital_zh => '拉萨市', }, |
86
|
|
|
|
|
|
|
{ category => 2, iso => '61', gb => 'SN', abbr => '陕', area => 6, |
87
|
|
|
|
|
|
|
en => 'Shaanxi', zh => '陕西省', capital_zh => '西安市', }, |
88
|
|
|
|
|
|
|
{ category => 2, iso => '62', gb => 'GS', abbr => '甘', area => 6, |
89
|
|
|
|
|
|
|
en => 'Gansu', zh => '甘肃省', capital_zh => '兰州市', }, |
90
|
|
|
|
|
|
|
{ category => 2, iso => '63', gb => 'QH', abbr => '青', area => 6, |
91
|
|
|
|
|
|
|
en => 'Qinghai', zh => '青海省', capital_zh => '西宁市', }, |
92
|
|
|
|
|
|
|
{ category => 3, iso => '64', gb => 'NX', abbr => '宁', area => 6, |
93
|
|
|
|
|
|
|
en => 'Ningxia', zh => '宁夏回族自治区', capital_zh => '银川市', }, |
94
|
|
|
|
|
|
|
{ category => 3, iso => '65', gb => 'XJ', abbr => '新', area => 6, |
95
|
|
|
|
|
|
|
en => 'Xinjiang', zh => '新疆维吾尔自治区', capital_zh => '乌鲁木齐市', }, |
96
|
|
|
|
|
|
|
{ category => 2, iso => '71', gb => 'TW', abbr => '台', area => 3, |
97
|
|
|
|
|
|
|
en => 'Taiwan', zh => '台湾省', capital_zh => '台北市', }, |
98
|
|
|
|
|
|
|
{ category => 4, iso => '91', gb => 'HK', abbr => '港', area => 4, |
99
|
|
|
|
|
|
|
en => 'Hong Kong', zh => '香港特别行政区', capital_zh => '香港', }, |
100
|
|
|
|
|
|
|
{ category => 4, iso => '92', gb => 'MC', abbr => '澳', area => 4, |
101
|
|
|
|
|
|
|
en => 'Macao', zh => '澳门特别行政区', capital_zh => '澳门', }, |
102
|
|
|
|
|
|
|
]; |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
1
|
1
|
1275
|
sub areas { %$AREAS; } |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub _create_entry { |
107
|
204
|
|
|
204
|
|
223
|
my $entry = shift; |
108
|
204
|
|
|
|
|
828
|
+{ %$entry, |
109
|
|
|
|
|
|
|
category => { |
110
|
|
|
|
|
|
|
id => $entry->{category}, |
111
|
204
|
|
|
|
|
2265
|
%{ $REGION_CATEGORIES->{$entry->{category}} }, |
112
|
|
|
|
|
|
|
}, |
113
|
|
|
|
|
|
|
area => { |
114
|
|
|
|
|
|
|
id => $entry->{area}, |
115
|
204
|
|
|
|
|
537
|
%{ $AREAS->{$entry->{area}} }, |
116
|
|
|
|
|
|
|
}, |
117
|
|
|
|
|
|
|
}; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub all { |
121
|
1
|
|
|
1
|
1
|
1445
|
map { _create_entry($_) } @$REGIONS; |
|
34
|
|
|
|
|
71
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub category { |
125
|
4
|
|
|
4
|
1
|
9
|
my ($class, $name) = @_; |
126
|
4
|
|
|
|
|
43
|
map { _create_entry($_) } grep { $_->{category} eq $REGION_CATEGORY_MAP->{$name} } @$REGIONS; |
|
34
|
|
|
|
|
67
|
|
|
136
|
|
|
|
|
228
|
|
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub municipals { |
130
|
1
|
|
|
1
|
1
|
183056
|
shift->category('municipality'); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub provinces { |
134
|
1
|
|
|
1
|
1
|
1584
|
shift->category('province'); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub autonomous_regions { |
138
|
1
|
|
|
1
|
1
|
1994
|
shift->category('autonomous_region'); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub special_admin_regions { |
142
|
1
|
|
|
1
|
1
|
1897
|
shift->category('special_admin_region'); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub area { |
146
|
20
|
|
|
20
|
1
|
2155
|
my ($class, $id) = @_; |
147
|
20
|
|
|
|
|
38
|
map { _create_entry($_) } grep { $_->{area} eq $id } @$REGIONS; |
|
102
|
|
|
|
|
239
|
|
|
680
|
|
|
|
|
1220
|
|
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub area_name { |
151
|
14
|
|
|
14
|
1
|
4136
|
my ($class, $name) = @_; |
152
|
14
|
|
|
|
|
47
|
$name = decode_utf8($name); |
153
|
14
|
100
|
|
|
|
382
|
my $lang = $name =~ /^[\x20-\x7e]+$/ ? 'en' : 'zh'; # consists only with ASCII => en |
154
|
14
|
|
|
|
|
49
|
for my $id (keys %$AREAS) { |
155
|
54
|
100
|
|
|
|
169
|
return $class->area($id) if $AREAS->{$id}->{$lang} eq $name; |
156
|
|
|
|
|
|
|
} |
157
|
2
|
|
|
|
|
9
|
(); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub iso { |
161
|
36
|
|
|
36
|
1
|
13281
|
my ($class, $iso) = @_; |
162
|
36
|
|
|
|
|
61
|
for my $r (@$REGIONS) { |
163
|
663
|
100
|
|
|
|
5308
|
return _create_entry($r) if $r->{iso} eq $iso; |
164
|
|
|
|
|
|
|
} |
165
|
2
|
|
|
|
|
6
|
undef; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
1; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
__END__ |