home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet 1996 World Exposition
/
park.org.s3.amazonaws.com.7z
/
park.org.s3.amazonaws.com
/
cgi-bin
/
Japan
/
Theme
/
bearth
/
bin
/
mkevents
< prev
next >
Wrap
Text File
|
2017-09-21
|
4KB
|
120 lines
#!/usr/local/bin/perl
#
# mkevents
# - make events file for Breathing Earth
# usage: mkevents rawdatafile
# (file name of 'rawdatafile' is yyyymmdd; full path name is available)
# created by haruki@st.rim.or.jp 1996/11/02
require '/stage/htdocs/cgi-bin/Japan/Theme/bearth/bin/bearth_init.pl';
$rawdata=shift(@ARGV);
$rawfile="$RawdataDir/$rawdata";
#
# ░·┐⌠Ñ┴ѺÑ├Ñ»
#
if ($rawfile eq "") {
print "argument mismatch\n";
exit;
}
$amEventsTmp="$EventsDir/$rawdata-0.tmp";
$pmEventsTmp="$EventsDir/$rawdata-1.tmp";
$amEventsFile="$EventsDir/$rawdata-0.evt";
$pmEventsFile="$EventsDir/$rawdata-1.evt";
$data=0;
open(FILE, $rawfile);
open(AMTMP, "> $amEventsTmp"); # ╕ß┴░ñ╬ÑñÑ┘Ñ≤Ñ╚ñ≥╜±ñ¡╜╨ñ╣Ñ╒ÑíÑñÑδ
open(PMTMP, "> $pmEventsTmp"); # ╕ß╕σñ╬ÑñÑ┘Ñ≤Ñ╚ñ≥╜±ñ¡╜╨ñ╣Ñ╒ÑíÑñÑδ
while (<FILE>) {
if ($data == 1) {
# ╣α╠▄'Depth'ñ¼╢⌡╟≥ñ╬╛∞╣τñ¼ñóñδñ╬ñ╟├▒╜πñ╦╢⌡╟≥ñ≥Ñ╗Ñ╤Ñ∞í╝Ñ┐ñ╦
# ñ╟ñ¡ñ╩ñññ╬ñ╟║┘ñ½ñ»ñ∩ñ▒ñ╞╣α╠▄ñ≥╝ΦñΩ╜╨ñ╣
# ╣α╠▄'mb' or 'ML' ñ╟║╕┬ªñ╚▒ª┬ªñ╦╩¼ñ▒ñδ
($tableleft, $tableright) = split('mb|ML', $_, 2);
# ║╕┬ªñ╬╣α╠▄ñ½ñΘ Date, Time, Lat, Lon ñ≥╝ΦñΩ╜╨ñ╣
($type, $date, $time, $lat, $lon, $nph, $depth) = split(' ', $tableleft, 7);
# Dateñ╬╣α╠▄ñ╦┐⌠╗·ñ¼╞■ñ├ñ╞ñññ╩ññ╣╘ñ╧╠╡╗δñ╣ñδ
# Region ñ╬╩╕╗·╬≤ñ¼─╣ñññ╚ú▓╣╘ñ╦ñ∩ñ┐ñδÑ╟í╝Ñ┐ñ╦ñ╩ñ├ñ╞ñññδñ┐ñß
if ($date =~ /\d{4}\/\d{2}\/\d{2}/) {
# Dateñ¼╗╪─Ωñ╡ñ∞ñ┐╞ⁿ╔╒ñ╬╛∞╣τñ└ñ▒Ñ╟í╝Ñ┐ñ≥╝ΦñΩ╜╨ñ╣
$data_date = $date;
$data_date =~ s/\///g; # Dateñ≥yyyymmddÑ╒Ñ⌐í╝Ñ▐Ñ├Ñ╚ñ╦ñ╣ñδ
if ($data_date eq $rawdata) {
# Lat, Lon ñ╧├═ñ╚íó╞ε╦╠íª└╛┼∞ñ╬╡¡╣µñ╚ñ≥╩¼ñ▒ñδ
($latval, $latdir) = $lat =~ /(\d+\.\d+|\d+)(\w+)/;
($lonval, $londir) = $lon =~ /(\d+\.\d+|\d+)(\w+)/;
# ▒ª┬ªñ╬╣α╠▄ñ½ñΘ Mag, Region ñ≥╝ΦñΩ╜╨ñ╣
($mag, $region) = split(' ', $tableright, 2);
# Time ñ½ñΘ╗■íó╩¼íó╔├ñ≥╝ΦñΩ╜╨ñ╣
($hour, $min, $sec) = split(':', $time, 3);
if ($hour < 12) { # ╕ß┴░ñ╬ÑñÑ┘Ñ≤Ñ╚í╩yyyymmdd-0.evt Ñ╒ÑíÑñÑδñ╪í╦
$latval = &to_plus_minus($latval, $latdir, "lat");
$lonval = &to_plus_minus($lonval, $londir, "lon");
print AMTMP "$latval\t$lonval\t$mag\t($date $time)\n";
} else { # ╕ß╕σñ╬ÑñÑ┘Ñ≤Ñ╚í╩yyyymmdd-1.evt Ñ╒ÑíÑñÑδñ╪í╦
$latval = &to_plus_minus($latval, $latdir, "lat");
$lonval = &to_plus_minus($lonval, $londir, "lon");
print PMTMP "$latval\t$lonval\t$mag\t($date $time)\n";
}
}
}
# end of data
if (/_________________________________________________________________/) {
$data=0;
}
}
# Ñ╟í╝Ñ┐ñ╬ñ╚ñ│ñφñ▐ñ╟╞╔ñ▀╚⌠ñ╨ñ╣
if (/^B Date Time Lat Lon Nph Depth Mag Region/) {
$data=1;
}
}
close(FILE);
close(AMTMP);
close(PMTMP);
#
# rawdatañ╧ÑñÑ┘Ñ≤Ñ╚ñ╬┐╖ñ╖ññ╜τñ╩ñ╬ñ╟╡╒╜τñ╦ñ╣ñδ
#
open(AMTMP, "$amEventsTmp"); # ╕ß┴░ñ╬ÑñÑ┘Ñ≤Ñ╚ñ¼╞■ñ├ñ╞ñññδÑ╒ÑíÑñÑδ
open(AMEVENTS, "> $amEventsFile"); # ╕ß┴░ñ╬ÑñÑ┘Ñ≤Ñ╚ñ≥╜±ñ¡╜╨ñ╣Ñ╒ÑíÑñÑδ
print AMEVENTS reverse <AMTMP>;
close(AMTMP);
close(AMEVENTS);
open(PMTMP, "$pmEventsTmp"); # ╕ß╕σñ╬ÑñÑ┘Ñ≤Ñ╚ñ¼╞■ñ├ñ╞ñññδÑ╒ÑíÑñÑδ
open(PMEVENTS, "> $pmEventsFile"); # ╕ß╕σñ╬ÑñÑ┘Ñ≤Ñ╚ñ≥╜±ñ¡╜╨ñ╣Ñ╒ÑíÑñÑδ
print PMEVENTS reverse <PMTMP>;
close(PMTMP);
close(PMEVENTS);
unlink("$amEventsTmp");
unlink("$pmEventsTmp");
#
# to_plus_minus(░▐┼┘/╖╨┼┘, N/S/E/W, "lat"/"lon")
# ú▒╚╓╠▄ñ╬░·┐⌠ñ╧░▐┼┘or╖╨┼┘ñ╬┐⌠├═
# ú▓╚╓╠▄ñ╬░·┐⌠ñ╧░▐┼┘or╖╨┼┘ñ╬╩²│╤íó░▐┼┘ñ╩ñΘN or Síó╖╨┼┘ñ╩ñΘ E or W
# ú│╚╓╠▄ñ╬░·┐⌠ñ╧░▐┼┘or╖╨┼┘ñ≥╔╜ñ∩ñ╣╩╕╗·╬≤
sub to_plus_minus {
($val, $dir, $kind) = @_;
if ($kind eq "lat") { # ░▐┼┘
if ($dir eq 'S') { #╞ε░▐ñ╧╔Θñ╬├═
$val = "-$val";
} #╦╠░▐ñ╧└╡ñ╬├═
} else {
if ($dir eq 'W') { #└╛╖╨ñ╧╔Θñ╬├═
$val = "-$val";
} #┼∞╖╨ñ╧└╡ñ╬├═
}
return $val;
}