navit
0.5.3-trunk
|
Contains code related to processing traffic messages into map items. More...
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include "glib_slice.h"
#include "config.h"
#include "navit.h"
#include "util.h"
#include "coord.h"
#include "item.h"
#include "map.h"
#include "mapset.h"
#include "route_protected.h"
#include "route.h"
#include "transform.h"
#include "xmlconfig.h"
#include "traffic.h"
#include "plugin.h"
#include "fib.h"
#include "event.h"
#include "callback.h"
#include "vehicleprofile.h"
#include "debug.h"
Data Structures | |
struct | traffic_shared_priv |
Private data shared between all traffic instances. More... | |
struct | traffic |
A traffic plugin instance. More... | |
struct | traffic_location_priv |
struct | traffic_message_priv |
struct | map_priv |
Represents the map from a single binfile. More... | |
struct | map_rect_priv |
Implementation-specific map rect data. More... | |
struct | item_msg_priv |
Message-specific map private data. More... | |
struct | item_priv |
Implementation-specific item data for traffic map items. More... | |
struct | parsed_item |
Parsed data for a cached item. More... | |
struct | seg_data |
Data for segments affected by a traffic message. More... | |
struct | point_data |
struct | xml_state |
State for the XML parser. More... | |
struct | xml_element |
Data for an XML element. More... | |
Macros | |
#define | MESSAGE_UPDATE_MESSAGES 1 << 0 |
#define | MESSAGE_UPDATE_SEGMENTS 1 << 1 |
#define | PENALTY_OFFROAD 8 |
#define | PENALTY_SEGMENT_MATCH 4 |
#define | PENALTY_POINT_MATCH 24 |
#define | PROCESS_MESSAGES_PURGE_EXPIRED 1 << 0 |
#define | PROCESS_MESSAGES_NO_DUMP_STORE 1 << 1 |
#define | ROUTE_ORDER(x) |
#define | ROUTE_RECT_DIST_ABS(x) ((x == location_fuzziness_low_res) ? 1000 : 100) |
#define | ROUTE_RECT_DIST_REL(x) 0 |
#define | TEXTFILE_LINE_SIZE 512 |
#define | TIME_SLICE 40 |
Functions | |
static struct seg_data * | seg_data_new (void) |
Creates a new struct seg_data and initializes it with default values. More... | |
static struct item * | tm_add_item (struct map *map, enum item_type type, int id_hi, int id_lo, int flags, struct attr **attrs, struct coord *c, int count, char *id) |
Adds an item to the map. More... | |
static void | tm_destroy (struct map_priv *priv) |
Destroys (closes) the traffic map. More... | |
static void | tm_coord_rewind (void *priv_data) |
Rewinds the coordinates of the currently selected item. More... | |
static void | tm_item_destroy (struct item *item) |
Destroys a traffic map item. More... | |
static struct item * | tm_item_ref (struct item *item) |
References a traffic map item. More... | |
static struct item * | tm_item_unref (struct item *item) |
Unreferences a traffic map item. More... | |
static void | tm_item_update_attrs (struct item *item, struct route *route) |
Updates the attributes of an item. More... | |
static int | tm_coord_get (void *priv_data, struct coord *c, int count) |
Returns the coordinates of a traffic item. More... | |
static void | tm_attr_rewind (void *priv_data) |
Rewinds the attributes of the currently selected item. More... | |
static int | tm_attr_get (void *priv_data, enum attr_type attr_type, struct attr *attr) |
static int | tm_type_set (void *priv_data, enum item_type type) |
Sets the type of a traffic item. More... | |
static struct map_selection * | traffic_location_get_rect (struct traffic_location *this_, enum projection projection) |
static struct route_graph * | traffic_location_get_route_graph (struct traffic_location *this_, struct mapset *ms) |
Builds a new route graph for traffic location matching. More... | |
static int | traffic_location_match_attributes (struct traffic_location *this_, struct item *item) |
Determines the degree to which the attributes of a location and a map item match. More... | |
static int | traffic_message_add_segments (struct traffic_message *this_, struct mapset *ms, struct seg_data *data, struct map *map, struct route *route) |
Generates segments affected by a traffic message. More... | |
static int | traffic_message_restore_segments (struct traffic_message *this_, struct mapset *ms, struct map *map, struct route *route) |
Restores segments associated with a traffic message from cached data. More... | |
static void | traffic_location_populate_route_graph (struct traffic_location *this_, struct route_graph *rg, struct mapset *ms) |
Populates a route graph. More... | |
static void | traffic_location_set_enclosing_rect (struct traffic_location *this_, struct coord_geo **coords) |
Sets the rectangle enclosing all points of a location. More... | |
static void | traffic_dump_messages_to_xml (struct traffic_shared_priv *shared) |
Dumps all currently active traffic messages to an XML file. More... | |
static void | traffic_loop (struct traffic *this_) |
The loop function for the traffic module. More... | |
static struct traffic * | traffic_new (struct attr *parent, struct attr **attrs) |
Instantiates the traffic plugin. More... | |
static int | traffic_process_messages_int (struct traffic *this_, int flags) |
Processes new traffic messages. More... | |
static void | traffic_message_dump_to_stderr (struct traffic_message *this_) |
Prints a dump of a message to debug output. More... | |
static struct seg_data * | traffic_message_parse_events (struct traffic_message *this_) |
Parses the events of a traffic message. More... | |
static struct route_graph_point * | traffic_route_flood_graph (struct route_graph *rg, struct seg_data *data, struct coord *c_start, struct coord *c_dst, struct route_graph_point *start_existing) |
Determines the path between two reference points in a route graph. More... | |
static void | traffic_message_remove_item_data (struct traffic_message *old, struct traffic_message *new, struct route *route) |
Removes message data from the items associated with a message. More... | |
static int | boolean_new (const char *string, int deflt) |
Creates a Boolean value from its string representation. More... | |
static void | parsed_item_destroy (struct parsed_item *this_) |
Destructor for struct parsed_item More... | |
static time_t | time_new (char *string) |
Creates a timestamp from its ISO8601 representation. More... | |
static int | seg_data_equals (struct seg_data *l, struct seg_data *r) |
Whether two struct seg_data contain the same data. More... | |
static int | tm_item_add_message_data (struct item *item, char *msgid, int speed, int delay, struct attr **attrs, struct route *route) |
Adds message data to a traffic map item. More... | |
static struct item * | tm_find_item (struct map_rect *mr, enum item_type type, struct attr **attrs, struct coord *c, int count) |
Returns an item from the map which matches the supplied data. More... | |
static void | tm_item_dump_to_file (struct item *item, FILE *f) |
Dumps an item to a file in textfile format. More... | |
static void | tm_dump_item_to_textfile (struct item *item) |
Dumps an item to a textfile map. More... | |
static void | tm_dump_to_textfile (struct map *map) |
Dumps the traffic map to a textfile map. More... | |
static struct map_rect_priv * | tm_rect_new (struct map_priv *priv, struct map_selection *sel) |
Opens a new map rectangle on the traffic map. More... | |
static void | tm_rect_destroy (struct map_rect_priv *mr) |
Destroys a map rectangle on the traffic map. More... | |
static struct item * | tm_get_item (struct map_rect_priv *mr) |
Returns the next item from the traffic map. More... | |
static struct item * | tm_get_item_byid (struct map_rect_priv *mr, int id_hi, int id_lo) |
Returns the next item with the supplied ID from the traffic map. More... | |
static struct item * | tm_rect_create_item (struct map_rect_priv *mr, enum item_type type) |
Creates a new item of the specified type and inserts it into the map. More... | |
static int | tm_get_attr (struct map_priv *priv, enum attr_type type, struct attr *attr) |
Gets an attribute from the traffic map. More... | |
static int | tm_attr_get (void *priv_data, enum attr_type attr_type, struct attr *attr) |
Returns the next attribute of a traffic item which matches the specified type. More... | |
static int | traffic_event_is_valid (struct traffic_event *this_) |
Whether the contents of an event are valid. More... | |
static int | traffic_point_match_attributes (struct traffic_point *this_, struct item *item) |
Determines the degree to which the attributes of a point and a map item match. More... | |
static int | traffic_point_match_segment_attributes (struct traffic_point *this_, struct route_graph_point *p, struct route_graph_point *start, int match_start) |
Determines the degree to which the attributes of a point match those of the segments connecting to it. More... | |
static int | traffic_route_get_seg_cost (struct route_graph_segment *over, struct seg_data *data, int dir) |
Returns the cost of the segment in the given direction. More... | |
static int | traffic_location_get_point_triple (struct traffic_location *this_, struct coord_geo **coords) |
Determines the “point triple” for a traffic location. More... | |
static struct map_selection * | traffic_location_get_rect (struct traffic_location *this_, enum projection projection) |
Obtains a map selection for the traffic location. More... | |
static struct map_rect * | traffic_location_open_map_rect (struct traffic_location *this_, struct route_graph *rg) |
Opens a map rectangle around the end points of the traffic location. More... | |
static int | traffic_point_equals (struct traffic_point *l, struct traffic_point *r) |
Whether two traffic points are equal. More... | |
static int | traffic_location_equals (struct traffic_location *l, struct traffic_location *r) |
Whether two traffic locations are equal. More... | |
static struct route_graph_segment * | traffic_route_append (struct route_graph *rg, struct route_graph_segment *last, struct route_graph_point *end) |
Extends the route beyond its end point. More... | |
static struct route_graph_point * | traffic_route_prepend (struct route_graph *rg, struct route_graph_point *start) |
Extends the route beyond its start point. More... | |
static struct traffic_point * | traffic_location_get_point (struct traffic_location *this_, int point) |
Returns one of the traffic location’s points. More... | |
static int | traffic_location_get_point_match (struct traffic_location *this_, struct route_graph_point *p, int point, struct route_graph *rg, struct route_graph_point *start, int match_start, struct mapset *ms) |
Compares a given point to the traffic location and returns a score. More... | |
static GList * | traffic_location_get_matching_points (struct traffic_location *this_, int point, struct route_graph *rg, struct route_graph_point *start, int match_start, struct mapset *ms) |
Returns points from the route graph which match a traffic location. More... | |
static int | traffic_location_is_valid (struct traffic_location *this_) |
Whether the contents of a location are valid. More... | |
static int | route_graph_point_is_endpoint_candidate (struct route_graph_point *this_, struct route_graph_segment *s_prev) |
Whether the current point is a candidate for low-res endpoint matching. More... | |
static int | traffic_get_item_speed (struct item *item, struct seg_data *data, int item_maxspeed) |
Gets the speed for a traffic distortion item. More... | |
static int | traffic_get_item_delay (int delay, int item_len, int len) |
Gets the delay for a traffic distortion item. More... | |
static int | traffic_message_is_valid (struct traffic_message *this_) |
Whether the contents of a message are valid. More... | |
static void | traffic_set_shared (struct traffic *this_) |
Ensures the traffic instance points to valid shared data. More... | |
static struct xml_element * | traffic_xml_element_new (const char *tag_name, const char **names, const char **values) |
Creates a new XML element structure. More... | |
static void | traffic_xml_element_destroy (struct xml_element *this_) |
Frees up an XML element structure. More... | |
static char * | traffic_xml_get_attr (const char *attr, char **names, char **values) |
Retrieves the value of an XML attribute. More... | |
static int | traffic_xml_is_tagstack_valid (struct xml_state *state) |
Whether the tag stack represents a hierarchy of elements which is recognized. More... | |
static void | traffic_xml_start (xml_context *dummy, const char *tag_name, const char **names, const char **values, void *data, GError **error) |
Callback function which gets called when an opening tag is encountered. More... | |
static void | traffic_xml_end (xml_context *dummy, const char *tag_name, void *data, GError **error) |
Callback function which gets called when a closing tag is encountered. More... | |
static void | traffic_xml_text (xml_context *dummy, const char *text, gsize len, void *data, GError **error) |
Callback function which gets called when character data is encountered. More... | |
enum event_class | event_class_new (char *string) |
Creates an event class from its string representation. More... | |
const char * | event_class_to_string (enum event_class this_) |
Translates an event class to its string representation. More... | |
enum event_type | event_type_new (char *string) |
Creates an event type from its string representation. More... | |
const char * | event_type_to_string (enum event_type this_) |
Translates an event type to its string representation. More... | |
enum item_type | item_type_from_road_type (char *string, int is_urban) |
Creates an item type from a road type. More... | |
enum location_dir | location_dir_new (char *string) |
Creates a location directionality from its string representation. More... | |
enum location_fuzziness | location_fuzziness_new (char *string) |
Creates a location fuzziness from its string representation. More... | |
const char * | location_fuzziness_to_string (enum location_fuzziness this_) |
Translates location fuzziness to its string representation. More... | |
enum location_ramps | location_ramps_new (char *string) |
Creates an enum location_ramps from its string representation. More... | |
const char * | location_ramps_to_string (enum location_ramps this_) |
Translates an enum location_ramps to its string representation. More... | |
enum si_class | si_class_new (char *string) |
Creates a supplementary information class from its string representation. More... | |
const char * | si_class_to_string (enum si_class this_) |
Translates a supplementary information class to its string representation. More... | |
enum si_type | si_type_new (char *string) |
Creates a supplementary information type from its string representation. More... | |
const char * | si_type_to_string (enum si_type this_) |
Translates a supplementary information type to its string representation. More... | |
struct traffic_point * | traffic_point_new (float lon, float lat, char *junction_name, char *junction_ref, char *tmc_id) |
Creates a new traffic_point . More... | |
struct traffic_point * | traffic_point_new_short (float lon, float lat) |
Creates a new traffic_point . More... | |
void | traffic_point_destroy (struct traffic_point *this_) |
Destroys a traffic_point . More... | |
struct traffic_location * | traffic_location_new (struct traffic_point *at, struct traffic_point *from, struct traffic_point *to, struct traffic_point *via, struct traffic_point *not_via, char *destination, char *direction, enum location_dir directionality, enum location_fuzziness fuzziness, enum location_ramps ramps, enum item_type road_type, char *road_name, char *road_ref, char *tmc_table, int tmc_direction) |
Creates a new traffic_location . More... | |
struct traffic_location * | traffic_location_new_short (struct traffic_point *at, struct traffic_point *from, struct traffic_point *to, struct traffic_point *via, struct traffic_point *not_via, enum location_dir directionality, enum location_fuzziness fuzziness) |
Creates a new traffic_location . More... | |
void | traffic_location_destroy (struct traffic_location *this_) |
Destroys a traffic_location . More... | |
struct traffic_suppl_info * | traffic_suppl_info_new (enum si_class si_class, enum si_type type, struct quantifier *quantifier) |
Creates a new traffic_suppl_info . More... | |
void | traffic_suppl_info_destroy (struct traffic_suppl_info *this_) |
Destroys a traffic_suppl_info . More... | |
struct traffic_event * | traffic_event_new (enum event_class event_class, enum event_type type, int length, int speed, struct quantifier *quantifier, int si_count, struct traffic_suppl_info **si) |
Creates a new traffic_event . More... | |
struct traffic_event * | traffic_event_new_short (enum event_class event_class, enum event_type type) |
Creates a new traffic_event . More... | |
void | traffic_event_destroy (struct traffic_event *this_) |
Destroys a traffic_event . More... | |
void | traffic_event_add_suppl_info (struct traffic_event *this_, struct traffic_suppl_info *si) |
Adds a supplementary information item to an event. More... | |
struct traffic_suppl_info * | traffic_event_get_suppl_info (struct traffic_event *this_, int index) |
Retrieves a supplementary information item associated with an event. More... | |
struct traffic_message * | traffic_message_new (char *id, time_t receive_time, time_t update_time, time_t expiration_time, time_t start_time, time_t end_time, int is_cancellation, int is_forecast, int replaced_count, char **replaces, struct traffic_location *location, int event_count, struct traffic_event **events) |
Creates a new traffic_message . More... | |
struct traffic_message * | traffic_message_new_short (char *id, time_t receive_time, time_t update_time, time_t expiration_time, int is_forecast, struct traffic_location *location, int event_count, struct traffic_event **events) |
Creates a new traffic_message . More... | |
struct traffic_message * | traffic_message_new_single_event (char *id, time_t receive_time, time_t update_time, time_t expiration_time, int is_forecast, struct traffic_location *location, enum event_class event_class, enum event_type type) |
Creates a new single-event traffic_message . More... | |
struct traffic_message * | traffic_message_new_cancellation (char *id, time_t receive_time, time_t update_time, time_t expiration_time, struct traffic_location *location) |
Creates a new cancellation traffic_message . More... | |
void | traffic_message_destroy (struct traffic_message *this_) |
Destroys a traffic_message . More... | |
void | traffic_message_add_event (struct traffic_message *this_, struct traffic_event *event) |
Adds an event to a message. More... | |
struct traffic_event * | traffic_message_get_event (struct traffic_message *this_, int index) |
Retrieves an event associated with a message. More... | |
struct item ** | traffic_message_get_items (struct traffic_message *this_) |
Returns the items associated with a message. More... | |
static struct map_priv * | traffic_map_new (struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) |
Registers a new traffic map plugin. More... | |
void | traffic_init (void) |
Initializes the traffic plugin. More... | |
struct map * | traffic_get_map (struct traffic *this_) |
Returns the map for the traffic plugin. More... | |
static struct traffic_message ** | traffic_get_messages_from_parsed_xml (struct xml_state *state) |
Reads previously stored traffic messages from parsed XML data. More... | |
struct traffic_message ** | traffic_get_messages_from_xml_file (struct traffic *this_, char *filename) |
Reads previously stored traffic messages from an XML file. More... | |
struct traffic_message ** | traffic_get_messages_from_xml_string (struct traffic *this_, char *xml) |
Reads traffic messages from an XML string. More... | |
struct traffic_message ** | traffic_get_stored_messages (struct traffic *this_) |
Returns currently active traffic messages. More... | |
void | traffic_process_messages (struct traffic *this_, struct traffic_message **messages) |
Processes new traffic messages. More... | |
void | traffic_set_mapset (struct traffic *this_, struct mapset *ms) |
Sets the mapset for the traffic plugin. More... | |
void | traffic_set_route (struct traffic *this_, struct route *rt) |
Sets the route for the traffic plugin. More... | |
void | traffic_destroy (struct traffic *this_) |
Destructor. More... | |
Variables | |
int | item_default_flags_value = AF_ALL |
static struct map_methods | traffic_map_meth |
static struct item_methods | methods_traffic_item |
struct object_func | traffic_func |
Contains code related to processing traffic messages into map items.
Navit, a modular navigation system. Copyright (C) 2005-2017 Navit Team
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Currently the only map items supported are traffic distortions. More may be added in the future.
Traffic distortions are used by Navit to route around traffic problems.
#define MESSAGE_UPDATE_MESSAGES 1 << 0 |
Flag to indicate new messages have been received
#define MESSAGE_UPDATE_SEGMENTS 1 << 1 |
Flag to indicate segments have changed
#define PENALTY_OFFROAD 8 |
The penalty applied to an off-road link
#define PENALTY_POINT_MATCH 24 |
The maximum penalty applied to points with non-matching attributes
#define PENALTY_SEGMENT_MATCH 4 |
The penalty applied to segments with non-matching attributes
#define PROCESS_MESSAGES_NO_DUMP_STORE 1 << 1 |
Flag to indicate the message store should not be exported
#define PROCESS_MESSAGES_PURGE_EXPIRED 1 << 0 |
Flag to indicate expired messages should be purged
#define ROUTE_ORDER | ( | x | ) |
The lowest order of items to consider (always the default order for the next-lower road type)
#define ROUTE_RECT_DIST_ABS | ( | x | ) | ((x == location_fuzziness_low_res) ? 1000 : 100) |
The buffer zone around the enclosing rectangle used in route calculations, absolute distance
#define ROUTE_RECT_DIST_REL | ( | x | ) | 0 |
The buffer zone around the enclosing rectangle used in route calculations, relative to rect size
#define TEXTFILE_LINE_SIZE 512 |
Maximum textfile line size
#define TIME_SLICE 40 |
Time slice for idle loops, in milliseconds
|
static |
Creates a Boolean value from its string representation.
If the string equals true
, yes
or can be parsed to a nonzero integer, the result is true.
If the string equals false
, no
or begins with the digit 0 and returns zero when parsed to an integer, the result is false.
If NULL is supplied, or if the string does not match any known value, the result is the default value.
String comparison is case-insensitive.
Since true is always represented by a return value of 1, passing a deflt
other than 0 or 1 allows the caller to determine if the string could be parsed correctly.
string | The string representation |
deflt | The default value to return if string is not a valid representation of a Boolean value. |
enum event_class
, or event_class_invalid
if string
does not match a known identifier Referenced by traffic_xml_end().
enum event_class event_class_new | ( | char * | string | ) |
Creates an event class from its string representation.
string | The string representation (case is ignored) |
enum event_class
, or event_class_invalid
if string
does not match a known identifier References data, dbg, xml_state::is_opened, xml_state::is_valid, lvl_debug, xml_state::tagstack, and xml_element::text.
Referenced by traffic_xml_end().
const char* event_class_to_string | ( | enum event_class | this_ | ) |
Translates an event class to its string representation.
References event_class_congestion, event_class_delay, and event_class_restriction.
Referenced by traffic_dump_messages_to_xml(), and traffic_message_dump_to_stderr().
enum event_type event_type_new | ( | char * | string | ) |
Creates an event type from its string representation.
string | The string representation (case is ignored) |
enum event_type
, or event_invalid
if string
does not match a known identifier Referenced by event_request_system(), and traffic_xml_end().
const char* event_type_to_string | ( | enum event_type | this_ | ) |
Translates an event type to its string representation.
References event_congestion_cleared, event_congestion_forecast_withdrawn, event_congestion_heavy_traffic, event_congestion_long_queue, event_congestion_none, event_congestion_normal_traffic, event_congestion_queue, event_congestion_queue_likely, event_congestion_slow_traffic, event_congestion_stationary_traffic, event_congestion_stationary_traffic_likely, event_congestion_traffic_building_up, event_congestion_traffic_congestion, event_congestion_traffic_easing, event_congestion_traffic_flowing_freely, event_congestion_traffic_heavier_than_normal, event_congestion_traffic_lighter_than_normal, event_congestion_traffic_much_heavier_than_normal, event_congestion_traffic_problem, event_delay_clearance, event_delay_delay, event_delay_delay_possible, event_delay_forecast_withdrawn, event_delay_long_delay, event_delay_several_hours, event_delay_uncertain_duration, event_delay_very_long_delay, event_restriction_access_restrictions_lifted, event_restriction_all_carriageways_cleared, event_restriction_all_carriageways_reopened, event_restriction_batch_service, event_restriction_blocked, event_restriction_blocked_ahead, event_restriction_carriageway_blocked, event_restriction_carriageway_closed, event_restriction_closed, event_restriction_closed_ahead, event_restriction_contraflow, event_restriction_entry_blocked, event_restriction_entry_reopened, event_restriction_exit_blocked, event_restriction_exit_reopened, event_restriction_intermittent_closures, event_restriction_lane_blocked, event_restriction_lane_closed, event_restriction_open, event_restriction_ramp_blocked, event_restriction_ramp_closed, event_restriction_ramp_reopened, event_restriction_reduced_lanes, event_restriction_reopened, event_restriction_road_cleared, event_restriction_single_alternate_line_traffic, event_restriction_speed_limit, and event_restriction_speed_limit_lifted.
Referenced by traffic_dump_messages_to_xml(), and traffic_message_dump_to_stderr().
enum item_type item_type_from_road_type | ( | char * | string, |
int | is_urban | ||
) |
Creates an item type from a road type.
This is guaranteed to return either a routable type (i.e. route_item_first <= type <= route_item_last
) or type_line_unspecified
. The latter is also returned if string
refers to a Navit item type which is not routable.
string | A TraFF road type or the string representation of a Navit item type |
is_urban | Whether the road is in a built-up area (ignored if string is a Navit item type) |
enum item_type
, or type_line_unspecified
if string
does not match a known and routable identifier Referenced by traffic_xml_end().
enum location_dir location_dir_new | ( | char * | string | ) |
Creates a location directionality from its string representation.
string | The string representation (case is ignored) |
enum location_dir
, or location_dir_both
if string
does not match a known identifier Referenced by traffic_xml_end().
enum location_fuzziness location_fuzziness_new | ( | char * | string | ) |
Creates a location fuzziness from its string representation.
string | The string representation (case is ignored) |
enum location_fuzziness
, or location_fuzziness_none
if string
does not match a known identifier Referenced by traffic_xml_end().
const char* location_fuzziness_to_string | ( | enum location_fuzziness | this_ | ) |
Translates location fuzziness to its string representation.
location_fuzziness_none
References location_fuzziness_end_unknown, location_fuzziness_extent_unknown, location_fuzziness_low_res, and location_fuzziness_start_unknown.
Referenced by traffic_dump_messages_to_xml(), and traffic_message_dump_to_stderr().
enum location_ramps location_ramps_new | ( | char * | string | ) |
Creates an enum location_ramps
from its string representation.
string | The string representation (case is ignored) |
enum location_ramps
, or location_ramps_none
if string
does not match a known identifier Referenced by traffic_xml_end().
const char* location_ramps_to_string | ( | enum location_ramps | this_ | ) |
Translates an enum location_ramps
to its string representation.
References location_ramps_all, location_ramps_entry, location_ramps_exit, and location_ramps_none.
Referenced by traffic_dump_messages_to_xml(), and traffic_message_dump_to_stderr().
|
static |
Destructor for struct parsed_item
This frees up the struct parsed_item
and all associated data. The pointer passed to this function will be invalid after it returns.
References attr_list_free(), parsed_item::attrs, and parsed_item::coords.
Referenced by traffic_message_restore_segments().
|
static |
Whether the current point is a candidate for low-res endpoint matching.
this_ | The point to examine |
s_prev | The route segment leading to this_ (NULL for the start point) |
References AF_UNDERGROUND, route_graph_segment::data, route_graph_point::end, route_graph_segment::end_next, route_segment_data::flags, route_graph_point::seg, route_graph_point::start, and route_graph_segment::start_next.
Referenced by traffic_message_add_segments().
Whether two struct seg_data
contain the same data.
l
and r
are equal, false if not. Two NULL values are considered equal; a NULL value and a non-NULL value are not. References attr_search(), attr::attrs, seg_data::attrs, attr::data, seg_data::delay, seg_data::dir, seg_data::flags, seg_data::speed, seg_data::speed_factor, seg_data::speed_penalty, attr::type, seg_data::type, and attr::u.
Referenced by traffic_process_messages_int().
|
static |
Creates a new struct seg_data
and initializes it with default values.
References seg_data::speed, seg_data::speed_factor, and seg_data::type.
Referenced by traffic_message_parse_events().
enum si_class si_class_new | ( | char * | string | ) |
Creates a supplementary information class from its string representation.
string | The string representation (case is ignored) |
enum si_class
, or si_class_invalid
if string
does not match a known identifier Referenced by traffic_xml_start().
const char* si_class_to_string | ( | enum si_class | this_ | ) |
Translates a supplementary information class to its string representation.
References si_class_place, si_class_tendency, and si_class_vehicle.
Referenced by traffic_dump_messages_to_xml(), and traffic_message_dump_to_stderr().
enum si_type si_type_new | ( | char * | string | ) |
Creates a supplementary information type from its string representation.
string | The string representation (case is ignored) |
enum si_type
, or si_invalid
if string
does not match a known identifier Referenced by traffic_xml_start().
const char* si_type_to_string | ( | enum si_type | this_ | ) |
Translates a supplementary information type to its string representation.
References si_place_bridge, si_place_ramp, si_place_roadworks, si_place_tunnel, si_tendency_queue_decreasing, si_tendency_queue_increasing, si_vehicle_all, si_vehicle_bus, si_vehicle_car, si_vehicle_car_with_caravan, si_vehicle_car_with_trailer, si_vehicle_hazmat, si_vehicle_hgv, si_vehicle_motor, and si_vehicle_with_trailer.
Referenced by traffic_dump_messages_to_xml(), and traffic_message_dump_to_stderr().
|
static |
Creates a timestamp from its ISO8601 representation.
string | The ISO8601 timestamp |
string
is NULL. References iso8601_to_time().
Referenced by traffic_xml_end().
|
static |
Adds an item to the map.
If a matching item is already in the map, that item will be returned.
All data passed to this method is safe to free after the method returns, and doing so is the responsibility of the caller.
map | The traffic map |
type | Type of the item |
id_hi | First part of the ID of the item (item IDs have two parts) |
id_lo | Second part of the ID of the item |
flags | Flags used as a matching criterion, and added to newly-created items |
attrs | The attributes for the item |
c | Points to an array of coordinates for the item |
count | Number of items in c |
id | Message ID for the associated message |
References attr_generic_set_attr(), attr_list_dup(), attr_list_free(), attr::attrs, item_priv::attrs, c, item_priv::coord_count, item_priv::coords, item::id_hi, item::id_lo, attr::map, item::map, map_rect_create_item(), map_rect_destroy(), map_rect_new(), item::meth, methods_traffic_item, item_priv::mr, item_priv::next_attr, item_priv::next_coord, attr::num, item::priv_data, tm_find_item(), attr::type, type, and attr::u.
Referenced by traffic_message_add_segments(), and traffic_message_restore_segments().
Returns the next attribute of a traffic item which matches the specified type.
priv_data | The item's private data |
attr_type | The attribute type to retrieve, or attr_any to retrieve the next attribute, regardless of type |
attr | Receives the attribute |
References attr_dup_content(), and item_priv::next_attr.
|
static |
Rewinds the attributes of the currently selected item.
After rewinding, the next call to tm_attr_get()
will return the first attribute.
priv_data | The item's private data |
References item_priv::attrs, and item_priv::next_attr.
Referenced by tm_get_item().
|
static |
Returns the coordinates of a traffic item.
priv_data | The item's private data |
c | Pointer to a struct coord array where coordinates will be stored |
count | The maximum number of coordinates to retrieve (must be less than or equal to the number of items c can hold) |
References c, item_priv::coord_count, item_priv::coords, and item_priv::next_coord.
|
static |
Rewinds the coordinates of the currently selected item.
After rewinding, the next call to the tm_coord_get()
will return the first coordinate of the current item.
priv_data | The item's private data |
References item_priv::next_coord.
Referenced by tm_get_item().
|
static |
Destroys (closes) the traffic map.
priv | The private data for the traffic map instance |
|
static |
Dumps an item to a textfile map.
This method writes the item to a textfile map named distortion.txt
in the default data folder. This map can be added to the active mapset in order for the distortions to be rendered on the map and considered for routing.
All data passed to this method is safe to free after the method returns, and doing so is the responsibility of the caller.
item | The item |
References item_priv::attrs, c, item_priv::coords, dbg, lvl_error, navit_get_user_data_directory(), item::priv_data, and tm_item_dump_to_file().
Referenced by tm_dump_to_textfile().
|
static |
Dumps the traffic map to a textfile map.
This method writes all items to a textfile map named distortion.txt
in the default data folder. This map can be added to the active mapset in order for the distortions to be rendered on the map and considered for routing.
map | The traffic map |
References item, map_rect_destroy(), map_rect_get_item(), map_rect_new(), and tm_dump_item_to_textfile().
Referenced by traffic_process_messages_int().
|
static |
Returns an item from the map which matches the supplied data.
Comparison criteria are as follows:
attr_flags
is supplied in attrs
, the item must have this attribute and the rules listed below are applied AF_ALL
must match AF_ONEWAYMASK
must be set either on both sides or neither side AF_ONEWAYMASK
must effectively match (equal for same direction, inverted for opposite directions) This is due to the way different reports for the same segment are handled:
tm_item_update_attrs()
(lowest speed and longest delay wins) route_get_traffic_distortion()
mr | A map rectangle in the traffic map |
type | Type of the item |
attrs | The attributes for the item |
c | Points to an array of coordinates for the item |
count | Number of items in c |
References AF_ALL, AF_ONEWAYMASK, attr_generic_get_attr(), attr::attrs, c, item_priv::coord_count, item_priv::coords, item_attr_get(), item_attr_rewind(), map_rect_get_item(), attr::num, item::priv_data, attr::type, item::type, type, attr::u, coord::x, pcoord::x, coord::y, and pcoord::y.
Referenced by tm_add_item().
Gets an attribute from the traffic map.
This only supports the attr_traffic
attribute, which is currently only used for the purpose of identifying the map as a traffic map. Note, however, that for now the attribute will have a null pointer.
map_priv | Private data of the traffic map |
type | The type of the attribute to be read |
attr | Pointer to an attrib-structure where the attribute should be written to |
References attr::traffic, attr::type, and attr::u.
|
static |
Returns the next item from the traffic map.
mr | The map rect to search for items |
NULL
if the last item has already been retrieved. References map_rect_priv::item, item_priv::mr, map_rect_priv::next_item, item::priv_data, tm_attr_rewind(), and tm_coord_rewind().
Referenced by tm_get_item_byid().
|
static |
Returns the next item with the supplied ID from the traffic map.
mr | The map rect to search for items |
id_hi | The high-order portion of the ID |
id_lo | The low-order portion of the ID |
NULL
if there are no matching items or the last matching item has already been retrieved. References item::id_hi, item::id_lo, and tm_get_item().
|
static |
Adds message data to a traffic map item.
This method checks if the item already has data for the message specified in msgid
. If so, the existing data is updated, else a new entry is added.
Data changes also trigger an update of the affected item’s attributes.
item | The item (its priv_data member must point to a struct item_priv ) |
msgid | The message ID |
speed | The maximum speed for the segment (INT_MAX if none given) |
delay | The delay for the segment, in tenths of seconds (0 for none) |
attrs | Additional attributes specified by the message, can be NULL |
route | The route affected by the changes |
References item_msg_priv::delay, item_priv::message_data, item_msg_priv::message_id, item::priv_data, item_msg_priv::speed, and tm_item_update_attrs().
Referenced by traffic_message_add_segments(), and traffic_message_restore_segments().
|
static |
Destroys a traffic map item.
This function should never be called directly. Instead, be sure to obtain all references by calling tm_item_ref()
and destroying them by calling tm_item_unref()
.
item | The item (its priv_data member must point to a struct item_priv ) |
References attr_list_free(), item_msg_priv::attrs, item_priv::attrs, item_priv::coords, item_priv::message_data, item_msg_priv::message_id, and item::priv_data.
Referenced by tm_item_unref().
|
static |
Dumps an item to a file in textfile format.
All data passed to this method is safe to free after the method returns, and doing so is the responsibility of the caller.
item | The item |
f | The file to write to |
References attr_to_name(), attr_to_text(), item_priv::attrs, c, item_priv::coord_count, item_priv::coords, item::id_hi, item::id_lo, item_to_name(), item::priv_data, and item::type.
Referenced by tm_dump_item_to_textfile(), and traffic_dump_messages_to_xml().
References a traffic map item.
Storing a reference to a traffic map item should always be done by calling this function, passing the item as its argument. This will return the item and increase its reference count by one.
Never store a pointer to a traffic item not obtained via this function. Doing so may have undesired side effects as the item will not be aware of the reference to it, and the reference may unexpectedly become invalid, leading to a segmentation fault.
item | The item (its priv_data member must point to a struct item_priv ) |
NULL
will be returned if the argument is NULL
or points to an item whose priv_data
member is NULL
. References item, and item::priv_data.
Referenced by traffic_message_add_segments().
Unreferences a traffic map item.
This must be called when destroying a reference to a traffic map item. It will decrease the reference count of the item by one, and destroy the item if the last reference to is is removed.
The map itself (and only the map) holds weak references to its items, which are not considered in the reference count. Consequently, when the reference count reaches zero, the item is also removed from the map.
Unreferencing an item with a zero reference count (which is only possible for an item which has never been referenced since its creation) is equivalent to dropping the last reference, i.e. it will destroy the item.
When the last reference is removed (or an item with a zero reference count is unreferenced) and the item’s rt
member is set (indicating the route to which the item was added), the item is removed from that route.
If the unreference operation is successful, this function returns NULL
. This allows one-line operations such as:
item | The item (its priv_data member must point to a struct item_priv ) |
NULL
if the item was unreferenced successfully, item
if it points to an item whose priv_data
member is NULL
. References item, item_type_set(), item::map, map_rect_destroy(), map_rect_get_item(), map_rect_new(), item_priv::mr, item::priv_data, item_priv::refcount, route_remove_traffic_distortion(), item_priv::rt, and tm_item_destroy().
Referenced by traffic_message_destroy().
Updates the attributes of an item.
This method must be called after changing the message data associated with an item, i.e. adding, removing or modifying message data.
item | The item |
route | The route affected by the changes |
References attr_generic_add_attr(), attr_generic_remove_attr(), attr_search(), item_priv::attrs, attr::data, item_msg_priv::delay, item_priv::message_data, attr::num, item::priv_data, route_add_traffic_distortion(), route_change_traffic_distortion(), item_priv::rt, item_msg_priv::speed, attr::type, and attr::u.
Referenced by tm_item_add_message_data(), and traffic_message_remove_item_data().
|
static |
Creates a new item of the specified type and inserts it into the map.
mr | The map rect in which to create the item |
type | The type of item to create |
type
and has an allocated priv_data
member; all other members of both structs are NULL
. References map_priv::items, map_rect_priv::mpriv, item::priv_data, item::type, and type.
|
static |
Destroys a map rectangle on the traffic map.
|
static |
Opens a new map rectangle on the traffic map.
This function opens a new map rectangle on the route graph's map.
priv | The traffic graph map's private data |
sel | The map selection (to restrict search to a rectangle, order and/or item types) |
References map_selection::c_rect, coord_rect_overlap(), data, dbg, traffic_message_priv::items, lvl_debug, map_selection_destroy(), traffic_shared_priv::messages, map_rect_priv::mpriv, map_selection::next, map_rect_priv::next_item, traffic_message::priv, map_methods::pro, map_priv::shared, traffic_dump_messages_to_xml(), traffic_location_get_rect(), traffic_location_set_enclosing_rect(), traffic_map_meth, traffic_message_add_segments(), traffic_message_parse_events(), traffic_message_restore_segments(), and map_selection::u.
|
static |
Sets the type of a traffic item.
priv_data | The item's private data |
type | The new type for the item. Setting it to type_none deletes the item from the map. |
References dbg, map_rect_priv::item, map_priv::items, lvl_error, map_rect_priv::mpriv, item_priv::mr, map_rect_priv::next_item, item::priv_data, item::type, and type.
void traffic_destroy | ( | struct traffic * | this_ | ) |
Destructor.
References attr_list_free(), traffic_methods::destroy, traffic::meth, and traffic::priv.
|
static |
Dumps all currently active traffic messages to an XML file.
References traffic_point::coord, dbg, event_class_to_string(), event_type_to_string(), message::id, item_to_name(), coord_geo::lng, location_dir_one, location_fuzziness_to_string(), location_ramps_to_string(), lvl_error, traffic_shared_priv::messages, navit_get_user_data_directory(), si_class_to_string(), si_type_to_string(), time_to_iso8601(), and tm_item_dump_to_file().
Referenced by tm_rect_new(), and traffic_process_messages_int().
void traffic_event_add_suppl_info | ( | struct traffic_event * | this_, |
struct traffic_suppl_info * | si | ||
) |
Adds a supplementary information item to an event.
The traffic_suppl_info
instance is destroyed when the traffic_event
is destroyed, and therefore cannot be shared between multiple traffic_event
instances.
this_ | The event |
si | The supplementary information item |
References traffic_event::si, and traffic_event::si_count.
void traffic_event_destroy | ( | struct traffic_event * | this_ | ) |
Destroys a traffic_event
.
This will release the memory used by the traffic_event
and all related data.
A traffic_event
is usually destroyed together with its parent traffic_message
, thus it is usually not necessary to call this destructor directly.
this_ | The event |
References traffic_event::quantifier, traffic_event::si, traffic_event::si_count, and traffic_suppl_info_destroy().
Referenced by traffic_message_destroy(), and traffic_xml_end().
struct traffic_suppl_info* traffic_event_get_suppl_info | ( | struct traffic_event * | this_, |
int | index | ||
) |
Retrieves a supplementary information item associated with an event.
this_ | The event |
index | The index of the supplementary information item, zero-based |
References traffic_event::si.
|
static |
Whether the contents of an event are valid.
This identifies any malformed events in which mandatory members are not set.
References dbg, traffic_event::event_class, event_class_congestion, event_class_delay, event_class_restriction, event_congestion_cleared, event_delay_clearance, event_restriction_access_restrictions_lifted, event_restriction_speed_limit_lifted, lvl_debug, traffic_event::si, traffic_event::si_count, and traffic_event::type.
Referenced by traffic_message_is_valid(), and traffic_xml_end().
struct traffic_event* traffic_event_new | ( | enum event_class | event_class, |
enum event_type | type, | ||
int | length, | ||
int | speed, | ||
struct quantifier * | quantifier, | ||
int | si_count, | ||
struct traffic_suppl_info ** | si | ||
) |
Creates a new traffic_event
.
The traffic_suppl_info
instances are destroyed when the traffic_event
is destroyed, and therefore cannot be shared between multiple traffic_event
instances.
It is the responsibility of the caller to destroy all other references passed to this function (including the si
buffer but not the traffic_suppl_info
instances). This can be done immediately after the function returns.
event_class | The event class (generic category) |
type | The event type, which can be mapped to a string to be displayed to the user |
length | The length of the affected route in meters, -1 if not known |
speed | The speed in km/h at which vehicles can expect to pass through the affected stretch of road (either a temporary speed limit or average speed in practice, whichever is less); INT_MAX if unknown |
quantifier | Additional quantifier for supplementary information types allowing this, or NULL |
si_count | Number of supplementary information items in si_count |
si | Points to an array of pointers to supplementary information items |
References traffic_event::event_class, length, traffic_event::length, traffic_event::quantifier, traffic_event::si, traffic_event::si_count, traffic_event::speed, type, and traffic_event::type.
Referenced by traffic_event_new_short(), and traffic_xml_end().
struct traffic_event* traffic_event_new_short | ( | enum event_class | event_class, |
enum event_type | type | ||
) |
Creates a new traffic_event
.
This is the short version of the constructor, which sets only mandatory members. Other members can be set after the instance is created.
event_class | The event class (generic category) |
type | The event type, which can be mapped to a string to be displayed to the user |
References traffic_event_new(), and type.
Referenced by traffic_message_new_single_event().
|
static |
Gets the delay for a traffic distortion item.
delay | Total delay for all items associated with the same message and direction |
item_len | Length of the current item |
len | Combined length of all items associated with the same message and direction |
Referenced by traffic_message_add_segments().
|
static |
Gets the speed for a traffic distortion item.
item | The road item to which the traffic distortion refers (not the traffic distortion item) |
data | Segment data |
item_maxspeed | Speed limit for the item, INT_MAX if none |
References data, and item::type.
Referenced by traffic_message_add_segments(), and traffic_message_restore_segments().
Returns the map for the traffic plugin.
The map is created by the first traffic plugin loaded. If multiple traffic plugin instances are active at the same time, they share the map created by the first instance.
this_ | The traffic plugin instance |
References attr::attrs, callback_cast, callback_new_2, data, event_add_idle(), filename, traffic::idle_cb, traffic::idle_ev, traffic_shared_priv::map, map_new(), traffic_shared_priv::message_queue, navit_get_user_data_directory(), PROCESS_MESSAGES_NO_DUMP_STORE, traffic::shared, attr::str, attr::traffic, traffic_get_messages_from_xml_file(), traffic_process_messages_int(), attr::type, and attr::u.
Referenced by navit_init().
|
static |
Reads previously stored traffic messages from parsed XML data.
state | The XML parser state after parsing the XML data |
NULL
-terminated pointer array. Each element points to one struct traffic_message
. NULL
is returned (rather than an empty pointer array) if there are no messages to report. References xml_state::messages.
Referenced by traffic_get_messages_from_xml_file(), and traffic_get_messages_from_xml_string().
struct traffic_message** traffic_get_messages_from_xml_file | ( | struct traffic * | this_, |
char * | filename | ||
) |
Reads previously stored traffic messages from an XML file.
this_ | The traffic instance |
filename | The full path to the XML file to parse |
NULL
-terminated pointer array. Each element points to one struct traffic_message
. NULL
is returned (rather than an empty pointer array) if there are no messages to report. References dbg, filename, lvl_error, traffic_get_messages_from_parsed_xml(), traffic_xml_end(), traffic_xml_start(), traffic_xml_text(), and xml_parse_file().
Referenced by request_navit_traffic_inject(), and traffic_get_map().
struct traffic_message** traffic_get_messages_from_xml_string | ( | struct traffic * | this_, |
char * | xml | ||
) |
Reads traffic messages from an XML string.
this_ | The traffic instance |
filename | The XML document to parse, as a string |
NULL
-terminated pointer array. Each element points to one struct traffic_message
. NULL
is returned (rather than an empty pointer array) if there are no messages to report. References dbg, lvl_error, traffic_get_messages_from_parsed_xml(), traffic_xml_end(), traffic_xml_start(), traffic_xml_text(), and xml_parse_text().
Referenced by traffic_traff_android_on_feed_received().
struct traffic_message** traffic_get_stored_messages | ( | struct traffic * | this_ | ) |
Returns currently active traffic messages.
If multiple plugin instances are active, this will give the same result for any plugin, as traffic messages are shared between instances.
this_ | The traffic plugin instance |
References data, traffic_shared_priv::map, traffic_shared_priv::messages, traffic_shared_priv::ms, traffic_shared_priv::rt, traffic::shared, traffic_message_add_segments(), and traffic_message_parse_events().
Referenced by request_navit_traffic_export_gpx().
void traffic_init | ( | void | ) |
Initializes the traffic plugin.
This function is called once on startup.
References dbg, lvl_debug, and traffic_map_new().
Referenced by main_real().
void traffic_location_destroy | ( | struct traffic_location * | this_ | ) |
Destroys a traffic_location
.
This will release the memory used by the traffic_location
and all related data.
A traffic_location
is usually destroyed together with its parent traffic_message
, thus it is usually not necessary to call this destructor directly.
this_ | The location |
References traffic_location::at, traffic_location::destination, traffic_location::direction, traffic_location::from, traffic_location_priv::ne, traffic_location::not_via, traffic_location::priv, traffic_location::road_name, traffic_location::road_ref, traffic_location_priv::sw, traffic_location::tmc_table, traffic_location::to, traffic_point_destroy(), traffic_location_priv::txt_data, and traffic_location::via.
Referenced by traffic_message_destroy().
|
static |
Whether two traffic locations are equal.
Only directionality, the ramps
member and reference points are considered for comparison; auxiliary data (such as road names, road types and additional TMC information) is ignored.
When in doubt, this function errs on the side of inequality, i.e. when equivalence cannot be reliably determined, the locations will be reported as not equal, even though they may translate to the same segments later.
l
and r
are equal, false if not References traffic_location::at, traffic_location::directionality, traffic_location::from, traffic_location::not_via, traffic_location::ramps, traffic_location::to, traffic_point_equals(), and traffic_location::via.
Referenced by traffic_process_messages_int().
|
static |
Returns points from the route graph which match a traffic location.
This method obtains point items from the map_rect from which the route graph was built and compares their attributes to those supplied with the location. Each point is assigned a match score, from 0 (no matching attributes) to 100 (all supplied attributes match), and a list of all points with a nonzero score is returned.
Points which have no corresponding map item (i.e. points which have no additional attributes) are not included in the result and must be analyzed separately if needed.
this_ | The traffic location |
point | The point of the traffic location to use for matching (0 = from, 1 = at, 2 = to, 16 = start, 17 = end) |
rg | The route graph |
start | The first point of the path |
match_start | True to evaluate for the start point of a route, false for the end point |
ms | The mapset to read the items from |
GList
. The data
member of each item points to a struct point_data
for the point. References c, data, dbg, route_graph::h, item, item_coord_get(), lvl_debug, route_graph::m, map_get_attr(), map_rect_destroy(), map_rect_get_item(), map_selection_destroy(), mapset_next(), mapset_open(), route_graph::mr, p, route_graph_build_done(), route_graph_get_point(), route_graph_get_point_next(), RP_TURN_RESTRICTION, point_data::score, route_graph::sel, traffic_location_get_point(), traffic_location_open_map_rect(), traffic_location_set_enclosing_rect(), traffic_point_match_attributes(), and item::type.
Referenced by traffic_message_add_segments().
|
static |
Returns one of the traffic location’s points.
this_ | The traffic location |
point | The point of the traffic location to retrieve (0 = from, 1 = at, 2 = to, 16 = start, 17 = end) |
References traffic_location::at, traffic_location::from, and traffic_location::to.
Referenced by traffic_location_get_matching_points(), and traffic_location_get_point_match().
|
static |
Compares a given point to the traffic location and returns a score.
This method obtains all points at coordinates c
from the map_rect used to build the route graph, compares their attributes to those supplied with the location, assigns a match score from 0 (no matching attributes) to 100 (all supplied attributes match) and returns the highest score obtained. If no matching point is found, 0 is returned.
this_ | The traffic location |
p | The route graph point to examine for matches |
point | The point of the traffic location to use for matching (0 = from, 1 = at, 2 = to, 16 = start, 17 = end) |
rg | The route graph |
start | The first point of the path |
match_start | True to evaluate for the start point of a route, false for the end point |
ms | The mapset to read the items from |
References p, traffic_location_get_point(), and traffic_point_match_segment_attributes().
Referenced by traffic_message_add_segments().
|
static |
Determines the “point triple” for a traffic location.
Each traffic location is defined by up to three points:
This method determines these three points, puts them in the order in which they are encountered and returns a bit field indicating the end points. If a point in the array is NULL or refers to an auxiliary point, its corresponding bit is not set. The following values are returned:
this_ | The location |
coords | Points to an array which will receive pointers to the coordinates. The array must be able to store three pointers. |
References traffic_location::at, traffic_point::coord, traffic_location::from, traffic_location::not_via, projection_mg, traffic_location::to, transform_distance(), transform_from_geo(), and traffic_location::via.
Referenced by traffic_location_set_enclosing_rect(), and traffic_message_add_segments().
|
static |
|
static |
Obtains a map selection for the traffic location.
The map selection is a rectangle around the points of the traffic location, with some extra padding as specified in ROUTE_RECT_DIST_REL
and ROUTE_RECT_DIST_ABS
, with a map order specified in ROUTE_ORDER
.
this_ | The traffic location |
projection | The projection to be used by coordinates of the selection (should correspond to the projection of the target map) |
References c1, c2, traffic_location::fuzziness, traffic_location_priv::ne, traffic_location::priv, traffic_location::road_type, ROUTE_ORDER, route_rect(), ROUTE_RECT_DIST_ABS, ROUTE_RECT_DIST_REL, traffic_location_priv::sw, and transform_from_geo().
|
static |
Builds a new route graph for traffic location matching.
Traffic location matching is done by using a modified routing algorithm to identify the segments affected by a traffic message.
this_ | The location to match to the map |
ms | The mapset to use for the route graph |
References route_graph::busy, route_graph::done_cb, traffic_location_populate_route_graph(), and traffic_location_set_enclosing_rect().
Referenced by traffic_message_add_segments().
|
static |
Whether the contents of a location are valid.
This identifies any malformed locations in which mandatory members are not set.
References traffic_location::at, traffic_location::from, and traffic_location::to.
Referenced by traffic_message_is_valid().
|
static |
Determines the degree to which the attributes of a location and a map item match.
The result of this method is used to match a location to a map item. Its result is a score—the higher the score, the better the match.
To calculate the score, all supplied attributes are examined and points are given for each attribute which is defined for the location. An exact match adds 4 points, a partial match adds 2. Values of 1 and 3 are added where additional granularity is needed. The number of points attained is divided by the maximum number of points attainable, and the result is returned as a percentage value.
If no points can be attained (because no attributes which must match are supplied), the score is 100 for any item supplied.
this_ | The location |
item | The map item |
References compare_name_systematic(), item_attr_get(), item_attr_rewind(), MAX_MISMATCH, traffic_location::road_name, traffic_location::road_ref, traffic_location::road_type, attr::str, item::type, and attr::u.
Referenced by traffic_location_populate_route_graph().
struct traffic_location* traffic_location_new | ( | struct traffic_point * | at, |
struct traffic_point * | from, | ||
struct traffic_point * | to, | ||
struct traffic_point * | via, | ||
struct traffic_point * | not_via, | ||
char * | destination, | ||
char * | direction, | ||
enum location_dir | directionality, | ||
enum location_fuzziness | fuzziness, | ||
enum location_ramps | ramps, | ||
enum item_type | road_type, | ||
char * | road_name, | ||
char * | road_ref, | ||
char * | tmc_table, | ||
int | tmc_direction | ||
) |
Creates a new traffic_location
.
The traffic_point
instances are destroyed when the traffic_location
is destroyed, and therefore cannot be shared between multiple traffic_location
instances.
It is the responsibility of the caller to destroy all other references passed to this function. This can be done immediately after the function returns.
If at
is non-NULL, the location is a point location, and from
and to
are interpreted as auxiliary locations.
Of from
and to
, one is mandatory for a unidirectional point location; both are mandatory for a linear location.
ramps
is mainly intended for compatibility with TMC, where junctions with all their ramps are represented by a single point. Other sources should use coordinate pairs instead.
at | The coordinates for a point location, NULL for a linear location |
from | The start of a linear location, or a point before at |
to | The end of a linear location, or a point after at |
via | A point between from and to , needed only on ring roads |
not_via | A point not between from and to , needed only on ring roads |
destination | A destination, preferably the one given on road signs, indicating that the message applies only to traffic going in that direction; can be NULL, do not use for bidirectional locations |
direction | A compass direction indicating the direction of travel which this location refers to; can be NULL, do not use where ambiguous |
directionality | Whether the location is unidirectional or bidirectional |
fuzziness | A precision indicator for from and to |
ramps | Whether the main carriageway or the ramps are affected |
road_type | The importance of the road within the road network, must be a road item type, type_line_unspecified if not known or not consistent |
road_name | A road name, if consistent throughout the location; NULL if not known or inconsistent |
road_ref | A road number, if consistent throughout the location; NULL if not known or inconsistent |
tmc_table | For messages received via TMC, the CID and LTN; NULL otherwise |
tmc_direction | For messages received via TMC, the direction of the road; ignored for bidirectional or non-TMC messages |
References traffic_location::at, traffic_location::destination, traffic_location::direction, traffic_location::directionality, traffic_location::from, traffic_location::fuzziness, traffic_location_priv::ne, traffic_location::not_via, traffic_location::priv, traffic_location::ramps, traffic_location::road_name, traffic_location::road_ref, traffic_location::road_type, traffic_location_priv::sw, traffic_location::tmc_direction, traffic_location::tmc_table, traffic_location::to, and traffic_location::via.
Referenced by traffic_dummy_get_messages(), traffic_location_new_short(), and traffic_xml_end().
struct traffic_location* traffic_location_new_short | ( | struct traffic_point * | at, |
struct traffic_point * | from, | ||
struct traffic_point * | to, | ||
struct traffic_point * | via, | ||
struct traffic_point * | not_via, | ||
enum location_dir | directionality, | ||
enum location_fuzziness | fuzziness | ||
) |
Creates a new traffic_location
.
This is the short version of the constructor, which sets only mandatory members. Other members can be set after the instance is created.
The traffic_point
instances are destroyed when the traffic_location
is destroyed, and therefore cannot be shared between multiple traffic_location
instances.
If at
is non-NULL, the location is a point location, and from
and to
are interpreted as auxiliary locations.
Of from
and to
, one is mandatory for a unidirectional point location; both are mandatory for a linear location.
at | The coordinates for a point location, NULL for a linear location |
from | The start of a linear location, or a point before at |
to | The end of a linear location, or a point after at |
via | A point between from and to , needed only on ring roads |
not_via | A point not between from and to , needed only on ring roads |
directionality | Whether the location is unidirectional or bidirectional |
fuzziness | A precision indicator for from and to |
References traffic_location::at, traffic_location::directionality, traffic_location::from, traffic_location::fuzziness, location_ramps_none, traffic_location::not_via, traffic_location::to, traffic_location_new(), and traffic_location::via.
|
static |
Opens a map rectangle around the end points of the traffic location.
Prior to calling this function, the caller must ensure rg->m
points to the map to be used, and the enclosing rectangle for the traffic location has been set (e.g. by calling traffic_location_set_enclosing_rect()
).
this_ | The traffic location |
rg | The route graph |
References route_graph::m, map_projection(), map_rect_new(), map_selection_destroy(), route_graph::mr, route_graph::sel, and traffic_location_get_rect().
Referenced by traffic_location_get_matching_points(), and traffic_location_populate_route_graph().
|
static |
Populates a route graph.
This adds all routable segments in the enclosing rectangle of the location (plus a safety margin) to the route graph.
rg | The route graph |
ms | The mapset to read the ramps from |
References AF_DANGEROUS_GOODS, AF_SEGMENTED, AF_SIZE_OR_WEIGHT_LIMIT, AF_SPEED_LIMIT, c, data, dbg_assert, default_flags, route_graph::h, item, item_attr_get(), item_attr_rewind(), item_coord_get(), item_coord_is_node(), item_coord_rewind(), item_default_flags_value, item_get_default_flags(), route_graph_segment_data::len, route_graph::m, item::map, map_get_attr(), map_projection(), map_rect_destroy(), map_rect_get_item(), map_selection_destroy(), mapset_next(), mapset_open(), route_graph::mr, attr::num, traffic_location::road_type, route_graph_add_point(), route_graph_add_segment(), route_graph_add_turn_restriction(), route_graph_build_done(), route_graph_segment_is_duplicate(), route_item_first, route_item_last, route_graph::sel, traffic_location_match_attributes(), traffic_location_open_map_rect(), traffic_location_set_enclosing_rect(), transform_distance(), item::type, and attr::u.
Referenced by traffic_location_get_route_graph().
|
static |
Sets the rectangle enclosing all points of a location.
this_ | The traffic location |
coords | The point triple, can be NULL |
References coord_geo::lat, lat, coord_geo::lng, traffic_location_priv::ne, traffic_location::priv, traffic_location_priv::sw, and traffic_location_get_point_triple().
Referenced by tm_rect_new(), traffic_location_get_matching_points(), traffic_location_get_route_graph(), traffic_location_populate_route_graph(), traffic_message_add_segments(), traffic_message_restore_segments(), and traffic_process_messages_int().
|
static |
The loop function for the traffic module.
This function polls backends for new messages and processes them by inserting, removing or modifying traffic distortions and triggering route recalculations as needed.
References callback_cast, callback_destroy(), callback_new_2, event_add_idle(), event_remove_idle(), traffic_methods::get_messages, traffic::idle_cb, traffic::idle_ev, traffic_shared_priv::message_queue, traffic::meth, traffic::priv, PROCESS_MESSAGES_PURGE_EXPIRED, traffic::shared, and traffic_process_messages_int().
Referenced by traffic_new().
|
static |
Registers a new traffic map plugin.
meth | Receives the map methods |
attrs | The attributes for the map |
cbl |
map_priv
structure for the map References attr_search(), attr::attrs, dbg, lvl_error, traffic::shared, map_priv::shared, attr::traffic, traffic_map_meth, and attr::u.
Referenced by traffic_init().
void traffic_message_add_event | ( | struct traffic_message * | this_, |
struct traffic_event * | event | ||
) |
Adds an event to a message.
The traffic_event
instance is destroyed when the traffic_message
is destroyed, and therefore cannot be shared between multiple traffic_message
instances.
this_ | The message |
event | The event to add to this message |
References traffic_message::event_count, and traffic_message::events.
|
static |
Generates segments affected by a traffic message.
This translates the approximate coordinates in the from
, at
, to
, via
and not_via
members of the location to one or more map segments, using both the raw coordinates and the auxiliary information contained in the location. Each segment is stored in the map, if not already present, and a link is stored with the message.
this_ | The traffic message |
ms | The mapset to use for matching |
data | Data for the segments added to the map |
map | The traffic map |
route | The route affected by the changes |
true
if the locations were matched successfully, false
if there was a failure. References AF_ONEWAY, AF_ONEWAYMASK, AF_ONEWAYREV, AF_SPEED_LIMIT, traffic_location::at, c, route_graph_point::c, data, route_graph_segment::data, dbg, traffic_location::directionality, route_graph_segment::end, route_segment_data::flags, traffic_location::from, traffic_location::fuzziness, traffic_message::id, item::id_hi, item::id_lo, item, route_segment_data::item, item_coord_get_within_range(), traffic_message_priv::items, coord_geo::lat, route_segment_data::len, coord_geo::lng, traffic_message::location, location_dir_one, location_fuzziness_low_res, location_ramps_none, lvl_debug, lvl_error, traffic_location::not_via, point_data::p, PENALTY_POINT_MATCH, traffic_message::priv, projection_mg, traffic_location::ramps, route_graph_free_points(), route_graph_free_segments(), route_graph_point_is_endpoint_candidate(), RSD_MAXSPEED, point_data::score, route_graph_point::seg, route_graph_segment::start, tm_add_item(), tm_item_add_message_data(), tm_item_ref(), traffic_location::to, traffic_get_item_delay(), traffic_get_item_speed(), traffic_location_get_matching_points(), traffic_location_get_point_match(), traffic_location_get_point_triple(), traffic_location_get_route_graph(), traffic_location_set_enclosing_rect(), traffic_route_append(), traffic_route_flood_graph(), traffic_route_prepend(), transform_distance(), transform_from_geo(), transform_to_geo(), and route_graph_point::value.
Referenced by tm_rect_new(), traffic_get_stored_messages(), and traffic_process_messages_int().
void traffic_message_destroy | ( | struct traffic_message * | this_ | ) |
Destroys a traffic_message
.
This will release the memory used by the traffic_message
and all related data.
A traffic_message
is usually destroyed by the traffic plugin, thus it is usually not necessary to call this destructor directly.
this_ | The message |
References traffic_message::event_count, traffic_message::events, traffic_message::id, traffic_message_priv::items, traffic_message::location, traffic_message::priv, traffic_message::replaced_count, traffic_message::replaces, tm_item_unref(), traffic_event_destroy(), and traffic_location_destroy().
Referenced by traffic_process_messages_int(), and traffic_xml_end().
|
static |
Prints a dump of a message to debug output.
this_ | The message to dump |
References traffic_location::at, traffic_point::coord, dbg, traffic_location::destination, traffic_location::direction, traffic_location::directionality, traffic_message::end_time, traffic_event::event_class, event_class_to_string(), traffic_message::event_count, event_type_to_string(), traffic_message::events, traffic_message::expiration_time, traffic_location::from, traffic_location::fuzziness, traffic_message::id, traffic_message::is_cancellation, traffic_message::is_forecast, item_to_name(), traffic_point::junction_name, traffic_point::junction_ref, traffic_event::length, coord_geo::lng, traffic_message::location, location_fuzziness_to_string(), location_ramps_to_string(), lvl_debug, traffic_location::not_via, traffic_location::ramps, traffic_message::receive_time, traffic_message::replaced_count, traffic_message::replaces, traffic_location::road_name, traffic_location::road_ref, traffic_location::road_type, traffic_event::si, traffic_suppl_info::si_class, si_class_to_string(), traffic_event::si_count, si_type_to_string(), traffic_event::speed, traffic_message::start_time, time_to_iso8601(), traffic_location::tmc_direction, traffic_point::tmc_id, traffic_location::tmc_table, traffic_location::to, traffic_suppl_info::type, traffic_event::type, traffic_message::update_time, and traffic_location::via.
Referenced by traffic_process_messages_int().
struct traffic_event* traffic_message_get_event | ( | struct traffic_message * | this_, |
int | index | ||
) |
Retrieves an event associated with a message.
this_ | The message |
index | The index of the event, zero-based |
References traffic_message::events.
struct item** traffic_message_get_items | ( | struct traffic_message * | this_ | ) |
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.
this_ | The message |
References traffic_message_priv::items, and traffic_message::priv.
Referenced by request_navit_traffic_export_gpx().
|
static |
Whether the contents of a message are valid.
This identifies any malformed messages in which mandatory members are not set.
References dbg, traffic_message::end_time, traffic_message::event_count, traffic_message::events, traffic_message::expiration_time, traffic_message::id, traffic_message::is_cancellation, traffic_message::location, lvl_debug, traffic_message::receive_time, traffic_event_is_valid(), traffic_location_is_valid(), and traffic_message::update_time.
Referenced by traffic_xml_end().
struct traffic_message* traffic_message_new | ( | char * | id, |
time_t | receive_time, | ||
time_t | update_time, | ||
time_t | expiration_time, | ||
time_t | start_time, | ||
time_t | end_time, | ||
int | is_cancellation, | ||
int | is_Forecast, | ||
int | replaced_count, | ||
char ** | replaces, | ||
struct traffic_location * | location, | ||
int | event_count, | ||
struct traffic_event ** | events | ||
) |
Creates a new traffic_message
.
The traffic_event
and traffic_location
instances are destroyed when the traffic_message
is destroyed, and therefore cannot be shared between multiple traffic_message
instances.
It is the responsibility of the caller to destroy all other references passed to this function (including the events
buffer but not the traffic_event
instances). This can be done immediately after the function returns.
id | The message identifier; existing messages with the same identifier will be replaced by the new message |
receive_time | When the message was first received by the source, should be kept stable across all updates |
update_time | When the last update to this message was received by the source |
expiration_time | How long the message should be considered valid |
start_time | When the condition is expected to begin (optional, 0 if not set) |
end_time | How long the condition is expected to last (optional, 0 if not set) |
isCancellation | If true, create a cancellation message (existing messages with the same ID should be deleted or no longer considered current, and all other attributes ignored) |
isForecast | If false, the message describes a current situation; if true, it describes an expected situation in the future |
replaced_count | The number of entries in replaces |
replaces | Points to an array of identifiers of messages which the current message replaces |
location | The location to which this message refers |
event_count | The number of events in events |
events | Points to an array of pointers to the events for this message |
References traffic_message::end_time, traffic_message::event_count, traffic_message::events, traffic_message::expiration_time, traffic_message::id, traffic_message::is_cancellation, traffic_message::is_forecast, traffic_message_priv::items, traffic_message::location, traffic_message::priv, traffic_message::receive_time, traffic_message::replaced_count, traffic_message::replaces, traffic_message::start_time, and traffic_message::update_time.
Referenced by traffic_message_new_cancellation(), traffic_message_new_short(), and traffic_xml_end().
struct traffic_message* traffic_message_new_cancellation | ( | char * | id, |
time_t | receive_time, | ||
time_t | update_time, | ||
time_t | expiration_time, | ||
struct traffic_location * | location | ||
) |
Creates a new cancellation traffic_message
.
This is a convenience constructor, which creates a cancellation message, without the need to supply members which are not required for cancellation messages. Upon receiving a cancellation message, existing messages with the same ID should be deleted or no longer considered current, and all other attributes ignored.
The traffic_location
instances are destroyed when the traffic_message
is destroyed, and therefore cannot be shared between multiple traffic_message
instances.
It is the responsibility of the caller to destroy all other references passed to this function. This can be done immediately after the function returns.
id | The message identifier; existing messages with the same identifier will be replaced by the new message |
receive_time | When the message was first received by the source, should be kept stable across all updates |
update_time | When the last update to this message was received by the source |
expiration_time | How long the message should be considered valid |
location | The location to which this message refers |
References traffic_message::expiration_time, traffic_message::location, traffic_message::receive_time, traffic_message_new(), and traffic_message::update_time.
Referenced by traffic_dummy_get_messages().
struct traffic_message* traffic_message_new_short | ( | char * | id, |
time_t | receive_time, | ||
time_t | update_time, | ||
time_t | expiration_time, | ||
int | is_forecast, | ||
struct traffic_location * | location, | ||
int | event_count, | ||
struct traffic_event ** | events | ||
) |
Creates a new traffic_message
.
This is the short version of the constructor, which sets only mandatory members. Other members can be set after the instance is created.
The traffic_event
and traffic_location
instances are destroyed when the traffic_message
is destroyed, and therefore cannot be shared between multiple traffic_message
instances.
It is the responsibility of the caller to destroy all other references passed to this function (including the events
buffer but not the traffic_event
instances). This can be done immediately after the function returns.
id | The message identifier; existing messages with the same identifier will be replaced by the new message |
receive_time | When the message was first received by the source, should be kept stable across all updates |
update_time | When the last update to this message was received by the source |
expiration_time | How long the message should be considered valid |
is_forecast | If false, the message describes a current situation; if true, it describes an expected situation in the future |
location | The location to which this message refers |
event_count | The number of events in events |
events | Points to an array of pointers to the events for this message |
References traffic_message::event_count, traffic_message::events, traffic_message::expiration_time, traffic_message::is_forecast, traffic_message::location, traffic_message::receive_time, traffic_message_new(), and traffic_message::update_time.
Referenced by traffic_message_new_single_event().
struct traffic_message* traffic_message_new_single_event | ( | char * | id, |
time_t | receive_time, | ||
time_t | update_time, | ||
time_t | expiration_time, | ||
int | is_forecast, | ||
struct traffic_location * | location, | ||
enum event_class | event_class, | ||
enum event_type | type | ||
) |
Creates a new single-event traffic_message
.
This is a convenience constructor, which sets only mandatory members. Other members can be set after the instance is created.
The traffic_location
instances are destroyed when the traffic_message
is destroyed, and therefore cannot be shared between multiple traffic_message
instances.
It is the responsibility of the caller to destroy all other references passed to this function. This can be done immediately after the function returns.
id | The message identifier; existing messages with the same identifier will be replaced by the new message |
receive_time | When the message was first received by the source, should be kept stable across all updates |
update_time | When the last update to this message was received by the source |
expiration_time | How long the message should be considered valid |
is_forecast | If false, the message describes a current situation; if true, it describes an expected situation in the future |
location | The location to which this message refers |
event_class | The event class (generic category) |
type | The event type, which can be mapped to a string to be displayed to the user |
References traffic_event_new_short(), traffic_message_new_short(), and type.
Referenced by traffic_dummy_get_messages().
|
static |
Parses the events of a traffic message.
message | The message to parse |
struct seg_data
, or NULL
if the message contains no usable information References AF_ALL, AF_CAR, AF_DANGEROUS_GOODS, AF_DELIVERY_TRUCK, AF_MOPED, AF_MOTORIZED_FAST, AF_PUBLIC_BUS, AF_TRANSPORT_TRUCK, seg_data::delay, seg_data::dir, traffic_location::directionality, traffic_event::event_class, event_class_congestion, event_class_delay, event_class_restriction, event_congestion_heavy_traffic, event_congestion_long_queue, event_congestion_queue, event_congestion_slow_traffic, event_congestion_stationary_traffic, event_congestion_traffic_building_up, event_congestion_traffic_congestion, event_congestion_traffic_heavier_than_normal, event_congestion_traffic_much_heavier_than_normal, event_congestion_traffic_problem, traffic_message::event_count, event_delay_delay, event_delay_long_delay, event_delay_several_hours, event_delay_uncertain_duration, event_delay_very_long_delay, event_restriction_batch_service, event_restriction_blocked, event_restriction_blocked_ahead, event_restriction_carriageway_blocked, event_restriction_carriageway_closed, event_restriction_closed, event_restriction_closed_ahead, event_restriction_contraflow, event_restriction_intermittent_closures, event_restriction_lane_blocked, event_restriction_lane_closed, event_restriction_reduced_lanes, event_restriction_single_alternate_line_traffic, traffic_message::events, seg_data::flags, traffic_message::location, quantifier::q_duration, traffic_event::quantifier, traffic_location::road_type, seg_data_new(), traffic_event::si, traffic_event::si_count, si_vehicle_all, si_vehicle_bus, si_vehicle_car, si_vehicle_car_with_caravan, si_vehicle_car_with_trailer, si_vehicle_hazmat, si_vehicle_hgv, si_vehicle_motor, si_vehicle_with_trailer, seg_data::speed, traffic_event::speed, seg_data::speed_factor, seg_data::speed_penalty, traffic_suppl_info::type, traffic_event::type, and quantifier::u.
Referenced by tm_rect_new(), traffic_get_stored_messages(), traffic_message_restore_segments(), and traffic_process_messages_int().
|
static |
Removes message data from the items associated with a message.
Removing message data also triggers an update of the affected items’ attributes.
It is possible to skip items associated with a particular message from being removed by passing that message as the new
argument. This is used for message updates, as this function is called after the items associated with both the old and the new message have already been updated. Skipping items referenced by new
ensures that message data is only stripped from items which are no longer being referenced by the updated message.
If the IDs of old
and new
differ, new
is ignored.
old | The message whose data it so be removed from its associated items |
new | If non-NULL, items referenced by this message will be skipped, see description |
route | The route affected by the changes |
References traffic_message::id, traffic_message_priv::items, item_priv::message_data, item_msg_priv::message_id, traffic_message::priv, item::priv_data, and tm_item_update_attrs().
Referenced by traffic_process_messages_int().
|
static |
Restores segments associated with a traffic message from cached data.
This reads textfile map data and compares it to data in the current map set. If one or more items (identified by their ID) are no longer present in the map, or their coordinates no longer match, the cached data is discarded and the location needs to be expanded into a set of segments as for a new message. Otherwise the cached segments are added to the traffic map.
While this operation does require extensive examination of map data, it is still less expensive than expanding the location from scratch, as the most expensive operation in the latter is routing between the points involved.
this_ | The traffic message |
ms | The mapset to use for matching |
data | Data for the segments to be added to the map, in textfile format |
map | The traffic map |
route | The route affected by the changes |
true
if the locations were matched successfully, false
if there was a failure. References AF_SEGMENTED, AF_SPEED_LIMIT, attr_from_line(), attr_list_dup(), attr_new_from_text(), attr::attrs, parsed_item::attrs, seg_data::attrs, parsed_item::coord_count, coord_parse(), parsed_item::coords, dbg, default_flags, parsed_item::delay, parsed_item::flags, traffic_message::id, item::id_hi, parsed_item::id_hi, item::id_lo, parsed_item::id_lo, parsed_item::is_matched, item, item_attr_get(), item_attr_rewind(), item_coord_get(), item_coord_rewind(), item_default_flags_value, item_from_name(), item_get_default_flags(), traffic_message_priv::items, traffic_message::location, lvl_debug, lvl_warning, map_get_attr(), map_projection(), map_rect_destroy(), map_rect_get_item(), map_rect_new(), map_selection_destroy(), mapset_close(), mapset_next(), mapset_open(), name, attr::num, parsed_item_destroy(), startup::pos, traffic_location::priv, traffic_message::priv, projection_mg, traffic_location::road_type, route_item_first, route_item_last, TEXTFILE_LINE_SIZE, tm_add_item(), tm_item_add_message_data(), traffic_get_item_speed(), traffic_location_get_rect(), traffic_location_set_enclosing_rect(), traffic_message_parse_events(), traffic_location_priv::txt_data, item::type, type, parsed_item::type, attr::u, value, coord::x, and coord::y.
Referenced by tm_rect_new(), and traffic_process_messages_int().
Instantiates the traffic plugin.
At a minimum, attrs
must contain a type
attribute matching one of the available traffic plugins.
parent | The parent, usually the Navit instance |
attrs | The attributes for the plugin |
traffic
instance. References attr_search(), attr_to_name(), attr::attrs, traffic::callback, callback_cast, callback_new_1, cbl, dbg, event_add_timeout(), traffic_methods::get_messages, lvl_debug, lvl_error, traffic::meth, traffic::navit, navit_object_destroy(), navit_object_new(), traffic::priv, traffic::shared, attr::str, traffic::timeout, traffic_func, traffic_loop(), traffic_set_shared(), and attr::u.
void traffic_point_destroy | ( | struct traffic_point * | this_ | ) |
Destroys a traffic_point
.
This will release the memory used by the traffic_point
and all related data.
A traffic_point
is usually destroyed together with its parent traffic_location
, thus it is usually not necessary to call this destructor directly.
this_ | The point |
References traffic_point::junction_name, traffic_point::junction_ref, and traffic_point::tmc_id.
Referenced by traffic_location_destroy().
|
static |
Whether two traffic points are equal.
Comparison is done solely on coordinates and requires a precise match. This can result in two points being reported as not equal, even though the locations using these points may translate to the same segments later.
l
and r
are equal, false if not References traffic_point::coord, coord_geo::lat, and coord_geo::lng.
Referenced by traffic_location_equals().
|
static |
Determines the degree to which the attributes of a point and a map item match.
The result of this method is used to match a location to a map item. Its result is a score—the higher the score, the better the match.
To calculate the score, all supplied attributes are examined and points are given for each attribute which is defined for the location. An exact match adds 4 points, a partial match adds 2. Values of 1 and 3 are added where additional granularity is needed. The number of points attained is divided by the maximum number of points attainable, and the result is returned as a percentage value.
If no points can be attained (because no attributes which must match are supplied), the score is 0 for any item supplied.
this_ | The traffic point |
item | The map item |
References compare_name_systematic(), item_attr_get(), item_attr_rewind(), traffic_point::junction_name, traffic_point::junction_ref, MAX_MISMATCH, attr::str, and attr::u.
Referenced by traffic_location_get_matching_points().
|
static |
Determines the degree to which the attributes of a point match those of the segments connecting to it.
The result of this method is used to match a location to a map item. Its result is a score—the higher the score, the better the match.
To calculate the score, this method iterates over all segments which begin or end at p
. The junction_name
member of the location is compared against the name of the segment, and the highest score for any segment is returned. Currently the name must match completely, resulting in a score of 100, while everything else is considered a mismatch (with a score of 0). Future versions may introduce support for partial matches, with the score indicating the quality of the match.
Segments which are part of the route are treated in a different manner, as the direction in which the segment is traversed (not the direction of the segment itself) is taken into account, which is needed to govern whether the matched segment ends up being part of the route or not.
In some cases, this_
refers to a point which is actually a segment (such as a bridge or tunnel), which we want to include in the route. In other cases, this_
refers to an intersection with another road, and the junction name is the name of the other road; these segments need to be excluded from the route.
This is controlled by the match_start
argument: if true, we are evaluating the start point of a route, else we are evaluating its end point. To include the matched segment in the route, only the first point (whose seg
member points to the segment) will match for the start point, the opposite is true for the end point. To exclude the matched segment, this logic is reversed.
A heuristic is in place to distinguish whether or not we want the matched segment included.
If no points can be attained (because no attributes which must match are supplied), the score is 0 for any point.
this_ | The traffic point |
p | The point shared by all segments to examine |
start | The first point of the path |
match_start | True to evaluate for the start point of a route, false for the end point |
References compare_name_systematic(), route_graph_segment::data, dbg, route_graph_segment::end, route_graph_segment::end_next, item::id_hi, item::id_lo, item, route_segment_data::item, item_attr_get(), item_attr_rewind(), traffic_point::junction_name, lvl_debug, item::map, map_rect_destroy(), map_rect_get_item_byid(), map_rect_new(), p, route_graph_point::seg, route_graph_point::start, route_graph_segment::start, route_graph_segment::start_next, attr::str, and attr::u.
Referenced by traffic_location_get_point_match().
struct traffic_point* traffic_point_new | ( | float | lon, |
float | lat, | ||
char * | junction_name, | ||
char * | junction_ref, | ||
char * | tmc_id | ||
) |
Creates a new traffic_point
.
It is the responsibility of the caller to destroy all references passed to this function. This can be done immediately after the function returns.
lon | The longitude, as reported by the source, in GPS coordinates |
lat | The latitude, as reported by the source, in GPS coordinates |
junction_name | The name of the motorway junction this point refers to, NULL if not applicable |
junction_ref | The reference number of the motorway junction this point refers to, NULL if not applicable |
tmc_id | The TMC identifier of the point, if the location was obtained via TMC, or NULL if not applicable |
References traffic_point::coord, traffic_point::junction_name, traffic_point::junction_ref, coord_geo::lat, lat, coord_geo::lng, and traffic_point::tmc_id.
Referenced by traffic_dummy_get_messages(), traffic_point_new_short(), and traffic_xml_end().
struct traffic_point* traffic_point_new_short | ( | float | lon, |
float | lat | ||
) |
Creates a new traffic_point
.
This is the short version of the constructor, which sets only mandatory members. Other members can be set after the instance is created.
lon | The longitude, as reported by the source, in GPS coordinates |
lat | The latitude, as reported by the source, in GPS coordinates |
References lat, and traffic_point_new().
void traffic_process_messages | ( | struct traffic * | this_, |
struct traffic_message ** | messages | ||
) |
Processes new traffic messages.
Calling this method delivers new messages in a “push” manner (as opposed to the “pull” fashion of calling a plugin method).
Messages which are past their expiration timestamp are skipped, and the flags in the return value are set only if at least one valid message is found.
this_ | The traffic instance |
messages | The new messages |
References callback_cast, callback_destroy(), callback_new_2, event_add_idle(), event_remove_idle(), traffic::idle_cb, traffic::idle_ev, traffic_shared_priv::message_queue, traffic::shared, and traffic_process_messages_int().
Referenced by request_navit_traffic_inject(), and traffic_traff_android_on_feed_received().
|
static |
Processes new traffic messages.
This is the internal backend for traffic_process_messages()
. It is also used internally.
The behavior of this function can be controlled via flags.
PROCESS_MESSAGES_PURGE_EXPIRED
causes expired messages to be purged from the message store after new messages have been processed. It is intended to be used with timer-triggered calls.
PROCESS_MESSAGES_NO_DUMP_STORE
prevents saving of the message store to disk, intended to be used when reading stored message data on startup.
Traffic messages are always read from this->shared->message_queue
. It can be empty, which makes sense e.g. when the PROCESS_MESSAGES_PURGE_EXPIRED
flag is used, to just purge expired messages.
this_ | The traffic instance |
flags | Flags, see description |
MESSAGE_UPDATE_MESSAGES
indicating that new messages were processed and MESSAGE_UPDATE_SEGMENTS
that segments were changed References map_selection::c_rect, callback_destroy(), coord_rect_overlap(), data, dbg, event_remove_idle(), traffic_message::expiration_time, message::id, traffic_message::id, traffic::idle_cb, traffic::idle_ev, traffic_message_priv::items, traffic_message::location, lvl_debug, traffic_shared_priv::map, map_selection_destroy(), traffic_shared_priv::message_queue, MESSAGE_UPDATE_MESSAGES, MESSAGE_UPDATE_SEGMENTS, traffic_shared_priv::messages, traffic_shared_priv::ms, traffic::navit, navit_draw_async(), navit_get_ready(), map_selection::next, attr::num, traffic_message::priv, map_methods::pro, PROCESS_MESSAGES_NO_DUMP_STORE, PROCESS_MESSAGES_PURGE_EXPIRED, traffic_message::replaces, route_get_attr(), route_get_pos(), route_get_selection(), route_recalculate_partial(), route_status_destination_set, traffic_shared_priv::rt, seg_data_equals(), traffic::shared, TIME_SLICE, tm_dump_to_textfile(), traffic_dump_messages_to_xml(), traffic_location_equals(), traffic_location_get_rect(), traffic_location_set_enclosing_rect(), traffic_map_meth, traffic_message_add_segments(), traffic_message_destroy(), traffic_message_dump_to_stderr(), traffic_message_parse_events(), traffic_message_remove_item_data(), traffic_message_restore_segments(), attr::u, and map_selection::u.
Referenced by traffic_get_map(), traffic_loop(), and traffic_process_messages().
|
static |
Extends the route beyond its end point.
This function follows the road beginning at end
, stopping at the next junction. It can be called again on the result, again extending it to the next junction.
To follow the road, each segment is compared to last
and the segment whose attributes match it is chosen, provided such a segment can be determined without ambiguity.
When the function returns, all points added to the route will have their seg
member set. To append the new stretch to the route, set the seg
member of its last point to the return value. After that, the extended route can be walked in the usual manner.
The value of each new point is the value of its predecessor on the route mins the length of the segment which links the two points. Point values thus continue to decrease along the route, allowing comparisons or difference calculations to be performed on the extended route. Note that this may result in points having negative values.
rg | The flooded route graph |
last | The last segment in the current route graph (either the start or the end member of this segment must be equal to the end argument) |
end | The last point of the current route graph (the seg member of this point must be NULL) |
NULL
if the route cannot be extended. References AF_ONEWAY, AF_ONEWAYREV, dbg, route_graph_point::end, route_graph_segment::end, item_is_equal_id, lvl_debug, lvl_error, p, RP_TURN_RESTRICTION, route_graph_segment::start, and route_graph_point::value.
Referenced by traffic_message_add_segments().
|
static |
Determines the path between two reference points in a route graph.
The reference points from
and to
are the beginning and end of the path and do not necessarily coincide with the from
and to
members of the location. For a point location with an auxiliary point, one will instead be the at
member of the location; when examining the opposite direction of a bidirectional location, from
and to
will be swapped with respect to the location.
The coordinates contained in the reference points are typically approximate, i.e. they do not precisely coincide with a point in the route graph.
When this function returns, the route graph will be flooded, i.e. every point will have a cost assigned to it and the seg
member for each point will be set, indicating the next segment on which to proceed in order to reach the destination. For the last point in the graph, seg
will be NULL
. Unlike in common routing, the last point will have a nonzero cost if to
does not coincide with a point in the route graph.
The cost of each node represents the cost to reach to
. The cost is calculated in traffic_route_get_seg_cost()
for actual segments, and distance (with a penalty factor) for the offroad connection from the last point in the graph to to
.
To obtain the path, start with the return value. Its seg
member points to the next segment. Either the start
or the end
value of that segment will coincide with the point currently being examined; the other of the two is the point at the other end. Repeat this until you reach a point whose seg
member is NULL
.
This function can be run multiple times against the same route graph but with different reference points. It is safe to call with NULL
passed for one or both reference points, in which case NULL
will be returned.
The caller is responsible for freeing up the data structures passed to this function when they are no longer needed.
rg | The route graph |
data | Data for the segments added to the map |
c_start | Start coordinates |
c_dst | Destination coordinates |
start_existing | Start point of an existing route (whose points will not be used) |
NULL
if no path was found. References route_graph_point::c, data, dbg, route_graph_point::el, route_graph_segment::end, route_graph_segment::end_next, fh_deleteheap(), fh_extractmin(), fh_insertkey(), fh_makekeyheap(), fh_replacekey(), route_graph::hash, HASH_SIZE, lvl_debug, p, PENALTY_OFFROAD, projection_mg, RP_TURN_RESTRICTION, route_graph_point::seg, route_graph_segment::start, route_graph_segment::start_next, traffic_route_get_seg_cost(), transform_distance(), and route_graph_point::value.
Referenced by traffic_message_add_segments().
|
static |
Returns the cost of the segment in the given direction.
The cost is calculated based on the length of the segment and a penalty which depends on the score. A segment with the maximum score of 100 is not penalized, i.e. its cost is equal to its length. A segment with a zero score is penalized with a factor of PENALTY_SEGMENT_MATCH
. For scores in between, a penalty factor between 1 and PENALTY_SEGMENT_MATCH
is applied.
If the segment is impassable in the given direction, the cost is always INT_MAX
.
over | The segment |
data | Data for the segments added to the map |
dir | The direction (positive numbers indicate positive direction) |
References AF_ALL, AF_ONEWAY, AF_ONEWAYREV, data, route_graph_segment::data, route_graph_segment::end, route_graph_point::flags, route_segment_data::flags, route_segment_data::item, route_segment_data::len, PENALTY_SEGMENT_MATCH, route_item_first, route_item_last, RP_TURN_RESTRICTION, route_segment_data::score, route_graph_segment::start, and item::type.
Referenced by traffic_route_flood_graph().
|
static |
Extends the route beyond its start point.
This function follows the road leading towards start
backwards, stopping at the next junction. It can be called again on the result, again extending it to the next junction.
To follow the road, each segment is compared to start->seg
and the segment whose attributes match it is chosen, provided such a segment can be determined without ambiguity.
When the function returns, all points added to the route will have their seg
member set so the extended route can be walked in the usual manner.
rg | The flooded route graph |
start | The current start of the route |
NULL
if the route cannot be extended (in which case start
continues to be the start of the route). References AF_ONEWAY, AF_ONEWAYREV, route_graph_segment::data, dbg, route_graph_point::end, route_graph_segment::end, route_graph_segment::end_next, route_segment_data::flags, route_segment_data::item, item_is_equal_id, route_segment_data::len, lvl_debug, route_graph_point::seg, route_graph_point::start, route_graph_segment::start, route_graph_segment::start_next, item::type, and route_graph_point::value.
Referenced by traffic_message_add_segments().
Sets the mapset for the traffic plugin.
This sets the mapset from which the segments affected by a traffic report will be retrieved.
this_ | The traffic plugin instance |
ms | The mapset |
References traffic_shared_priv::ms, and traffic::shared.
Referenced by navit_init().
Sets the route for the traffic plugin.
This sets the route which may get notified by the traffic plugin if traffic distortions change.
References traffic_shared_priv::rt, and traffic::shared.
Referenced by navit_init().
|
static |
Ensures the traffic instance points to valid shared data.
This method first examines all registered traffic instances to see if one of them has the shared
member set. If that is the case, the current instance copies the shared
pointer of the other instance. Otherwise a new struct traffic_shared_priv
is created and its address stored in shared
.
Calling this method on a traffic instance with a non-NULL shared
member has no effect.
this_ | The traffic instance |
References dbg, attr_iter::iter, lvl_debug, traffic::navit, navit_attr_iter_destroy(), navit_attr_iter_new(), navit_get_attr(), attr::navit_object, traffic::shared, and attr::u.
Referenced by traffic_new().
void traffic_suppl_info_destroy | ( | struct traffic_suppl_info * | this_ | ) |
Destroys a traffic_suppl_info
.
This will release the memory used by the traffic_suppl_info
and all related data.
A traffic_suppl_info
is usually destroyed together with its parent traffic_event
, thus it is usually not necessary to call this destructor directly.
this_ | The supplementary information item |
References traffic_suppl_info::quantifier.
Referenced by traffic_event_destroy().
struct traffic_suppl_info* traffic_suppl_info_new | ( | enum si_class | si_class, |
enum si_type | type, | ||
struct quantifier * | quantifier | ||
) |
Creates a new traffic_suppl_info
.
It is the responsibility of the caller to destroy all references passed to this function. This can be done immediately after the function returns.
si_class | The supplementary information class (generic category) |
type | The supplementary information type, which can be mapped to a string to be displayed to the user |
quantifier | Additional quantifier for supplementary information types allowing this, or NULL |
References traffic_suppl_info::quantifier, traffic_suppl_info::si_class, type, and traffic_suppl_info::type.
Referenced by traffic_xml_start().
|
static |
Frees up an XML element structure.
This will free up the memory used by the struct and all its members.
References xml_element::names, xml_element::tag_name, xml_element::text, and xml_element::values.
Referenced by traffic_xml_end().
|
static |
Creates a new XML element structure.
Note that the structure of names
and values
may differ between XML libraries. Behavior is indicated by the XML_ATTR_DISTANCE
constant.
If XML_ATTR_DISTANCE == 1
, names
and values
are two separate arrays, and values[n]
is the value that corresponds to names[n]
.
If XML_ATTR_DISTANCE == 2
, attribute names and values are kept in a single array in which names and values alternate, names first. In this case, names
points to the array while values
points to its second element, i.e. the first value. In this case, value
is invalid for an empty array, and dereferencing it may segfault.
tag_name | The tag name |
names | Attribute names |
values | Attribute values |
References xml_element::names, xml_element::tag_name, xml_element::values, and XML_ATTR_DISTANCE.
Referenced by traffic_xml_start().
|
static |
Callback function which gets called when a closing tag is encountered.
tag_name | The tag name |
data | Points to a struct xml_state holding parser state |
References xml_state::at, boolean_new(), data, dbg, event_class_new(), event_type_new(), xml_state::events, xml_state::from, message::id, xml_state::is_opened, xml_state::is_valid, item_type_from_road_type(), lat, length, xml_state::location, location_dir_new(), location_fuzziness_new(), location_ramps_new(), xml_state::location_txt_data, lvl_debug, lvl_error, xml_state::messages, xml_element::names, xml_state::not_via, traffic_location::priv, xml_state::si, xml_element::tag_name, xml_state::tagstack, xml_element::text, time_new(), xml_state::to, traffic_event_destroy(), traffic_event_is_valid(), traffic_event_new(), traffic_location_new(), traffic_message_destroy(), traffic_message_is_valid(), traffic_message_new(), traffic_point_new(), traffic_xml_element_destroy(), traffic_xml_get_attr(), traffic_xml_is_tagstack_valid(), traffic_location_priv::txt_data, xml_element::values, and xml_state::via.
Referenced by traffic_get_messages_from_xml_file(), and traffic_get_messages_from_xml_string().
|
static |
Retrieves the value of an XML attribute.
name | The name of the attribute to retrieve |
names | All attribute names |
values | Attribute values (indices correspond to names ) |
names
contains name
, the corresponding value is returned, else NULL References xml_element::names, and xml_element::values.
Referenced by traffic_xml_end(), and traffic_xml_start().
|
static |
Whether the tag stack represents a hierarchy of elements which is recognized.
state | The XML parser state |
References xml_element::tag_name, and xml_state::tagstack.
Referenced by traffic_xml_end(), and traffic_xml_start().
|
static |
Callback function which gets called when an opening tag is encountered.
tag_name | The tag name |
names | Attribute names |
values | Attribute values (indices correspond to names ) |
data | Points to a struct xml_state holding parser state |
References data, dbg, xml_state::is_opened, xml_state::is_valid, lvl_debug, xml_element::names, xml_state::si, si_class_new(), si_type_new(), xml_element::tag_name, xml_state::tagstack, traffic_suppl_info_new(), traffic_xml_element_new(), traffic_xml_get_attr(), traffic_xml_is_tagstack_valid(), and xml_element::values.
Referenced by traffic_get_messages_from_xml_file(), and traffic_get_messages_from_xml_string().
|
static |
Callback function which gets called when character data is encountered.
text | The character data (note that the data is not NULL-terminated!) |
len | The number of characters in text |
data | Points to a struct xml_state holding parser state |
Referenced by traffic_get_messages_from_xml_file(), and traffic_get_messages_from_xml_string().
int item_default_flags_value = AF_ALL |
Default value assumed for access flags if we cannot get flags for the item, nor for the item type
Referenced by traffic_location_populate_route_graph(), and traffic_message_restore_segments().
|
static |
Referenced by tm_add_item().
struct object_func traffic_func |
Referenced by object_func_lookup(), and traffic_new().
|
static |
Referenced by tm_rect_new(), traffic_map_new(), and traffic_process_messages_int().