summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Dana <ferdnyc@gmail.com>2016-08-24 19:19:00 -0700
committerGiovanni Campagna <gcampagna@src.gnome.org>2016-08-28 17:12:00 -0700
commit6b0586d95f5632c92b2fbbcb68426bfe5be51098 (patch)
tree1486a51d1393a7984f1c7e18614b35c4a9a0d8a0
parenta81f9dc3bdb5f753a4f96569865f233a09c41ff8 (diff)
downloadlibgweather-6b0586d95f5632c92b2fbbcb68426bfe5be51098.tar.gz
Switch to new METAR data provider
NOAA shut down their METAR service, so we need to switch to their recommended service, aviationweather.gov, for our data. https://bugzilla.gnome.org/show_bug.cgi?id=770321
-rw-r--r--libgweather/weather-metar.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/libgweather/weather-metar.c b/libgweather/weather-metar.c
index b8ac2b1..9d782da 100644
--- a/libgweather/weather-metar.c
+++ b/libgweather/weather-metar.c
@@ -580,7 +580,7 @@ metar_finish (SoupSession *session, SoupMessage *msg, gpointer data)
loc = &priv->location;
- searchkey = g_strdup_printf ("\n%s", loc->code);
+ searchkey = g_strdup_printf ("<raw_text>%s", loc->code);
p = strstr (msg->response_body->data, searchkey);
g_free (searchkey);
if (p) {
@@ -592,8 +592,8 @@ metar_finish (SoupSession *session, SoupMessage *msg, gpointer data)
metar = g_strdup (p);
success = metar_parse (metar, info);
g_free (metar);
- } else if (!strstr (msg->response_body->data, "National Weather Service")) {
- /* The response doesn't even seem to have come from NWS...
+ } else if (!strstr (msg->response_body->data, "aviationweather.gov")) {
+ /* The response doesn't even seem to have come from NOAA...
* most likely it is a wifi hotspot login page. Call that a
* network error.
*/
@@ -620,8 +620,14 @@ metar_start_open (GWeatherInfo *info)
loc = &priv->location;
msg = soup_form_request_new (
- "GET", "http://weather.noaa.gov/cgi-bin/mgetmetar.pl",
- "cccc", loc->code,
+ "GET", "https://www.aviationweather.gov/adds/dataserver_current/httpparam",
+ "dataSource", "metars",
+ "requestType", "retrieve",
+ "format", "xml",
+ "hoursBeforeNow", "3",
+ "mostRecent", "true",
+ "fields", "raw_text",
+ "stationString", loc->code,
NULL);
_gweather_info_begin_request (info, msg);
soup_session_queue_message (priv->session, msg, metar_finish, info);