From fd4b0ae5b2f6f31ec6e217a480321ac9292ff752 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Tue, 26 May 2020 00:04:48 +0000 Subject: [PATCH] Add weather zone hkz000 for Hong Kong Observatory Thanks to Bill Agee for suggesting the Hong Kong Observatory's weather forecast page. A custom filter is implemented to strip the forecast text from the HTML page in which it is embedded (if anyone finds a plaintext version published at an alternate URL, let me know and I'll rip out the extra routine). --- airports | 2 +- overrides.conf | 6 ++++++ overrides.log | 1 + places | 2 +- stations | 10 +++++++++- weather.py | 3 +++ zctas | 2 +- zones | 9 ++++++++- 8 files changed, 30 insertions(+), 5 deletions(-) diff --git a/airports b/airports index 11a656b..28619a1 100644 --- a/airports +++ b/airports @@ -20,7 +20,7 @@ # ab78f945488371035514fc2c14e4679a 2020-05-24 airports.csv # # ...and these manually-generated or hand-compiled adjustments: -# aadcf8801156f29dc5c622bb5e874e88 2020-05-24 overrides.conf +# 298b10d8d6f5a4a41b2eb0c356766427 2020-05-24 overrides.conf # ab8545489a62124779edf7214a619325 2020-05-24 slist # 12c84e28cdb6da9eeba12b5a4af034b0 2020-05-24 zlist diff --git a/overrides.conf b/overrides.conf index a8d1874..f563ebe 100644 --- a/overrides.conf +++ b/overrides.conf @@ -502,6 +502,12 @@ comment = manually researched on 2020-05-24 description = Ismalia, IML, Egypt location = (0.5339253128236962, 0.5628201985215509) +[hkz000] +description = Hong Kong Observatory +comment = suggested by Bill Agee +centroid = (0.3897902, 1.9928751) +zone_forecast = https://www.hko.gov.hk/textonly/v2/forecast/nday.htm + [hesw] comment = manually researched on 2020-05-24 description = Siwa Oasis Arpt, Egypt diff --git a/overrides.log b/overrides.log index 3d76b3b..0e98bd9 100644 --- a/overrides.log +++ b/overrides.log @@ -1,3 +1,4 @@ +added zone hkz000 (+4 options) changed station cahr (+3 options) changed station cerm (+3 options) changed station cmfm (+3 options) diff --git a/places b/places index 307a935..aa7096b 100644 --- a/places +++ b/places @@ -20,7 +20,7 @@ # ab78f945488371035514fc2c14e4679a 2020-05-24 airports.csv # # ...and these manually-generated or hand-compiled adjustments: -# aadcf8801156f29dc5c622bb5e874e88 2020-05-24 overrides.conf +# 298b10d8d6f5a4a41b2eb0c356766427 2020-05-24 overrides.conf # ab8545489a62124779edf7214a619325 2020-05-24 slist # 12c84e28cdb6da9eeba12b5a4af034b0 2020-05-24 zlist diff --git a/stations b/stations index 038053f..4e1ed6c 100644 --- a/stations +++ b/stations @@ -20,7 +20,7 @@ # ab78f945488371035514fc2c14e4679a 2020-05-24 airports.csv # # ...and these manually-generated or hand-compiled adjustments: -# aadcf8801156f29dc5c622bb5e874e88 2020-05-24 overrides.conf +# 298b10d8d6f5a4a41b2eb0c356766427 2020-05-24 overrides.conf # ab8545489a62124779edf7214a619325 2020-05-24 slist # 12c84e28cdb6da9eeba12b5a4af034b0 2020-05-24 zlist @@ -30143,6 +30143,7 @@ metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/VGHS.TXT description = Hong Kong Inter-National Airport, Hong Kong location = (0.3897902, 1.9928751) metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/VHHH.TXT +zone = ('hkz000', 0.0000000) [viag] description = Agra, India @@ -30243,6 +30244,7 @@ metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/VLVT.TXT description = Taipa, Macau location = (0.3868813, 1.9821123) metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/VMMC.TXT +zone = ('hkz000', 0.0103775) [vnkt] description = Kathmandu Airport, Nepal @@ -31382,6 +31384,7 @@ metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/ZBYN.TXT description = Guangzhou, China location = (0.4043346, 1.9780398) metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/ZGGG.TXT +zone = ('hkz000', 0.0199677) [zgha] description = Changsha, China @@ -31392,6 +31395,7 @@ metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/ZGHA.TXT description = Guilin, China location = (0.4421501, 1.9250982) metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/ZGKL.TXT +zone = ('hkz000', 0.0811393) [zgnn] description = Nanning, China @@ -31402,11 +31406,13 @@ metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/ZGNN.TXT description = Shantou, China location = (0.4084070, 2.0365083) metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/ZGOW.TXT +zone = ('hkz000', 0.0443041) [zgsz] description = Shenzhen, China location = (0.3935717, 1.9914207) metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/ZGSZ.TXT +zone = ('hkz000', 0.0040134) [zhcc] description = Zhengzhou, China @@ -31422,6 +31428,7 @@ metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/ZHHH.TXT description = Haikou Meilan International Airport, Haikou, 46, CN location = (0.3479296, 1.9278732) metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/ZJHK.TXT +zone = ('hkz000', 0.0736704) [zjsy] description = Sanya/Fenghuang, China @@ -31452,6 +31459,7 @@ metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/ZPPP.TXT description = Xiamen, China location = (0.4273148, 2.0609430) metar = https://tgftp.nws.noaa.gov/data/observations/metar/decoded/ZSAM.TXT +zone = ('hkz000', 0.0728636) [zsfz] description = Fuzhou, China diff --git a/weather.py b/weather.py index 78fd79c..369ce99 100644 --- a/weather.py +++ b/weather.py @@ -238,6 +238,9 @@ def get_uri( ) sys.stderr.write(message) sys.exit(1) + # Some data sources are HTML with the plain text wrapped in pre tags + if "
" in data:
+            data = data[data.find("
")+5:data.find("
")] if cache_data: try: import codecs diff --git a/zctas b/zctas index 666c9d9..8edf4db 100644 --- a/zctas +++ b/zctas @@ -20,7 +20,7 @@ # ab78f945488371035514fc2c14e4679a 2020-05-24 airports.csv # # ...and these manually-generated or hand-compiled adjustments: -# aadcf8801156f29dc5c622bb5e874e88 2020-05-24 overrides.conf +# 298b10d8d6f5a4a41b2eb0c356766427 2020-05-24 overrides.conf # ab8545489a62124779edf7214a619325 2020-05-24 slist # 12c84e28cdb6da9eeba12b5a4af034b0 2020-05-24 zlist diff --git a/zones b/zones index 7265b3a..3be68d5 100644 --- a/zones +++ b/zones @@ -20,7 +20,7 @@ # ab78f945488371035514fc2c14e4679a 2020-05-24 airports.csv # # ...and these manually-generated or hand-compiled adjustments: -# aadcf8801156f29dc5c622bb5e874e88 2020-05-24 overrides.conf +# 298b10d8d6f5a4a41b2eb0c356766427 2020-05-24 overrides.conf # ab8545489a62124779edf7214a619325 2020-05-24 slist # 12c84e28cdb6da9eeba12b5a4af034b0 2020-05-24 zlist @@ -14710,6 +14710,13 @@ station = ('phsf', 0.0040525) urgent_weather_message = https://tgftp.nws.noaa.gov/data/watches_warnings/non_precip/hi/hiz028.txt zone_forecast = https://tgftp.nws.noaa.gov/data/forecasts/zone/hi/hiz028.txt +[hkz000] +centroid = (0.3897902, 1.9928751) +comment = suggested by Bill Agee +description = Hong Kong Observatory +station = ('vhhh', 0.0000000) +zone_forecast = https://www.hko.gov.hk/textonly/v2/forecast/nday.htm + [iaz001] centroid = (0.7571326, -1.6791865) coastal_flood_statement = https://tgftp.nws.noaa.gov/data/watches_warnings/flood/coastal/ia/iaz001.txt -- 2.11.0