navit  0.5.3-trunk
traffic.h File Reference

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...
 

Enumerations

enum  event_class { event_class_invalid = 0 , event_class_congestion , event_class_delay , event_class_restriction }
 Classes for events. More...
 
enum  event_type {
  event_invalid = 0 , 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_contraflow , event_restriction_closed , event_restriction_closed_ahead , 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 , event_restriction_speed_limit_lifted
}
 Event types. More...
 
enum  location_dir { location_dir_one = 1 , location_dir_both = 2 }
 The directionality of a location. More...
 
enum  location_fuzziness {
  location_fuzziness_none = 0 , location_fuzziness_low_res , location_fuzziness_end_unknown , location_fuzziness_start_unknown ,
  location_fuzziness_extent_unknown
}
 The fuzziness of a location. More...
 
enum  location_ramps { location_ramps_none = 0 , location_ramps_all , location_ramps_entry , location_ramps_exit }
 Whether a location refers to the main carriageway or the ramps. More...
 
enum  si_class { si_class_invalid = 0 , si_class_place , si_class_tendency , si_class_vehicle }
 Classes for supplementary information items. More...
 
enum  si_type {
  si_invalid = 0 , 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 , si_vehicle_with_trailer
}
 Supplementary information types. 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_pointtraffic_point_new (float lon, float lat, char *junction_name, char *junction_ref, char *tmc_id)
 Creates a new traffic_point. More...
 
struct traffic_pointtraffic_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_locationtraffic_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_locationtraffic_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_infotraffic_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_eventtraffic_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_eventtraffic_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_infotraffic_event_get_suppl_info (struct traffic_event *this_, int index)
 Retrieves a supplementary information item associated with an event. More...
 
struct traffic_messagetraffic_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_messagetraffic_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_messagetraffic_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_messagetraffic_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_eventtraffic_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 maptraffic_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...
 

Detailed Description

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.

Macro Definition Documentation

◆ order_to_min_road_class

#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.

Enumeration Type Documentation

◆ event_class

Classes for events.

Enumerator
event_class_invalid 

Invalid event which should be ignored

event_class_congestion 

Traffic congestion, typically indicating the approximate speed

event_class_delay 

Delays, typically indicating the amount of extra waiting time

event_class_restriction 

Temporary traffic restrictions, such as road or lane closures or size, weight or access restrictions

◆ event_type

enum event_type

Event types.

Enumerator
event_invalid 

Invalid event which should be ignored

event_congestion_cleared 

Traffic congestion cleared

event_congestion_forecast_withdrawn 

Traffic congestion forecast withdrawn

event_congestion_heavy_traffic 

Heavy traffic with average speeds of speed

event_congestion_long_queue 

Long queues with average speeds of speed

event_congestion_none 

No problems to report

event_congestion_normal_traffic 

Traffic has returned to normal

event_congestion_queue 

Queuing traffic with average speeds of speed

event_congestion_queue_likely 

Danger of queuing traffic with average speeds of speed

event_congestion_slow_traffic 

Slow traffic with average speeds of speed

event_congestion_stationary_traffic 

Stationary traffic (frequent standstills)

event_congestion_stationary_traffic_likely 

Danger of stationary traffic

event_congestion_traffic_building_up 

Traffic building up with average speeds of speed

event_congestion_traffic_congestion 

Traffic congestion with average speeds of speed

event_congestion_traffic_easing 

Traffic easing

event_congestion_traffic_flowing_freely 

Traffic flowing freely with average speeds of speed

event_congestion_traffic_heavier_than_normal 

Traffic heavier than normal with average speeds of speed

event_congestion_traffic_lighter_than_normal 

Traffic lighter than normal with average speeds of speed

event_congestion_traffic_much_heavier_than_normal 

Traffic very much heavier than normal with average speeds of speed (increased density but no significant decrease in speed)

event_congestion_traffic_problem 

Traffic problem

event_delay_clearance 

Delays cleared

event_delay_delay 

Delays up to q_timespan

event_delay_delay_possible 

Delays up to q_timespan possible

event_delay_forecast_withdrawn 

Delay forecast withdrawn

event_delay_long_delay 

Long delays up to q_timespan

event_delay_several_hours 

Delays of several hours

event_delay_uncertain_duration 

Delays of uncertain duration

event_delay_very_long_delay 

Very long delays up to q_timespan

event_restriction_access_restrictions_lifted 

Traffic restrictions lifted: reopened for all traffic, other restrictions (overtaking etc.) remain in place

event_restriction_all_carriageways_cleared 

All carriageways cleared

event_restriction_all_carriageways_reopened 

All carriageways reopened

event_restriction_batch_service 

Batch service (to limit the amount of traffic passing through a section, unlike single alternate line traffic)

event_restriction_blocked 

Blocked (refers to the entire road; separate codes exist for blockages of individual lanes or carriageways)

event_restriction_blocked_ahead 

Blocked ahead (at a point beyond the indicated location)

event_restriction_carriageway_blocked 

Carriageway blocked (main carriageway, unless otherwise indicated in supplementary information)

event_restriction_carriageway_closed 

Carriageway closed (main carriageway, unless otherwise indicated in supplementary information)

event_restriction_contraflow 

Contraflow

event_restriction_closed 

Closed until q_time (refers to the entire road; separate codes exist for closures of individual lanes or carriageways)

event_restriction_closed_ahead 

Closed ahead (at a point beyond the indicated location)

event_restriction_entry_blocked 

q_int th entry slip road blocked

event_restriction_entry_reopened 

Entry reopened

event_restriction_exit_blocked 

q_int th exit slip road blocked

event_restriction_exit_reopened 

Exit reopened

event_restriction_intermittent_closures 

Intermittent short term closures

event_restriction_lane_blocked 

q_int lanes blocked

event_restriction_lane_closed 

q_int lanes closed

event_restriction_open 

Open

event_restriction_ramp_blocked 

Ramps blocked

event_restriction_ramp_closed 

Ramps closed

event_restriction_ramp_reopened 

Ramps reopened

event_restriction_reduced_lanes 

Carriageway reduced from q_ints[1] lanes to q_int[0] lanes (quantifiers are currently not implemented for this event type)

event_restriction_reopened 

Reopened

event_restriction_road_cleared 

Road cleared

event_restriction_single_alternate_line_traffic 

Single alternate line traffic (because the affected stretch of road can only be used in one direction at a time, different from batch service)

event_restriction_speed_limit 

Speed limit speed in force

event_restriction_speed_limit_lifted 

Speed limit lifted

◆ location_dir

The directionality of a location.

Enumerator
location_dir_one 

Indicates a unidirectional location.

location_dir_both 

Indicates a bidirectional location.

◆ location_fuzziness

The fuzziness of a location.

Enumerator
location_fuzziness_none 

No fuzziness information is given.

location_fuzziness_low_res 

Locations are constrained to a predefined table; the actual extent of the condition may be shorter than indicated.

location_fuzziness_end_unknown 

The end is unknown, e.g. a traffic jam reported by a driver who has just entered it.

location_fuzziness_start_unknown 

The start is unknown, e.g. a traffic jam reported by a driver who has just passed the obstruction which caused it.

location_fuzziness_extent_unknown 

Start and end are unknown, e.g. a traffic jam reported by a driver who is in the middle of it.

◆ location_ramps

Whether a location refers to the main carriageway or the ramps.

Enumerator
location_ramps_none 

The location refers to the carriageways of the main road.

location_ramps_all 

The location refers to the entry and exit ramps, not the main carriageway.

location_ramps_entry 

The location refers to the entry ramps only, not the main carriageway.

location_ramps_exit 

The location refers to the exit ramps only, not the main carriageway.

◆ si_class

enum si_class

Classes for supplementary information items.

Enumerator
si_class_invalid 

Invalid supplementary information item which should be ignored

si_class_place 

Qualifiers specifying the place(s) to which the event refers

si_class_tendency 

Traffic density development

si_class_vehicle 

Specifies categories of vehicles to which the event applies

◆ si_type

enum si_type

Supplementary information types.

Enumerator
si_invalid 

Invalid supplementary information item which should be ignored

si_place_bridge 

On bridges

si_place_ramp 

On ramps (entry/exit)

si_place_roadworks 

In the roadworks area

si_place_tunnel 

In tunnels

si_tendency_queue_decreasing 

Traffic queue length decreasing (average rate in optional q_speed)

si_tendency_queue_increasing 

Traffic queue length increasing (average rate in optional q_speed)

si_vehicle_all 

For all vehicles

si_vehicle_bus 

For buses only (TODO currently supported for public buses only)

si_vehicle_car 

For cars only

si_vehicle_car_with_caravan 

For cars with caravans only (TODO currently not supported)

si_vehicle_car_with_trailer 

For cars with trailers only (TODO currently not supported)

si_vehicle_hazmat 

For hazardous loads only

si_vehicle_hgv 

For heavy trucks only

si_vehicle_motor 

For all motor vehicles

si_vehicle_with_trailer 

For vehicles with trailers only (TODO currently not supported)

Function Documentation

◆ event_class_new()

enum event_class event_class_new ( char *  string)

Creates an event class from its string representation.

Parameters
stringThe string representation (case is ignored)
Returns
The corresponding 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().

◆ event_class_to_string()

const char* event_class_to_string ( enum event_class  this_)

Translates an event class to its string representation.

Returns
The string representation of the event class

References event_class_congestion, event_class_delay, and event_class_restriction.

Referenced by traffic_dump_messages_to_xml(), and traffic_message_dump_to_stderr().

◆ event_type_new()

enum event_type event_type_new ( char *  string)

Creates an event type from its string representation.

Parameters
stringThe string representation (case is ignored)
Returns
The corresponding enum event_type, or event_invalid if string does not match a known identifier

Referenced by event_request_system(), and traffic_xml_end().

◆ event_type_to_string()

const char* event_type_to_string ( enum event_type  this_)

Translates an event type to its string representation.

Returns
The string representation of the event type

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().

◆ item_type_from_road_type()

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.

Parameters
stringA TraFF road type or the string representation of a Navit item type
is_urbanWhether the road is in a built-up area (ignored if string is a Navit item type)
Returns
The corresponding enum item_type, or type_line_unspecified if string does not match a known and routable identifier

Referenced by traffic_xml_end().

◆ location_dir_new()

enum location_dir location_dir_new ( char *  string)

Creates a location directionality from its string representation.

Parameters
stringThe string representation (case is ignored)
Returns
The corresponding enum location_dir, or location_dir_both if string does not match a known identifier

Referenced by traffic_xml_end().

◆ location_fuzziness_new()

enum location_fuzziness location_fuzziness_new ( char *  string)

Creates a location fuzziness from its string representation.

Parameters
stringThe string representation (case is ignored)
Returns
The corresponding enum location_fuzziness, or location_fuzziness_none if string does not match a known identifier

Referenced by traffic_xml_end().

◆ location_fuzziness_to_string()

const char* location_fuzziness_to_string ( enum location_fuzziness  this_)

Translates location fuzziness to its string representation.

Returns
The string representation of the location fuzziness, or NULL for 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().

◆ location_ramps_new()

enum location_ramps location_ramps_new ( char *  string)

Creates an enum location_ramps from its string representation.

Parameters
stringThe string representation (case is ignored)
Returns
The corresponding enum location_ramps, or location_ramps_none if string does not match a known identifier

Referenced by traffic_xml_end().

◆ location_ramps_to_string()

const char* location_ramps_to_string ( enum location_ramps  this_)

Translates an enum location_ramps to its string representation.

Returns
The 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().

◆ si_class_new()

enum si_class si_class_new ( char *  string)

Creates a supplementary information class from its string representation.

Parameters
stringThe string representation (case is ignored)
Returns
The corresponding enum si_class, or si_class_invalid if string does not match a known identifier

Referenced by traffic_xml_start().

◆ si_class_to_string()

const char* si_class_to_string ( enum si_class  this_)

Translates a supplementary information class to its string representation.

Returns
The string representation of the supplementary information class

References si_class_place, si_class_tendency, and si_class_vehicle.

Referenced by traffic_dump_messages_to_xml(), and traffic_message_dump_to_stderr().

◆ si_type_new()

enum si_type si_type_new ( char *  string)

Creates a supplementary information type from its string representation.

Parameters
stringThe string representation (case is ignored)
Returns
The corresponding enum si_type, or si_invalid if string does not match a known identifier

Referenced by traffic_xml_start().

◆ si_type_to_string()

const char* si_type_to_string ( enum si_type  this_)

◆ traffic_destroy()

void traffic_destroy ( struct traffic this_)

◆ traffic_event_add_suppl_info()

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.

Parameters
this_The event
siThe supplementary information item

References traffic_event::si, and traffic_event::si_count.

◆ traffic_event_destroy()

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.

Parameters
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().

◆ traffic_event_get_suppl_info()

struct traffic_suppl_info* traffic_event_get_suppl_info ( struct traffic_event this_,
int  index 
)

Retrieves a supplementary information item associated with an event.

Parameters
this_The event
indexThe index of the supplementary information item, zero-based
Returns
The supplementary information item at the specified position, or NULL if out of bounds

References traffic_event::si.

◆ traffic_event_new()

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.

Parameters
event_classThe event class (generic category)
typeThe event type, which can be mapped to a string to be displayed to the user
lengthThe length of the affected route in meters, -1 if not known
speedThe 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
quantifierAdditional quantifier for supplementary information types allowing this, or NULL
si_countNumber of supplementary information items in si_count
siPoints 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().

◆ traffic_event_new_short()

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.

Parameters
event_classThe event class (generic category)
typeThe 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().

◆ traffic_get_map()

struct map* traffic_get_map ( struct traffic this_)

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.

Parameters
this_The traffic plugin instance
Returns
The traffic map

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().

◆ traffic_get_messages_from_xml_file()

struct traffic_message** traffic_get_messages_from_xml_file ( struct traffic this_,
char *  filename 
)

Reads previously stored traffic messages from an XML file.

Parameters
this_The traffic instance
filenameThe full path to the XML file to parse
Returns
A 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().

◆ traffic_get_messages_from_xml_string()

struct traffic_message** traffic_get_messages_from_xml_string ( struct traffic this_,
char *  xml 
)

Reads traffic messages from an XML string.

Parameters
this_The traffic instance
filenameThe XML document to parse, as a string
Returns
A 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().

◆ traffic_get_stored_messages()

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.

Parameters
this_The traffic plugin instance
Returns
A null-terminated array of traffic messages. The caller is responsible for freeing the array (not its elements) when it is no longer needed. This method will always return a valid pointer—if the message store is empty, an empty array (with just one single NULL element) will be returned.

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().

◆ traffic_init()

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().

◆ traffic_location_destroy()

void traffic_location_destroy ( struct traffic_location this_)

◆ traffic_location_new()

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.

Parameters
atThe coordinates for a point location, NULL for a linear location
fromThe start of a linear location, or a point before at
toThe end of a linear location, or a point after at
viaA point between from and to, needed only on ring roads
not_viaA point not between from and to, needed only on ring roads
destinationA 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
directionA compass direction indicating the direction of travel which this location refers to; can be NULL, do not use where ambiguous
directionalityWhether the location is unidirectional or bidirectional
fuzzinessA precision indicator for from and to
rampsWhether the main carriageway or the ramps are affected
road_typeThe importance of the road within the road network, must be a road item type, type_line_unspecified if not known or not consistent
road_nameA road name, if consistent throughout the location; NULL if not known or inconsistent
road_refA road number, if consistent throughout the location; NULL if not known or inconsistent
tmc_tableFor messages received via TMC, the CID and LTN; NULL otherwise
tmc_directionFor 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().

◆ traffic_location_new_short()

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.

Parameters
atThe coordinates for a point location, NULL for a linear location
fromThe start of a linear location, or a point before at
toThe end of a linear location, or a point after at
viaA point between from and to, needed only on ring roads
not_viaA point not between from and to, needed only on ring roads
directionalityWhether the location is unidirectional or bidirectional
fuzzinessA 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.

◆ traffic_message_add_event()

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.

Parameters
this_The message
eventThe event to add to this message

References traffic_message::event_count, and traffic_message::events.

◆ traffic_message_destroy()

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.

Parameters
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().

◆ traffic_message_get_event()

struct traffic_event* traffic_message_get_event ( struct traffic_message this_,
int  index 
)

Retrieves an event associated with a message.

Parameters
this_The message
indexThe index of the event, zero-based
Returns
The event at the specified position, or NULL if out of bounds

References traffic_message::events.

◆ traffic_message_get_items()

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.

Parameters
this_The message
Returns
Items as a NULL-terminated array. The caller is responsible for freeing the array (not its elements) when it is no longer needed. This method will always return a valid pointer—if no items are associated with the message, an empty array (with just one single NULL element) will be returned. No particular order is guaranteed for the items.

References traffic_message_priv::items, and traffic_message::priv.

Referenced by request_navit_traffic_export_gpx().

◆ traffic_message_new()

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.

Parameters
idThe message identifier; existing messages with the same identifier will be replaced by the new message
receive_timeWhen the message was first received by the source, should be kept stable across all updates
update_timeWhen the last update to this message was received by the source
expiration_timeHow long the message should be considered valid
start_timeWhen the condition is expected to begin (optional, 0 if not set)
end_timeHow long the condition is expected to last (optional, 0 if not set)
isCancellationIf true, create a cancellation message (existing messages with the same ID should be deleted or no longer considered current, and all other attributes ignored)
isForecastIf false, the message describes a current situation; if true, it describes an expected situation in the future
replaced_countThe number of entries in replaces
replacesPoints to an array of identifiers of messages which the current message replaces
locationThe location to which this message refers
event_countThe number of events in events
eventsPoints 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().

◆ traffic_message_new_cancellation()

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.

Parameters
idThe message identifier; existing messages with the same identifier will be replaced by the new message
receive_timeWhen the message was first received by the source, should be kept stable across all updates
update_timeWhen the last update to this message was received by the source
expiration_timeHow long the message should be considered valid
locationThe 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().

◆ traffic_message_new_short()

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.

Parameters
idThe message identifier; existing messages with the same identifier will be replaced by the new message
receive_timeWhen the message was first received by the source, should be kept stable across all updates
update_timeWhen the last update to this message was received by the source
expiration_timeHow long the message should be considered valid
is_forecastIf false, the message describes a current situation; if true, it describes an expected situation in the future
locationThe location to which this message refers
event_countThe number of events in events
eventsPoints 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().

◆ 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.

Parameters
idThe message identifier; existing messages with the same identifier will be replaced by the new message
receive_timeWhen the message was first received by the source, should be kept stable across all updates
update_timeWhen the last update to this message was received by the source
expiration_timeHow long the message should be considered valid
is_forecastIf false, the message describes a current situation; if true, it describes an expected situation in the future
locationThe location to which this message refers
event_classThe event class (generic category)
typeThe 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().

◆ traffic_point_destroy()

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.

Parameters
this_The point

References traffic_point::junction_name, traffic_point::junction_ref, and traffic_point::tmc_id.

Referenced by traffic_location_destroy().

◆ traffic_point_new()

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.

Parameters
lonThe longitude, as reported by the source, in GPS coordinates
latThe latitude, as reported by the source, in GPS coordinates
junction_nameThe name of the motorway junction this point refers to, NULL if not applicable
junction_refThe reference number of the motorway junction this point refers to, NULL if not applicable
tmc_idThe 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().

◆ traffic_point_new_short()

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.

Parameters
lonThe longitude, as reported by the source, in GPS coordinates
latThe latitude, as reported by the source, in GPS coordinates

References lat, and traffic_point_new().

◆ traffic_process_messages()

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.

Parameters
this_The traffic instance
messagesThe 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().

◆ traffic_set_mapset()

void traffic_set_mapset ( struct traffic this_,
struct mapset ms 
)

Sets the mapset for the traffic plugin.

This sets the mapset from which the segments affected by a traffic report will be retrieved.

Parameters
this_The traffic plugin instance
msThe mapset

References traffic_shared_priv::ms, and traffic::shared.

Referenced by navit_init().

◆ traffic_set_route()

void traffic_set_route ( struct traffic this_,
struct route rt 
)

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().

◆ traffic_suppl_info_destroy()

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.

Parameters
this_The supplementary information item

References traffic_suppl_info::quantifier.

Referenced by traffic_event_destroy().

◆ traffic_suppl_info_new()

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.

Parameters
si_classThe supplementary information class (generic category)
typeThe supplementary information type, which can be mapped to a string to be displayed to the user
quantifierAdditional 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().