diff options
author | mvglasow <michael -at- vonglasow.com> | 2017-11-29 18:36:15 +0100 |
---|---|---|
committer | mvglasow <michael -at- vonglasow.com> | 2017-11-29 18:36:15 +0100 |
commit | c86c107dae333fee628e78bf7327dfb187560630 (patch) | |
tree | c0235f9b83ee83d8b888d107da72d6b01418fd2f /navit | |
parent | bfffc8f916ed668f2dbdfd3d35d8a45949e289b7 (diff) | |
download | navit-c86c107dae333fee628e78bf7327dfb187560630.tar.gz |
Add:traffic:Store mapset and route
Signed-off-by: mvglasow <michael -at- vonglasow.com>
Diffstat (limited to 'navit')
-rw-r--r-- | navit/navit.c | 15 | ||||
-rw-r--r-- | navit/traffic.c | 10 | ||||
-rw-r--r-- | navit/traffic.h | 21 |
3 files changed, 46 insertions, 0 deletions
diff --git a/navit/navit.c b/navit/navit.c index db2304888..75975996b 100644 --- a/navit/navit.c +++ b/navit/navit.c @@ -2073,6 +2073,9 @@ navit_init(struct navit *this_) struct map *map; int callback; char *center_file; + struct attr_iter *iter; + struct attr *attr; + struct traffic * traffic; dbg(lvl_info,"enter gui %p graphics %p\n",this_->gui,this_->gra); @@ -2140,6 +2143,18 @@ navit_init(struct navit *this_) if (this_->route) tracking_set_route(this_->tracking, this_->route); } + + attr = g_new0(struct attr, 1); + iter = navit_attr_iter_new(); + while (navit_get_attr(this_, attr_traffic, attr, iter)) { + traffic = (struct traffic *) attr->u.navit_object; + traffic_set_mapset(traffic, ms); + if (this_->route) + traffic_set_route(traffic, this_->route); + } + navit_attr_iter_destroy(iter); + g_free(attr); + if (this_->navigation) { if ((map=navigation_get_map(this_->navigation))) { struct attr map_a,active; diff --git a/navit/traffic.c b/navit/traffic.c index 0ed290ee2..cc219c540 100644 --- a/navit/traffic.c +++ b/navit/traffic.c @@ -53,6 +53,8 @@ struct traffic { struct traffic_methods meth; /**< Methods implemented by the plugin */ struct callback * callback; /**< The callback function for the idle loop */ struct event_timeout * timeout; /**< The timeout event that triggers the loop function */ + struct mapset *ms; /**< The mapset used for routing */ + struct route *rt; /**< The route to notify of traffic changes */ }; /** @@ -476,6 +478,14 @@ void traffic_init(void) { plugin_register_category_map("traffic", traffic_map_new); } +void traffic_set_mapset(struct traffic *this_, struct mapset *ms) { + this_->ms = ms; +} + +void traffic_set_route(struct traffic *this_, struct route *rt) { + this_->rt = rt; +} + struct object_func traffic_func = { attr_traffic, (object_func_new)traffic_new, diff --git a/navit/traffic.h b/navit/traffic.h index 03aa41f9a..ceb96ee91 100644 --- a/navit/traffic.h +++ b/navit/traffic.h @@ -375,6 +375,10 @@ struct traffic_message { struct traffic_event ** events; /*!< Points to an array of pointers to the events for this message. */ }; +struct map; +struct mapset; +struct traffic; + /** * @brief Creates a new {@code traffic_point}. * @@ -717,6 +721,23 @@ struct traffic_event * traffic_message_get_event(struct traffic_message * this_, */ void traffic_init(void); +/** + * @brief Sets the mapset for the traffic plugin. + * + * This sets the mapset from which the segments affected by a traffic report will be retrieved. + * + * @param this_ The traffic plugin instance + * @param ms The mapset + */ +void traffic_set_mapset(struct traffic *this_, struct mapset *ms); + +/** + * @brief Sets the route for the traffic plugin. + * + * This sets the route which may get notified by the traffic plugin if traffic distortions change. + */ +void traffic_set_route(struct traffic *this_, struct route *rt); + /* end of prototypes */ #ifdef __cplusplus } |