summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormvglasow <michael -at- vonglasow.com>2018-08-15 22:53:38 +0200
committermvglasow <michael -at- vonglasow.com>2018-08-15 22:56:29 +0200
commit41775035e69d7eddf8539b9b65cbb0273a1aba3d (patch)
tree59d549b48ba922dbd2c7236ab5a448e391adfe8e
parent857d45434d2d93781c4b185fcb9e47e2bbb58113 (diff)
downloadnavit-41775035e69d7eddf8539b9b65cbb0273a1aba3d.tar.gz
Add:traffic:API function to return all items associated with a message
Signed-off-by: mvglasow <michael -at- vonglasow.com>
-rw-r--r--navit/traffic.c16
-rw-r--r--navit/traffic.h14
2 files changed, 30 insertions, 0 deletions
diff --git a/navit/traffic.c b/navit/traffic.c
index 618d18c23..b4265f911 100644
--- a/navit/traffic.c
+++ b/navit/traffic.c
@@ -4705,6 +4705,22 @@ struct traffic_event * traffic_message_get_event(struct traffic_message * this_,
return NULL;
}
+struct item ** traffic_message_get_items(struct traffic_message * this_) {
+ struct item ** ret;
+ struct item ** in;
+ int i;
+ if (!this_->priv->items) {
+ ret = g_new0(struct item *, 1);
+ return ret;
+ }
+ in = this_->priv->items;
+ for (i = 1; *in; i++)
+ in++;
+ ret = g_new0(struct item *, i);
+ memcpy(ret, this_->priv->items, sizeof(struct item *) * i);
+ return ret;
+}
+
/**
* @brief Registers a new traffic map plugin
*
diff --git a/navit/traffic.h b/navit/traffic.h
index 5298b888e..494250001 100644
--- a/navit/traffic.h
+++ b/navit/traffic.h
@@ -883,6 +883,20 @@ void traffic_message_add_event(struct traffic_message * this_, struct traffic_ev
struct traffic_event * traffic_message_get_event(struct traffic_message * this_, int index);
/**
+ * @brief Returns the items associated with a message.
+ *
+ * Note that no map rectangle is required to obtain traffic items. This behavior is particular to traffic items, which
+ * do not rely on a map rectangle. Items obtained from other maps may behave differently.
+ *
+ * @param this_ The message
+ *
+ * @return Items as a NULL-terminated array. The caller is responsible for freeing the array (not its elements) when it
+ * is no longer needed. This method will always return a valid pointer—if no items are associated with the message, an
+ * empty array (with just one single NULL element) will be returned. No particular order is guaranteed for the items.
+ */
+struct item ** traffic_message_get_items(struct traffic_message * this_);
+
+/**
* @brief Initializes the traffic plugin.
*
* This function is called once on startup.