eew_parser 0.1.8 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/eew_parser.gemspec +6 -5
- data/lib/area_code.rb +3 -0
- data/lib/eew_parser.rb +195 -174
- data/lib/epicenter_code.rb +3 -0
- data/spec/eew_parser_spec.rb +24 -2
- metadata +15 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d62f0e500e54d55070e6a84893bfa4e8de10eed3f3e391ec8b40acfe043798d
|
4
|
+
data.tar.gz: 24dc016bf1b1bfd5e8ea20adbccfa87bc898a72b2b8795a4c22e1458d6debd55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50b890cc366243422128be8fd97b24f0b29a9ad36a7207d0f5d915002aa2aa9ae126a80f7d1be6c70050f2172bc1099882a1620fd926b5e75b279476d4098ac7
|
7
|
+
data.tar.gz: 67b1e11165c87654d52f23d9f3725a92deb66351a4ce43c566565b46825f0d42f9de76a7bdb9f0f384cf6902c2548c3900111f4773ea506bf9f176454dae259d
|
data/.travis.yml
CHANGED
data/eew_parser.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "eew_parser"
|
3
|
-
spec.version = "0.
|
3
|
+
spec.version = "0.2.3"
|
4
4
|
spec.authors = ["Masaki Matsushita"]
|
5
5
|
spec.email = ["glass.saga@gmail.com"]
|
6
6
|
spec.summary = %q{Parser for Earthquake Early Warning from JMA}
|
@@ -13,8 +13,9 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
14
14
|
spec.require_paths = ["lib"]
|
15
15
|
|
16
|
-
spec.
|
17
|
-
spec.add_development_dependency "
|
18
|
-
spec.add_development_dependency "
|
19
|
-
spec.add_development_dependency "rspec
|
16
|
+
spec.required_ruby_version = '>= 2.5.0'
|
17
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
18
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
19
|
+
spec.add_development_dependency "rspec", "~> 3.9"
|
20
|
+
spec.add_development_dependency "rspec-its", "~> 1.3"
|
20
21
|
end
|
data/lib/area_code.rb
CHANGED
data/lib/eew_parser.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#encoding: utf-8
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "time"
|
2
4
|
|
3
5
|
require_relative "epicenter_code"
|
4
6
|
require_relative "area_code"
|
@@ -28,99 +30,41 @@ module EEW
|
|
28
30
|
def initialize(str)
|
29
31
|
raise ArgumentError unless str.is_a?(String)
|
30
32
|
@fastcast = str.dup
|
33
|
+
@fastcast.force_encoding(Encoding::ASCII)
|
31
34
|
@fastcast.freeze
|
32
|
-
raise Error, "
|
35
|
+
raise Error, "電文のサイズが不正です" if @fastcast.bytesize < 135
|
33
36
|
end
|
34
37
|
|
35
38
|
attr_reader :fastcast
|
36
39
|
|
37
|
-
|
38
|
-
|
39
|
-
@fastcast.dup
|
40
|
-
end
|
41
|
-
|
42
|
-
# 電文のサイズを返します。
|
43
|
-
def size
|
44
|
-
@fastcast.bytesize
|
40
|
+
def inspect
|
41
|
+
"#<EEWParser:#{id} (第#{number}報) #{epicenter} 震度#{seismic_intensity}>"
|
45
42
|
end
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
return @print.dup if @print
|
50
|
-
|
51
|
-
@print = <<-EOS
|
52
|
-
緊急地震速報 (第#{number}報)
|
53
|
-
電文種別: #{type}
|
54
|
-
発信官署: #{from}
|
55
|
-
訓練等の識別符: #{drill_type}
|
56
|
-
電文の発表時刻: #{report_time.strftime("%F %T")}
|
57
|
-
電文がこの電文を含め何通あるか: #{number_of_telegram}
|
58
|
-
コードが続くかどうか: #{continue?}
|
59
|
-
地震発生時刻もしくは地震検知時刻: #{earthquake_time.strftime("%F %T")}
|
60
|
-
地震識別番号: #{id}
|
61
|
-
発表状況(訂正等)の指示: #{status}
|
62
|
-
発表する高度利用者向け緊急地震速報の番号(地震単位での通番): #{number}
|
63
|
-
震央地名: #{epicenter}
|
64
|
-
震央の位置: #{position}
|
65
|
-
震源の深さ(単位 km)(不明・未設定時,キャンセル時:///): #{depth}
|
66
|
-
マグニチュード(不明・未設定時、キャンセル時:///): #{magnitude}
|
67
|
-
最大予測震度(不明・未設定時、キャンセル時://): #{seismic_intensity}
|
68
|
-
震央の確からしさ: #{probability_of_position}
|
69
|
-
震源の深さの確からしさ: #{probability_of_depth}
|
70
|
-
マグニチュードの確からしさ: #{probability_of_magnitude}
|
71
|
-
震央の確からしさ(気象庁の部内システムでの利用): #{probability_of_position_jma}
|
72
|
-
震源の深さの確からしさ(気象庁の部内システムでの利用): #{probability_of_depth_jma}
|
73
|
-
震央位置の海陸判定: #{land_or_sea}
|
74
|
-
警報を含む内容かどうか: #{warning?}
|
75
|
-
最大予測震度の変化: #{change}
|
76
|
-
最大予測震度の変化の理由: #{reason_of_change}
|
77
|
-
EOS
|
78
|
-
|
79
|
-
if has_ebi?
|
80
|
-
@print << "\n地域毎の警報の判別、最大予測震度及び主要動到達予測時刻(EBI):\n"
|
81
|
-
ebi.each do |local|
|
82
|
-
arrival_time = local[:arrival] ? "すでに到達" : local[:arrival_time]&.strftime("%T")
|
83
|
-
@print << "#{local[:area_name]} 最大予測震度: #{local[:intensity]} 予想到達時刻: #{arrival_time} 警報: #{local[:warning]}\n"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
@print.freeze
|
88
|
-
return @print.dup
|
44
|
+
def ==(other)
|
45
|
+
@fastcast == other.fastcast
|
89
46
|
end
|
90
47
|
|
91
|
-
|
92
|
-
|
93
|
-
:magnitude, :seismic_intensity, :probability_of_position_jma, :probability_of_depth, :probability_of_magnitude, :probability_of_position, :probability_of_depth_jma,
|
94
|
-
:land_or_sea, :warning?, :change, :reason_of_change, :ebi
|
95
|
-
].freeze
|
96
|
-
|
97
|
-
# 電文を解析した結果をHashで返します。
|
98
|
-
def to_hash
|
99
|
-
hash = {}
|
100
|
-
Attributes.each do |attribute|
|
101
|
-
hash[attribute] = __send__(attribute)
|
102
|
-
end
|
103
|
-
return hash
|
48
|
+
def <=>(other)
|
49
|
+
id + number <=> other.id + other.number
|
104
50
|
end
|
105
51
|
|
106
|
-
|
107
|
-
|
108
|
-
Attributes.each do |attribute|
|
109
|
-
__send__(attribute)
|
110
|
-
end
|
111
|
-
return true
|
52
|
+
def eql?(other)
|
53
|
+
@fastcast.eql?(other.fastcast)
|
112
54
|
end
|
113
55
|
|
114
|
-
def
|
115
|
-
|
56
|
+
def hash
|
57
|
+
@fastcast.hash
|
116
58
|
end
|
117
59
|
|
118
|
-
|
119
|
-
|
60
|
+
# initializeに与えられた電文を返します。
|
61
|
+
def to_s
|
62
|
+
@fastcast.dup
|
120
63
|
end
|
121
64
|
|
122
|
-
|
123
|
-
|
65
|
+
# 電文のサイズを返します。
|
66
|
+
def size
|
67
|
+
@fastcast.bytesize
|
124
68
|
end
|
125
69
|
|
126
70
|
# 電文種別コード
|
@@ -139,6 +83,12 @@ module EEW
|
|
139
83
|
end
|
140
84
|
end
|
141
85
|
|
86
|
+
# キャンセル報かどうか
|
87
|
+
def canceled?
|
88
|
+
return true if @fastcast[0, 2] == "39"
|
89
|
+
return false
|
90
|
+
end
|
91
|
+
|
142
92
|
# 発信官署
|
143
93
|
def from
|
144
94
|
case @fastcast[3, 2]
|
@@ -193,7 +143,7 @@ module EEW
|
|
193
143
|
|
194
144
|
# 電文の発表時刻のTimeオブジェクトを返します。
|
195
145
|
def report_time
|
196
|
-
Time.
|
146
|
+
Time.strptime(@fastcast[9, 12], "%y%m%d%H%M%S")
|
197
147
|
rescue ArgumentError
|
198
148
|
raise Error, "電文の形式が不正です (発表時刻: #{@fastcast[9, 12]})"
|
199
149
|
end
|
@@ -220,24 +170,21 @@ module EEW
|
|
220
170
|
|
221
171
|
# 地震発生時刻もしくは地震検知時刻のTimeオブジェクトを返します。
|
222
172
|
def earthquake_time
|
223
|
-
Time.
|
173
|
+
Time.strptime(@fastcast[26, 12], "%y%m%d%H%M%S")
|
224
174
|
rescue ArgumentError
|
225
175
|
raise Error, "電文の形式が不正です (地震発生時刻: #{@fastcast[26, 12]})"
|
226
176
|
end
|
227
177
|
|
228
178
|
# 地震識別番号(String)
|
229
179
|
def id
|
230
|
-
id
|
231
|
-
|
232
|
-
|
180
|
+
return @id if @id
|
181
|
+
@id = @fastcast[41, 14]
|
182
|
+
Integer(@id, 10) # verify
|
183
|
+
return @id
|
233
184
|
rescue ArgumentError
|
234
185
|
raise Error, "電文の形式が不正です(地震識別番号: #{id})"
|
235
186
|
end
|
236
187
|
|
237
|
-
def __id__
|
238
|
-
(id * 10) + number
|
239
|
-
end
|
240
|
-
|
241
188
|
# 発表状況(訂正等)の指示
|
242
189
|
def status
|
243
190
|
case @fastcast[59]
|
@@ -260,7 +207,7 @@ module EEW
|
|
260
207
|
|
261
208
|
# 発表状況と訓練識別が通常かどうか
|
262
209
|
def normal?
|
263
|
-
return true if @fastcast[59] == "0" && @fastcast[6, 2] == "00"
|
210
|
+
return true if (@fastcast[59] == "0" || @fastcast[59] == 9) && @fastcast[6, 2] == "00"
|
264
211
|
return false
|
265
212
|
end
|
266
213
|
|
@@ -295,6 +242,7 @@ module EEW
|
|
295
242
|
# 震央の名称
|
296
243
|
def epicenter
|
297
244
|
code = @fastcast[86, 3]
|
245
|
+
return "不明又は未設定" if code == "///"
|
298
246
|
code = Integer(code, 10)
|
299
247
|
EpicenterCode.fetch(code)
|
300
248
|
rescue ArgumentError, KeyError
|
@@ -350,13 +298,7 @@ module EEW
|
|
350
298
|
"6+" => "6強",
|
351
299
|
"07" => "7"
|
352
300
|
}.freeze
|
353
|
-
|
354
|
-
# 電文フォーマットの震度を文字列に変換
|
355
|
-
def to_seismic_intensity(str)
|
356
|
-
SeismicIntensity.fetch(str)
|
357
|
-
rescue KeyError
|
358
|
-
raise Error, "電文の形式が不正です(震度: #{str})"
|
359
|
-
end
|
301
|
+
private_constant :SeismicIntensity
|
360
302
|
|
361
303
|
# 最大予測震度
|
362
304
|
def seismic_intensity
|
@@ -375,6 +317,7 @@ module EEW
|
|
375
317
|
"9" => "予備",
|
376
318
|
"/" =>"不明又は未設定"
|
377
319
|
}.freeze
|
320
|
+
private_constant :OriginProbability
|
378
321
|
|
379
322
|
# 震央の確からしさ
|
380
323
|
def probability_of_position
|
@@ -440,7 +383,7 @@ module EEW
|
|
440
383
|
end
|
441
384
|
end
|
442
385
|
|
443
|
-
#
|
386
|
+
# 互換性のため
|
444
387
|
alias probability_of_position_jma observation_points_of_magnitude
|
445
388
|
|
446
389
|
# 震源の深さの確からしさ(※気象庁の部内システムでの利用)
|
@@ -494,7 +437,7 @@ module EEW
|
|
494
437
|
end
|
495
438
|
|
496
439
|
# 予測手法
|
497
|
-
def
|
440
|
+
def prediction_method
|
498
441
|
case @fastcast[123]
|
499
442
|
when "9"
|
500
443
|
"震源とマグニチュードによる震度推定手法において震源要素が推定できず、PLUM 法による震度予測のみが有効である場合"
|
@@ -561,11 +504,8 @@ module EEW
|
|
561
504
|
|
562
505
|
# EBIを含むかどうか
|
563
506
|
def has_ebi?
|
564
|
-
if @fastcast[135, 3] == "EBI"
|
565
|
-
|
566
|
-
else
|
567
|
-
return false
|
568
|
-
end
|
507
|
+
return true if @fastcast[135, 3] == "EBI"
|
508
|
+
return false
|
569
509
|
end
|
570
510
|
|
571
511
|
# 地域毎の警報の判別、最大予測震度及び主要動到達予測時刻
|
@@ -582,53 +522,167 @@ module EEW
|
|
582
522
|
@ebi = []
|
583
523
|
i = 139
|
584
524
|
while i + 20 < @fastcast.bytesize
|
585
|
-
|
586
|
-
|
587
|
-
local
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
525
|
+
local_str = @fastcast[i, 20]
|
526
|
+
area_code = ebi_area_code(local_str)
|
527
|
+
local = {
|
528
|
+
area_code: area_code,
|
529
|
+
area_name: ebi_area_name(area_code),
|
530
|
+
intensity: ebi_intensity(local_str),
|
531
|
+
arrival_time: ebi_arrival_time(local_str),
|
532
|
+
warning: ebi_warning(local_str),
|
533
|
+
arrival: ebi_arrival(local_str)
|
534
|
+
}
|
535
|
+
local.freeze
|
536
|
+
@ebi.push(local)
|
537
|
+
i += 20
|
538
|
+
end
|
539
|
+
@ebi.freeze
|
540
|
+
return @ebi.dup
|
541
|
+
end
|
542
|
+
|
543
|
+
Attributes = [
|
544
|
+
:type, :from, :drill_type, :report_time, :number_of_telegram, :continue?, :earthquake_time, :id, :status, :final?, :number, :epicenter, :position, :depth,
|
545
|
+
:magnitude, :seismic_intensity, :observation_points_of_magnitude, :probability_of_depth, :probability_of_magnitude, :probability_of_position, :probability_of_depth_jma,
|
546
|
+
:land_or_sea, :warning?, :prediction_method, :change, :reason_of_change, :ebi
|
547
|
+
].freeze
|
548
|
+
private_constant :Attributes
|
549
|
+
|
550
|
+
# 電文を解析した結果をHashで返します。
|
551
|
+
def to_hash
|
552
|
+
unless @hash
|
553
|
+
@hash = {}
|
554
|
+
Attributes.each do |attribute|
|
555
|
+
@hash[attribute] = __send__(attribute)
|
600
556
|
end
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
557
|
+
@hash.freeze
|
558
|
+
end
|
559
|
+
return @hash.dup
|
560
|
+
end
|
561
|
+
|
562
|
+
# 正しい電文であるかを返します
|
563
|
+
def valid?
|
564
|
+
unless @valid
|
565
|
+
begin
|
566
|
+
Attributes.each do |attribute|
|
567
|
+
__send__(attribute)
|
568
|
+
end
|
569
|
+
rescue Error
|
570
|
+
@valid = false
|
608
571
|
else
|
609
|
-
|
572
|
+
@valid = true
|
610
573
|
end
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
574
|
+
end
|
575
|
+
return @valid
|
576
|
+
end
|
577
|
+
|
578
|
+
# 緊急地震速報の内容をテキストで出力します。
|
579
|
+
def print
|
580
|
+
return @print.dup if @print
|
581
|
+
|
582
|
+
@print = <<-EOS
|
583
|
+
緊急地震速報 (第#{number}報)
|
584
|
+
電文種別: #{type}
|
585
|
+
発信官署: #{from}
|
586
|
+
訓練等の識別符: #{drill_type}
|
587
|
+
電文の発表時刻: #{report_time.strftime("%F %T")}
|
588
|
+
電文がこの電文を含め何通あるか: #{number_of_telegram}
|
589
|
+
コードが続くかどうか: #{continue?}
|
590
|
+
地震発生時刻もしくは地震検知時刻: #{earthquake_time.strftime("%F %T")}
|
591
|
+
地震識別番号: #{id}
|
592
|
+
発表状況(訂正等)の指示: #{status}
|
593
|
+
発表する高度利用者向け緊急地震速報の番号(地震単位での通番): #{number}
|
594
|
+
震央地名: #{epicenter}
|
595
|
+
震央の位置: #{position}
|
596
|
+
震源の深さ(単位 km)(不明・未設定時,キャンセル時:///): #{depth}
|
597
|
+
マグニチュード(不明・未設定時、キャンセル時:///): #{magnitude}
|
598
|
+
最大予測震度(不明・未設定時、キャンセル時://): #{seismic_intensity}
|
599
|
+
震央の確からしさ: #{probability_of_position}
|
600
|
+
震源の深さの確からしさ: #{probability_of_depth}
|
601
|
+
マグニチュードの確からしさ: #{probability_of_magnitude}
|
602
|
+
震源の深さの確からしさ(気象庁の部内システムでの利用): #{probability_of_depth_jma}
|
603
|
+
震央位置の海陸判定: #{land_or_sea}
|
604
|
+
警報を含む内容かどうか: #{warning?}
|
605
|
+
予測手法: #{prediction_method}
|
606
|
+
最大予測震度の変化: #{change}
|
607
|
+
最大予測震度の変化の理由: #{reason_of_change}
|
608
|
+
EOS
|
609
|
+
|
610
|
+
if has_ebi?
|
611
|
+
@print << "\n地域毎の警報の判別、最大予測震度及び主要動到達予測時刻(EBI):\n"
|
612
|
+
ebi.each do |local|
|
613
|
+
arrival_time = local[:arrival] ? "すでに到達" : local[:arrival_time]&.strftime("%T")
|
614
|
+
@print << "#{local[:area_name].ljust(10, " ")} 最大予測震度: #{local[:intensity].ljust(6, " ")} 予想到達時刻: #{arrival_time} 警報: #{local[:warning]}\n"
|
620
615
|
end
|
621
|
-
@ebi << local
|
622
|
-
i += 20
|
623
616
|
end
|
624
|
-
|
625
|
-
|
617
|
+
|
618
|
+
@print.freeze
|
619
|
+
return @print.dup
|
620
|
+
end
|
621
|
+
|
622
|
+
private
|
623
|
+
|
624
|
+
# 電文フォーマットの震度を文字列に変換
|
625
|
+
def to_seismic_intensity(str)
|
626
|
+
SeismicIntensity.fetch(str)
|
627
|
+
rescue KeyError
|
628
|
+
raise Error, "電文の形式が不正です(震度: #{str})"
|
629
|
+
end
|
630
|
+
|
631
|
+
def ebi_area_code(local_str)
|
632
|
+
return Integer(local_str[0, 3])
|
633
|
+
rescue ArgumentError
|
634
|
+
raise Error, "電文の形式が不正です(EBI: 地域コード)"
|
635
|
+
end
|
636
|
+
|
637
|
+
def ebi_area_name(area_code)
|
638
|
+
return AreaCode.fetch(area_code)
|
639
|
+
rescue KeyError
|
640
|
+
raise Error, "電文の形式が不正です(EBI: 地域名称)"
|
641
|
+
end
|
642
|
+
|
643
|
+
def ebi_intensity(local_str)
|
644
|
+
return to_seismic_intensity(local_str[5, 2]) + "以上" if local_str[7, 2] == "//" # 最大予測震度
|
645
|
+
return to_seismic_intensity(local_str[5, 2]) if local_str[5, 2] == local_str[7, 2]
|
646
|
+
return "#{to_seismic_intensity(local_str[7, 2])}から#{to_seismic_intensity(local_str[5, 2])}"
|
647
|
+
end
|
648
|
+
|
649
|
+
# 予想到達時刻
|
650
|
+
def ebi_arrival_time(local_str)
|
651
|
+
arrival_time = local_str[10, 6]
|
652
|
+
return nil if arrival_time == "//////"
|
653
|
+
return Time.strptime(arrival_time, "%H%M%S")
|
654
|
+
rescue ArgumentError
|
655
|
+
raise Error, "電文の形式が不正です (EBI: 地震発生時刻)"
|
656
|
+
end
|
657
|
+
|
658
|
+
def ebi_warning(local_str)
|
659
|
+
case local_str[17]
|
660
|
+
when "0"
|
661
|
+
return false
|
662
|
+
when "1"
|
663
|
+
return true
|
664
|
+
when "/", "2".."9"
|
665
|
+
return nil
|
666
|
+
else
|
667
|
+
raise Error, "電文の形式が不正です(EBI: 警報の判別)"
|
668
|
+
end
|
669
|
+
end
|
670
|
+
|
671
|
+
def ebi_arrival(local_str)
|
672
|
+
case local_str[18]
|
673
|
+
when "0"
|
674
|
+
return false
|
675
|
+
when "1"
|
676
|
+
return true
|
677
|
+
when "/", "2".."9"
|
678
|
+
return nil
|
679
|
+
else
|
680
|
+
raise Error, "電文の形式が不正です(EBI: 主要動の到達予測状況)"
|
681
|
+
end
|
626
682
|
end
|
627
683
|
end
|
628
684
|
end
|
629
685
|
|
630
|
-
EEWParser = EEW::Parser
|
631
|
-
|
632
686
|
if __FILE__ == $PROGRAM_NAME # テスト
|
633
687
|
str = <<EOS #テスト用の電文(EBIを含む)
|
634
688
|
37 03 00 110415233453 C11
|
@@ -646,40 +700,7 @@ EOS
|
|
646
700
|
|
647
701
|
fc = EEW::Parser.new(str)
|
648
702
|
p fc
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
puts <<FC
|
653
|
-
電文種別コード: #{fc.type}
|
654
|
-
発信官署: #{fc.from}
|
655
|
-
訓練等の識別符: #{fc.drill_type}
|
656
|
-
電文の発表時刻: #{fc.report_time}
|
657
|
-
電文がこの電文を含め何通あるか: #{fc.number_of_telegram}
|
658
|
-
コードが続くかどうか: #{fc.continue?}
|
659
|
-
地震発生時刻もしくは地震検知時刻: #{fc.earthquake_time}
|
660
|
-
地震識別番号: #{fc.id}
|
661
|
-
発表状況(訂正等)の指示: #{fc.status}
|
662
|
-
発表する高度利用者向け緊急地震速報の番号(地震単位での通番): #{fc.number}
|
663
|
-
震央地名コード: #{fc.epicenter}
|
664
|
-
震央の位置: #{fc.position}
|
665
|
-
震源の深さ(単位 km)(不明・未設定時,キャンセル時:///): #{fc.depth}
|
666
|
-
マグニチュード(不明・未設定時、キャンセル時:///): #{fc.magnitude}
|
667
|
-
最大予測震度(不明・未設定時、キャンセル時://): #{fc.seismic_intensity}
|
668
|
-
震央の確からしさ: #{fc.probability_of_position}
|
669
|
-
震源の深さの確からしさ: #{fc.probability_of_depth}
|
670
|
-
マグニチュードの確からしさ: #{fc.probability_of_magnitude}
|
671
|
-
震央の確からしさ(気象庁の部内システムでの利用): #{fc.probability_of_position_jma}
|
672
|
-
震源の深さの確からしさ(気象庁の部内システムでの利用): #{fc.probability_of_depth_jma}
|
673
|
-
震央位置の海陸判定: #{fc.land_or_sea}
|
674
|
-
警報を含む内容かどうか: #{fc.warning?}
|
675
|
-
最大予測震度の変化: #{fc.change}
|
676
|
-
最大予測震度の変化の理由: #{fc.reason_of_change}
|
677
|
-
FC
|
678
|
-
fc.ebi.each do |local|
|
679
|
-
puts "地域コード: #{local[:area_code]} 地域名: #{local[:area_name]} 最大予測震度: #{local[:intensity]} 予想到達時刻: #{local[:arrival_time]}"
|
680
|
-
puts "警報を含むかどうか: #{local[:warning]} 既に到達しているかどうか: #{local[:arrival]}"
|
681
|
-
end
|
682
|
-
|
703
|
+
puts fc.fastcast
|
704
|
+
pp fc.to_hash
|
683
705
|
puts fc.print
|
684
|
-
p EEW::AreaCode.values.max_by(&:size).size
|
685
706
|
end
|
data/lib/epicenter_code.rb
CHANGED
data/spec/eew_parser_spec.rb
CHANGED
@@ -43,6 +43,8 @@ EBI 251 S6+6- ////// 11 300 S5+5- ////// 11 250 S5+5- ////// 11
|
|
43
43
|
|
44
44
|
its(:type) { is_expected.to eq("マグニチュード、最大予測震度及び主要動到達予測時刻の高度利用者向け緊急地震速報(グリッドサーチ法、EPOS自動処理手法)") }
|
45
45
|
|
46
|
+
it { is_expected.not_to be_canceled }
|
47
|
+
|
46
48
|
its(:from) { is_expected.to eq("東京") }
|
47
49
|
|
48
50
|
its(:drill_type) { is_expected.to eq("通常") }
|
@@ -99,7 +101,9 @@ EBI 251 S6+6- ////// 11 300 S5+5- ////// 11 250 S5+5- ////// 11
|
|
99
101
|
|
100
102
|
its(:land_or_sea) { is_expected.to eq("陸域") }
|
101
103
|
|
102
|
-
|
104
|
+
its(:warning?) { is_expected.to be true }
|
105
|
+
|
106
|
+
its(:prediction_method) { is_expected.to eq("不明又は未設定") }
|
103
107
|
|
104
108
|
its(:change) { is_expected.to eq("最大予測震度が1.0以上大きくなった") }
|
105
109
|
|
@@ -163,10 +167,11 @@ ND20110415005001 NCN001 JD////////////// JN///
|
|
163
167
|
end
|
164
168
|
|
165
169
|
it "can be verified" do
|
170
|
+
eew = nil
|
166
171
|
expect {
|
167
172
|
eew = EEW::Parser.new(invalid)
|
168
|
-
eew.verify
|
169
173
|
}.not_to raise_error
|
174
|
+
expect(eew.valid?).to be true
|
170
175
|
end
|
171
176
|
end
|
172
177
|
|
@@ -180,7 +185,24 @@ ND20110415005001 NCN001 JD////////////// JN///
|
|
180
185
|
expect {
|
181
186
|
eew = EEW::Parser.new(sw)
|
182
187
|
}.not_to raise_error
|
188
|
+
expect(eew.valid?).to be true
|
183
189
|
expect(eew.position).to eq("S35.0 W140.3")
|
184
190
|
end
|
185
191
|
end
|
192
|
+
|
193
|
+
context "キャンセル報" do
|
194
|
+
let(:canceled) do
|
195
|
+
"39 04 10 181001002707 C11\n181001002656\nND20181001002656 NCN002 JD////////////// JN///\n/// //// ///// /// // // RK///// RT///// RC/////\n9999="
|
196
|
+
end
|
197
|
+
|
198
|
+
it "can be verified" do
|
199
|
+
eew = nil
|
200
|
+
expect {
|
201
|
+
eew = EEW::Parser.new(canceled)
|
202
|
+
eew.to_hash
|
203
|
+
}.not_to raise_error
|
204
|
+
expect(eew.valid?).to be true
|
205
|
+
expect(eew.canceled?).to be true
|
206
|
+
end
|
207
|
+
end
|
186
208
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eew_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaki Matsushita
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.9'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.9'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec-its
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
68
|
+
version: '1.3'
|
69
69
|
description: Parser for Earthquake Early Warning from JMA
|
70
70
|
email:
|
71
71
|
- glass.saga@gmail.com
|
@@ -90,7 +90,7 @@ homepage: https://github.com/mmasaki/eew_parser
|
|
90
90
|
licenses:
|
91
91
|
- MIT
|
92
92
|
metadata: {}
|
93
|
-
post_install_message:
|
93
|
+
post_install_message:
|
94
94
|
rdoc_options: []
|
95
95
|
require_paths:
|
96
96
|
- lib
|
@@ -98,16 +98,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
98
|
requirements:
|
99
99
|
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
101
|
+
version: 2.5.0
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
104
|
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
|
109
|
-
|
110
|
-
signing_key:
|
108
|
+
rubygems_version: 3.1.4
|
109
|
+
signing_key:
|
111
110
|
specification_version: 4
|
112
111
|
summary: Parser for Earthquake Early Warning from JMA
|
113
112
|
test_files:
|