diff options
author | Erich Eckner <git@eckner.net> | 2018-10-25 16:33:17 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-10-25 16:33:17 +0200 |
commit | 6146a1783aaa67b3869612eeeaca47a63a8b2c13 (patch) | |
tree | 0c1ecdc1b8a138c96bc1983ebc0a2373f442510e /input_gadgets.c | |
parent | df15ba80e1fcbd48f6e0a6a7ce1c25d52f322b6b (diff) | |
download | anzeige-6146a1783aaa67b3869612eeeaca47a63a8b2c13.tar.xz |
input_gadgets: alle geocodes abfragen, polygon-Abfrage vorbereitet
Diffstat (limited to 'input_gadgets.c')
-rw-r--r-- | input_gadgets.c | 82 |
1 files changed, 50 insertions, 32 deletions
diff --git a/input_gadgets.c b/input_gadgets.c index 2abd7a9..43e38b0 100644 --- a/input_gadgets.c +++ b/input_gadgets.c @@ -589,43 +589,61 @@ int gadgets_retrieve_weather_warnings(unsigned char *output, int max_len) int is_relevant = 0; for (sub_node = cur_node; sub_node = xml_find_node_by_name(sub_node, "area"); sub_node = sub_node -> next) { - xmlNode *sub_sub_node = xml_find_node_by_name(sub_node -> children, "geocode"); - if (sub_sub_node == NULL) // no geocode available - probably a polygon <<TODO>> - continue; - text = xml_extract_string(doc, sub_sub_node -> children, "valueName"); - if (text == NULL) { - fprintf(stderr, "Failed to enter <valueName>\n"); - free(inflated); - free(chunk.memory); - for (int i=0; i<warnings_len; i++) { - free(warnings[i].headline); - free(warnings[i].event); + xmlNode *sub_sub_node; + for (sub_sub_node = sub_node -> children; sub_sub_node = xml_find_node_by_name(sub_sub_node, "geocode"); sub_sub_node = sub_sub_node -> next) { + text = xml_extract_string(doc, sub_sub_node -> children, "valueName"); + if (text == NULL) { + fprintf(stderr, "Failed to enter <valueName>\n"); + free(inflated); + free(chunk.memory); + for (int i=0; i<warnings_len; i++) { + free(warnings[i].headline); + free(warnings[i].event); + } + free(warnings); + xmlFreeDoc(doc); + return EXIT_FAILURE; + } + if (strcmp(text,"WARNCELLID")!=0) { + xmlFree(text); + continue; } - free(warnings); - xmlFreeDoc(doc); - return EXIT_FAILURE; - } - if (strcmp(text,"WARNCELLID")!=0) { xmlFree(text); - continue; + text = xml_extract_string(doc, sub_sub_node -> children, "value"); + if (text == NULL) { + fprintf(stderr, "Failed to enter <value>\n"); + free(inflated); + free(chunk.memory); + for (int i=0; i<warnings_len; i++) { + free(warnings[i].headline); + free(warnings[i].event); + } + free(warnings); + xmlFreeDoc(doc); + return EXIT_FAILURE; + } + if (strcmp(text,"816053000")==0) // Stadt Jena + is_relevant = 1; + xmlFree(text); } - xmlFree(text); - text = xml_extract_string(doc, sub_sub_node -> children, "value"); - if (text == NULL) { - fprintf(stderr, "Failed to enter <value>\n"); - free(inflated); - free(chunk.memory); - for (int i=0; i<warnings_len; i++) { - free(warnings[i].headline); - free(warnings[i].event); + for (sub_sub_node = sub_node -> children; sub_sub_node = xml_find_node_by_name(sub_sub_node, "polygon"); sub_sub_node = sub_sub_node -> next) { + text = xmlNodeListGetString(doc, sub_sub_node -> children, 0); + if (text == NULL) { + fprintf(stderr, "Failed to read text of <polygon>\n"); + free(inflated); + free(chunk.memory); + for (int i=0; i<warnings_len; i++) { + free(warnings[i].headline); + free(warnings[i].event); + } + free(warnings); + xmlFreeDoc(doc); + return EXIT_FAILURE; } - free(warnings); - xmlFreeDoc(doc); - return EXIT_FAILURE; +/* if (point_is_inside_polygon(50.8830, 11.6223, text)) <<TODO>> + is_relevant = 1; */ + xmlFree(text); } - if (strcmp(text,"816053000")==0) // Stadt Jena - is_relevant = 1; - xmlFree(text); } if (!is_relevant) continue; |