navit
0.5.3-trunk
|
Contains exported code for traffic.c, the traffic module. More...
Go to the source code of this file.
Data Structures | |
struct | traffic_methods |
Holds all functions a traffic plugin has to implement to be usable. More... | |
struct | traffic_point |
A point on the road. More... | |
struct | traffic_location |
Location data for a traffic message. More... | |
struct | quantifier |
A quantifier, which can be used with events and supplementary information. More... | |
struct | traffic_suppl_info |
Extra information supplied with a traffic event. More... | |
struct | traffic_event |
A traffic event. More... | |
struct | traffic_message |
A traffic message. More... | |
Macros | |
#define | order_to_min_road_class(x) (x <= 8 ? "PRIMARY" : x <= 10 ? "SECONDARY" : x <= 12 ? "TERTIARY" : NULL) |
Translates a Navit tile order to a minimum road class as used in TraFF. More... | |
Functions | |
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... | |
void | traffic_init (void) |
Initializes the traffic plugin. 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 map * | traffic_get_map (struct traffic *this_) |
Returns the map for the traffic plugin. 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... | |
Contains exported code for traffic.c, the traffic module.
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 Library 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 Library General Public License for more details.
You should have received a copy of the GNU Library 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.
This file contains types and function prototypes exported from the traffic module, which enables Navit to route around traffic problems.
The traffic module consists of two parts:
The traffic core interacts with the Navit core and converts traffic messages into traffic distortions (future versions may add support for other traffic information).
The traffic backends obtain traffic information from a source of their choice (e.g. from a TMC receiver or a network service), translate them into Navit data structures and report them to the traffic plugin.
Traffic messages and related structures are considered immutable once created (when information changes, the old message is replaced with a new one). For this reason, there are very few data manipulation methods. Those that exist are intended for the creation of new messages rather than for extensive manipulation.
As a rule, responsibility for freeing up any traffic_*
instances normally lies with the traffic plugin, which frees messages as they expire or are replaced. Since this also frees all child data structures, traffic backends will seldom need to call any of the destructors. The only case in which this would be necessary is if a backend has instantiated an object which is not going to be used (i.e. attached to a parent object or, in the case of traffic_message
, reported to the traffic plugin: these need to be freed up manually by calling the destructor of the topmost object in the hierarchy.
Any other references passed in functions (including pointer arrays and quantifier
instances) must be freed up by the caller. This is safe to do as soon as the function returns.
#define order_to_min_road_class | ( | x | ) | (x <= 8 ? "PRIMARY" : x <= 10 ? "SECONDARY" : x <= 12 ? "TERTIARY" : NULL) |
Translates a Navit tile order to a minimum road class as used in TraFF.
This can be used to translate a map selection into a TraFF filter.
The tile order is the lowest tile level in which an object of a certain type can be placed (higher numbers correspond to lower levels). Currently, 8 is the maximum order for highway_city
, highway_land
and street_n_lanes
, equivalent to MOTORWAY
and TRUNK
. 10 is the maximum order for street_4_city
and street_4_land
(SECONDARY
), 12 for street_3_city
and street_3_land
(TERTIARY
). All others can be placed in any tile level.
This macro returns PRIMARY
, SECONDARY
and TERTIARY
for the three bins above these cut-off orders, corresponding to one level below the lowest road class we expect to find there. (Not considering that low-level roads can be placed into higher-level tiles if they cross a tile boundary of the next lower level.) Below the lowest cut-off order, the macro returns NULL.
enum event_class |
Classes for events.
enum event_type |
Event types.
enum location_dir |
enum location_fuzziness |
The fuzziness of a location.
enum location_ramps |
Whether a location refers to the main carriageway or the ramps.
enum si_class |
Classes for supplementary information items.
enum si_type |
Supplementary information types.
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().
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().
void traffic_destroy | ( | struct traffic * | this_ | ) |
Destructor.
References attr_list_free(), traffic_methods::destroy, traffic::meth, and traffic::priv.
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.
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().
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().
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().
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.
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.
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().
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().
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().
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().
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().
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().
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().