navit
0.5.3-trunk
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <glib.h>
#include "debug.h"
#include "profile.h"
#include "navigation.h"
#include "coord.h"
#include "item.h"
#include "xmlconfig.h"
#include "route.h"
#include "transform.h"
#include "mapset.h"
#include "projection.h"
#include "map.h"
#include "navit.h"
#include "event.h"
#include "callback.h"
#include "speech.h"
#include "vehicleprofile.h"
#include "plugin.h"
#include "navit_nls.h"
#include "util.h"
#include "linguistics.h"
Data Structures | |
struct | suffix |
struct | navigation |
struct | navigation_maneuver |
Holds information about a navigation maneuver. More... | |
struct | navigation_command |
Holds information about a command for a navigation maneuver. More... | |
struct | navigation_way |
struct | navigation_itm |
struct | street_destination |
A linked list containing the destination of the road. More... | |
struct | map_priv |
Represents the map from a single binfile. More... | |
struct | map_rect_priv |
Implementation-specific map rect data. More... | |
Macros | |
#define | SIZE_OF_ARRAY_DISTANCES (sizeof (distances)/sizeof (int)) |
#define | LAST_DISTANCE (SIZE_OF_ARRAY_DISTANCES - 1) |
#define | mex_none 0 |
#define | mex_merge 1 |
#define | mex_exit 2 |
#define | mex_interchange 4 |
#define | mex_merge_right 9 |
#define | mex_exit_right 10 |
#define | mex_merge_left 17 |
#define | mex_exit_left 18 |
Enumerations | |
enum | announcement_level { level_connect = -2 , level_error = -1 , level_now = 0 , level_meters = 1 , level_soon = 2 , level_follow = 3 } |
enum | gender { unknown , masculine , feminine , neuter } |
enum | nav_status_int { status_none = 0 , status_busy = 1 , status_has_ritem = 2 , status_has_sitem = 4 } |
Functions | |
static void | navigation_flush (struct navigation *this_) |
static int | angle_delta (int angle1, int angle2) |
Calculates the delta between two angles. More... | |
static int | angle_median (int angle1, int angle2) |
static int | angle_opposite (int angle) |
static int | is_same_street2 (char *old_name, char *old_name_systematic, char *new_name, char *new_name_systematic) |
Checks if two navigation items are on the same street. More... | |
static int | is_same_way (struct navigation_way *w1, struct navigation_way *w2) |
Checks if two ways are identical. More... | |
static void | free_list (struct street_destination *list) |
Frees a list as constructed with split_string_to_list() More... | |
static int | split_string_to_list (struct navigation_way *way, char *raw_string, char sep) |
Splits a string into a list, and sets their initial rank to 0. More... | |
static struct street_destination * | get_bestranked (struct street_destination *street_destination) |
Returns the first destination with a rank higher than zero. More... | |
static int | set_highrank (struct street_destination *street_destination, struct navigation_command *command) |
Assigns a high rank to a matching destination in the next command having destination info, and reset existing ranks to zero. More... | |
static char * | select_announced_destinations (struct navigation_command *current_command) |
Selects the destination-names for the next announcement from the destination-names that are registered in the following command items. More... | |
char * | nav_status_to_text (int status) |
Converts navigation status to human-readable text. More... | |
int | navigation_get_attr (struct navigation *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) |
static void | navigation_set_turnaround (struct navigation *this_, int val) |
int | navigation_set_attr (struct navigation *this_, struct attr *attr) |
struct navigation * | navigation_new (struct attr *parent, struct attr **attrs) |
int | navigation_set_announce (struct navigation *this_, enum item_type type, int *level) |
static enum announcement_level | navigation_get_announce_level (struct navigation *this_, enum item_type type, int dist) |
static int | is_way_allowed (struct navigation *nav, struct navigation_way *way, int mode) |
Checks whether a way is allowed. More... | |
static enum announcement_level | navigation_get_announce_level_cmd (struct navigation *this_, struct navigation_itm *itm, struct navigation_command *cmd, int distance) |
static int | road_angle (struct coord *c1, struct coord *c2, int dir) |
Gets the bearing from one point to another. More... | |
static const char * | get_count_str (int n) |
static const char * | get_exit_count_str (int n) |
static int | round_distance (int dist) |
static int | round_distance_reduced (int dist) |
Restricts the distance value to a simple set of pronounceable numbers. More... | |
static char * | get_distance_str (struct navigation *nav, int dist_meters, enum attr_type type, int is_length) |
Generates the distance string. Considers the configuration of 'imperial' units and 'vocabulary_distances'. 'imperial' if set distinguishes the distance statement between miles and feet. Maximum distance in feet is 500. 'vocabulary_distances' if set constrains the distance values to a set of simple pronounceable numbers. More... | |
static void | navigation_way_init (struct navigation_way *w) |
Initializes a navigation_way. More... | |
static int | navigation_way_get_max_delta (struct navigation_way *w, enum projection pro, int angle, double dist, int dir) |
Returns the maximum delta between a reference bearing and any segment of a given way, up to a given distance from its start. More... | |
static void | navigation_itm_ways_clear (struct navigation_itm *itm) |
Clears the ways one can drive from itm. More... | |
static void | navigation_itm_ways_update (struct navigation_itm *itm, struct map *graph_map) |
Updates the ways one can drive from itm. More... | |
static void | navigation_destroy_itms_cmds (struct navigation *this_, struct navigation_itm *end) |
Destroys navigation items associated with a navigation object. More... | |
static void | navigation_itm_update (struct navigation_itm *itm, struct item *ritem) |
static struct navigation_itm * | navigation_itm_new (struct navigation *this_, struct item *routeitem) |
Creates and adds a new navigation_itm to a linked list of such. More... | |
static int | count_possible_turns (struct navigation *nav, struct navigation_itm *from, struct navigation_itm *to, int direction) |
Counts how many times a driver could turn right/left. More... | |
static void | calculate_dest_distance (struct navigation *this_, int incr) |
Calculates distance and time to the destination. More... | |
static int | maneuver_category (enum item_type type) |
static int | is_motorway_like (struct navigation_way *way, int extended) |
Checks whether a way has motorway-like characteristics. More... | |
static int | is_ramp (struct navigation_way *way) |
Checks whether a way is a ramp. More... | |
static int | maneuver_required2 (struct navigation *nav, struct navigation_itm *old, struct navigation_itm *new, struct navigation_maneuver **maneuver) |
Checks if navit has to create a maneuver to drive from old to new. More... | |
static int | adjust_delta (int delta, int reference) |
Adjusts a bearing delta to point in the same direction as a reference delta. More... | |
static void | navigation_analyze_roundabout (struct navigation *this_, struct navigation_command *cmd, struct navigation_itm *itm) |
Analyzes a roundabout and sets maneuver information. More... | |
static struct navigation_command * | command_new (struct navigation *this_, struct navigation_itm *itm, struct navigation_maneuver *maneuver) |
Creates a new. More... | |
static void | make_maneuvers (struct navigation *this_, struct route *route) |
Creates turn instructions where needed. More... | |
static int | contains_suffix (char *name, char *suffix) |
static char * | replace_suffix (char *name, char *search, char *replace) |
static char * | navigation_item_destination (struct navigation *nav, struct navigation_command *cmd, struct navigation_itm *next, char *prefix) |
Creates a text description for the destination of a maneuver, which can be used in announcements. More... | |
static char * | navigation_cmd_get_exit_announce (struct navigation_command *this_, char *street_destination_announce) |
Formats the exit ref and name for display and speech output. More... | |
static char * | show_maneuver (struct navigation *nav, struct navigation_itm *itm, struct navigation_command *cmd, enum attr_type type, enum announcement_level level) |
Creates turn by turn guidance sentences for the speech and for the route description. More... | |
static char * | show_next_maneuvers (struct navigation *nav, struct navigation_itm *itm, struct navigation_command *cmd, enum attr_type type) |
Creates announcements for maneuvers, plus maneuvers immediately following the next maneuver. More... | |
static void | navigation_call_callbacks (struct navigation *this_, int force_speech) |
static void | navigation_update_done (struct navigation *this_, int cancel) |
Cleans up and initiates maneuver creation. More... | |
static void | navigation_update_idle (struct navigation *this_) |
Idle callback function to retrieve items from the route map. More... | |
static void | navigation_update (struct navigation *this_, struct route *route, struct attr *attr) |
Event handler for changes to the route. More... | |
void | navigation_destroy (struct navigation *this_) |
int | navigation_register_callback (struct navigation *this_, enum attr_type type, struct callback *cb) |
Registers a new callback function. More... | |
void | navigation_unregister_callback (struct navigation *this_, enum attr_type type, struct callback *cb) |
Unregisters a callback function. More... | |
struct map * | navigation_get_map (struct navigation *this_) |
static int | navigation_map_item_coord_get (void *priv_data, struct coord *c, int count) |
static void | navigation_map_item_coord_rewind (void *priv_data) |
static int | navigation_map_item_attr_get (void *priv_data, enum attr_type attr_type, struct attr *attr) |
static void | navigation_map_item_attr_rewind (void *priv_data) |
static void | navigation_map_destroy (struct map_priv *priv) |
static void | navigation_map_rect_init (struct map_rect_priv *priv) |
static struct map_rect_priv * | navigation_map_rect_new (struct map_priv *priv, struct map_selection *sel) |
static void | navigation_map_rect_destroy (struct map_rect_priv *priv) |
static struct item * | navigation_map_get_item (struct map_rect_priv *priv) |
Gets the next item from the navigation map. More... | |
static struct item * | navigation_map_get_item_byid (struct map_rect_priv *priv, int id_hi, int id_lo) |
Gets the item with the specified ID from the navigation map. More... | |
static struct map_priv * | navigation_map_new (struct map_methods *meth, struct attr **attrs, struct callback_list *cbl) |
void | navigation_set_route (struct navigation *this_, struct route *route) |
void | navigation_init (void) |
Variables | |
static int | roundabout_extra_length =50 |
static int | invalid_angle = 361 |
static int | min_turn_limit = 25 |
static int | turn_2_limit = 45 |
static int | sharp_turn_limit = 110 |
static int | u_turn_limit = 165 |
struct suffix | suffixes [] |
const int | distances [] = {1,2,3,4,5,10,25,50,75,100,150,200,250,300,400,500,750} |
Set of simplified distance values that are easy to be pronounced. Used for the 'vocabulary_distances' configuration. More... | |
static struct item_methods | navigation_map_item_methods |
static struct map_methods | navigation_map_meth |
struct object_func | navigation_func |
Navit, a modular navigation system. Copyright (C) 2005-2015 Navit Team
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Generates navigation messages for a calculated route.
#define LAST_DISTANCE (SIZE_OF_ARRAY_DISTANCES - 1) |
#define mex_exit 2 |
Exiting from a motorway-like road, direction undefined. This should only be used for ramps leading to a non-motorway road. For interchanges, use mex_interchange instead. This value is not intended to be set directly but can be used for comparisons, e.g. merge_or_exit & mex_merge
.
#define mex_exit_right 10 |
#define mex_interchange 4 |
Motorway-like road splits in two. This should be used for all cases in which ramps lead to another motorway-like road.
#define mex_merge 1 |
Merging into a motorway-like road, direction undefined. This value is not intended to be set directly but can be used for comparisons, e.g. merge_or_exit & mex_merge
.
#define mex_merge_left 17 |
Merging into a motorway-like road to the left (coming from the right)
#define mex_merge_right 9 |
Merging into a motorway-like road to the right (coming from the left)
#define mex_none 0 |
Not merging into or exiting from a motorway_like road
#define SIZE_OF_ARRAY_DISTANCES (sizeof (distances)/sizeof (int)) |
enum announcement_level |
enum gender |
enum nav_status_int |
|
static |
Adjusts a bearing delta to point in the same direction as a reference delta.
Calculated delta results are constrained to -180 <= delta <= +180 degrees. Some heuristics, however, require values outside that range, e.g. -190 rather than 170 degrees. Given a reference with approximately correct orientation, this function corrects that delta to match the reference as closely as possible. This is done by adding or subtracting 360 degrees as needed.
delta | The delta to adjust. abs(delta)
|
reference | The reference delta. abs(reference)
|
References dbg, and lvl_debug.
Referenced by navigation_analyze_roundabout().
|
static |
Calculates the delta between two angles.
The return value is to be interpreted as follows:
angle1 | The first angle |
angle2 | The second angle |
Referenced by angle_median(), command_new(), count_possible_turns(), maneuver_required2(), navigation_analyze_roundabout(), navigation_map_item_attr_get(), navigation_way_get_max_delta(), and tracking_update().
|
static |
References angle_delta().
Referenced by navigation_analyze_roundabout().
|
static |
Referenced by maneuver_required2(), and navigation_analyze_roundabout().
|
static |
Calculates distance and time to the destination.
This function calculates the distance and the time to the destination of a navigation. If incr is set, this is only calculated for the first navigation item, which is a lot faster than re-calculation the whole destination, but works only if the rest of the navigation already has been calculated.
this_ | The navigation whose destination / time should be calculated |
incr | Set this to true to only calculate the first item. See description. |
References dbg, navigation_itm::dest_count, navigation_itm::dest_length, navigation_itm::dest_time, navigation::first, navigation::last, navigation_itm::length, lvl_debug, lvl_info, next, navigation_itm::next, navigation_itm::prev, and navigation_itm::time.
Referenced by navigation_update_done().
|
static |
Creates a new.
for a maneuver.
This function creates a new command and inserts it into the command list of
. It also parses
and sets its
appropriately so that other functions can rely on that.
this_ | The navigation object |
itm | The navigation item following the maneuver |
maneuver | The struct navigation_maneuver
struct navigation_maneuver
type_nav_destination
|
References AF_ROUNDABOUT, navigation_way::angle2, angle_delta(), navigation_itm::angle_end, navigation::cmd_first, navigation::cmd_last, dbg, navigation_maneuver::delta, navigation_command::delta, navigation_way::flags, navigation_command::itm, navigation_maneuver::left, lvl_debug, navigation_command::maneuver, min_turn_limit, navigation_analyze_roundabout(), navigation_command::next, navigation_way::next, navigation_itm::next, navigation_command::prev, navigation_itm::prev, navigation_maneuver::right, sharp_turn_limit, turn_2_limit, navigation_maneuver::type, u_turn_limit, and navigation_itm::way.
Referenced by make_maneuvers().
|
static |
References name, and navit_utf8_strcasecmp().
Referenced by navigation_item_destination().
|
static |
Counts how many times a driver could turn right/left.
This function counts how many times the driver theoretically could turn right/left between two navigation items, not counting the final turn itself.
from | The navigation item which should form the start |
to | The navigation item which should form the end |
direction | Set to < 0 to count turns to the left >= 0 for turns to the right |
References navigation_way::angle2, angle_delta(), navigation_itm::angle_end, is_way_allowed(), navigation_way::next, navigation_itm::next, navigation_itm::prev, and navigation_itm::way.
Referenced by show_maneuver().
|
static |
Frees a list as constructed with split_string_to_list()
list | the list to be freed |
References street_destination::destination, and street_destination::next.
Referenced by navigation_destroy_itms_cmds(), and split_string_to_list().
|
static |
Returns the first destination with a rank higher than zero.
If all items in the list have a zero rank, the first one will be returned.
References street_destination::next, and street_destination::rank.
Referenced by select_announced_destinations().
|
static |
References _.
Referenced by show_maneuver().
|
static |
Generates the distance string. Considers the configuration of 'imperial' units and 'vocabulary_distances'. 'imperial' if set distinguishes the distance statement between miles and feet. Maximum distance in feet is 500. 'vocabulary_distances' if set constrains the distance values to a set of simple pronounceable numbers.
nav | The navigation object. |
dist_meters | Distance in meters. |
type | The type of announcement precision. |
is_length | 1 for length statement, 0 for distance statement. |
References _, FEET_PER_METER, METERS_TO_MILES, navigation::navit, navit_get_attr(), navit_nls_ngettext(), attr::num, round_distance(), round_distance_reduced(), navigation::speech, speech_get_attr(), type, and attr::u.
Referenced by show_maneuver().
|
static |
References _.
Referenced by show_maneuver().
|
static |
Checks whether a way has motorway-like characteristics.
Motorway-like means one of the following:
item type is highway_land or highway_city (OSM: highway=motorway) item type is street_n_lanes (OSM: highway=trunk) and way is one-way
is true and item type is either ramp or street_service
way | The way to examine |
extended | Whether to consider ramps and service roads to be motorway-like |
References AF_ONEWAYMASK, navigation_way::flags, navigation_way::item, item::type, and navigation_itm::way.
Referenced by maneuver_required2(), and navigation_item_destination().
|
static |
Checks whether a way is a ramp.
way | The way to be examined |
References navigation_way::item, item::type, and navigation_itm::way.
Referenced by navigation_analyze_roundabout().
|
static |
Checks if two navigation items are on the same street.
This function checks if two navigation items are on the same street. It returns true if either their name or their "systematic name" (e.g. "A6" or "B256") are the same.
old_name | The name of the first item to be checked |
old_name_systematic | The systematic name of the first item to be checked |
new_name | The name of the second item to be checked |
new_name_systematic | The systematic name of the second item to be checked |
References dbg, and lvl_debug.
Referenced by is_same_way(), and maneuver_required2().
|
static |
Checks if two ways are identical.
This function checks if two
s are likely to represent the same way on the ground. It does this by comparing the
,
,
and
members of both ways and returning
if all of them match.
Names are compared by calling
.
ID attributes (such as OSM IDs) are not used for comparison, which allows the function to handle even overlapping maps for the same area created from different versions of OSM data, in which IDs may have changed as a result of ways being merged or split. As long as the above attributes match, the ways will still be considered equal.
Note that way geometry (other than
) is not compared. If necessary, the caller needs to make geometry-related comparisons separately.
References navigation_way::angle2, is_same_street2(), navigation_way::item, navigation_way::name, navigation_way::name_systematic, and item::type.
Referenced by navigation_itm_ways_update().
|
static |
Checks whether a way is allowed.
This function checks whether a given vehicle is permitted to enter a given way by comparing the access and one-way restrictions of the way against the settings in
. Turn restrictions are not taken into account.
nav | The navigation object |
way | The way to examine |
mode | If nonzero, oneway restrictions will be taken into account. If zero, only the vehicle type will be taken into account. |
References navigation_way::dir, navigation_way::flags, vehicleprofile::flags, vehicleprofile::flags_forward_mask, vehicleprofile::flags_reverse_mask, navigation::vehicleprofile, and navigation_itm::way.
Referenced by count_possible_turns(), maneuver_required2(), navigation_analyze_roundabout(), and show_maneuver().
|
static |
Creates turn instructions where needed.
this_ | The navigation object for which to create turn instructions |
route | Not used |
References navigation::cmd_first, navigation::cmd_last, command_new(), navigation::first, maneuver_required2(), navigation_itm::next, and navigation_maneuver::type.
Referenced by navigation_update_done().
|
static |
References type.
Referenced by maneuver_required2().
|
static |
Checks if navit has to create a maneuver to drive from old to new.
This function checks if it has to create a "maneuver" - i.e. guide the user - to drive from "old" to "new".
old | The old navigation item, where we're coming from |
new | The new navigation item, where we're going to |
maneuver | Pointer to a buffer that will receive a pointer to a struct navigation_maneuver
|
References AF_ONEWAYMASK, AF_ROUNDABOUT, navigation_way::angle2, angle_delta(), navigation_itm::angle_end, angle_opposite(), dbg, navigation_maneuver::delta, navigation_way::exit_label, navigation_way::exit_ref, navigation_way::flags, navigation_maneuver::is_complex_t_junction, is_motorway_like(), navigation_maneuver::is_same_street, is_same_street2(), navigation_maneuver::is_unambiguous, is_way_allowed(), navigation_way::item, item_to_name(), navigation_maneuver::left, navigation_itm::length, lvl_debug, maneuver_category(), navigation_maneuver::max_cat, navigation_maneuver::merge_or_exit, mex_exit_left, mex_exit_right, mex_interchange, mex_merge_left, mex_merge_right, mex_none, min_turn_limit, navigation_way::name, navigation_way::name_systematic, navigation_maneuver::new_cat, navigation_way::next, navigation_itm::next, navigation_maneuver::num_new_motorways, navigation_maneuver::num_options, navigation_maneuver::num_other_ways, navigation_maneuver::num_similar_ways, navigation_maneuver::old_cat, navigation_itm::prev, navigation_maneuver::right, item::type, navigation_maneuver::type, and navigation_itm::way.
Referenced by make_maneuvers(), and navigation_map_item_attr_get().
char* nav_status_to_text | ( | int | status | ) |
Converts navigation status to human-readable text.
The | status. This must be one of the values for enum nav_status
|
References status_calculating, status_invalid, status_no_destination, status_no_route, status_position_wait, status_recalculating, and status_routing.
Referenced by attr_to_text_ext(), and osd_navigation_status_draw_do().
|
static |
Analyzes a roundabout and sets maneuver information.
Exit from a roundabout requires a somewhat complex analysis of the ways involved in order to:
Bearing change must be as close as possible to how drivers would perceive it. Builds prior to r2017 used the difference between the last way before and the first way after the roundabout, which tends to overestimate the angle when the ways leading towards and/or away from the roundabout split into separate carriageways in a Y-shape. This is referred to as
here.
In r2017 a different approach was introduced, which essentially distorts the roads so they enter and leave the roundabout at a 90 degree angle. (To make calculations simpler, tangents of the roundabout at the entry and exit points are used, with one of them reversed in direction, instead of the approach roads.) However, this approach tends to underestimate the angle when the distance between approach roads is large. This is referred to as
here.
Combining
and
, calculating error estimates for each and using a weighted average between the two delta estimates gives better results in many cases but fails for certain road layouts - namely, when corresponding approach roads are connected by more than one roundabout segment, or when additional ways connect to an approach road. These cases break error calculation and thus weight distribution.
Project HighFive introduces a new approach, which compares bearings of ways leading towards and away from the roundabout not immediately at entry and exit but at a certain distance from the roundabout, which is roughly proportional to the circumference of the roundabout. Circumference is estimated using the arithmetic mean value of
and
. This approach has produced the best results in tests. In code it is referred to as
.
this_ | The navigation object |
cmd | A struct navigation_cmd
delta
maneuver
|
itm | The navigation item for the maneuver to exit the roundabout |
References adjust_delta(), AF_ONEWAYMASK, AF_ROUNDABOUT, navigation_way::angle2, angle_delta(), navigation_itm::angle_end, angle_median(), angle_opposite(), dbg, navigation_command::delta, navigation_way::flags, invalid_angle, is_ramp(), is_way_allowed(), item_to_name(), length, navigation_command::length, navigation_itm::length, lvl_debug, lvl_error, navigation_command::maneuver, navigation::map, map_projection(), navigation_way_get_max_delta(), navigation_way::next, navigation_itm::next, navigation_itm::prev, navigation_command::roundabout_delta, roundabout_extra_length, navigation_maneuver::type, and navigation_itm::way.
Referenced by command_new().
|
static |
References navigation::callback, callback_list_call(), navigation::callback_speech, navigation::cmd_first, navigation::curr_delay, dbg, navigation::delay, navigation_itm::dest_length, navigation::distance_turn, navigation::first, navigation_way::item, item_is_equal, navigation::item_last, navigation_command::itm, navigation_command::length, navigation::level_last, lvl_debug, navigation_get_announce_level_cmd(), p, navigation_itm::speed, navigation::turn_around, navigation::turn_around_limit, item::type, and navigation_itm::way.
Referenced by navigation_update_done().
|
static |
Formats the exit ref and name for display and speech output.
This function takes the navigation command for a motorway maneuver (exit or interchange) and returns a string describing the exit.
If the exit has a name and ref and the name is different from
, a string of the form "ref name" is returned. If only one of the two is different from NULL, it is returned unchanged.
If the name matches
, it is always treated as if it were NULL. This prevents redundancy in announcements.
No checks are done that the maneuver actually has the appropriate merge_or_exit flags set. The caller is responsible for performing such checks prior to calling this function.
this_ | The navigation command |
street_destination_announce | The name of the street following the maneuver. This argument may be NULL, in which case the exit name will not be suppressed. |
References navigation_way::exit_label, navigation_way::exit_ref, navigation_command::itm, linguistics_casefold(), and navigation_itm::way.
Referenced by navigation_map_item_attr_get(), and show_maneuver().
void navigation_destroy | ( | struct navigation * | this_ | ) |
|
static |
Destroys navigation items associated with a navigation object.
This function destroys all or some of the
instances associated with
, starting with the first one. Data structures associated with the items will also be freed.
this_ | The navigation object whose command instances are to be destroyed |
end | The first navigation item to keep. If it is NULL or not found in the list, all items will be destroyed. |
References navigation::cmd_first, dbg, navigation_way::destination, navigation_way::exit_label, navigation_way::exit_ref, navigation::first, free_list(), navigation::hash, navigation_way::item, item_hash_remove(), navigation_command::itm, navigation::last, lvl_debug, lvl_error, lvl_info, navigation_command::maneuver, map_convert_free(), navigation_way::name, navigation_way::name_systematic, navigation_itm_ways_clear(), navigation_command::next, navigation_itm::next, navigation_command::prev, navigation_itm::prev, and navigation_itm::way.
Referenced by navigation_flush(), navigation_update_done(), and navigation_update_idle().
|
static |
References navigation_destroy_itms_cmds().
Referenced by navigation_destroy(), and navigation_update().
|
static |
References navigation::announce, dbg, lvl_debug, route_item_first, route_item_last, and type.
Referenced by navigation_map_item_attr_get(), and show_next_maneuvers().
|
static |
Referenced by navigation_call_callbacks(), and show_next_maneuvers().
int navigation_get_attr | ( | struct navigation * | this_, |
enum attr_type | type, | ||
struct attr * | attr, | ||
struct attr_iter * | iter | ||
) |
References attr_to_name(), dbg, item, item_attr_get(), attr::item_type, lvl_debug, attr::map, navigation::map, map_rect_destroy(), map_rect_get_item(), map_rect_new(), navigation::nav_status, navit_object_get_attr(), attr::num, navigation::turn_around_count, attr::type, item::type, type, and attr::u.
Referenced by navigation_register_callback(), navigation_unregister_callback(), osd_navigation_status_draw(), osd_navigation_status_init(), and request_navigation_get_attr().
struct map* navigation_get_map | ( | struct navigation * | this_ | ) |
References attr::attrs, data, description(), navigation::map, map_new(), attr::navigation, and type.
Referenced by gui_internal_populate_route_table(), navigation_get_map_py(), navit_init(), navit_speak(), navit_window_roadbook_update(), osd_nav_next_turn_draw(), osd_text_draw(), request_navit_route_export_geojson(), request_navit_route_export_gpx(), and statusbar_route_update().
void navigation_init | ( | void | ) |
Referenced by main_real().
|
static |
Creates a text description for the destination of a maneuver, which can be used in announcements.
nav | The navigation object |
cmd | The for which to generate an announcement |
next | The current navigation item. In speech mode this should be set to the navigation item starting at the vehicle's current position; in route description mode this should be set to the navigation_item
|
prefix | A space will be added as a prefix to the string returned, or a null string for no prefix |
References _, contains_suffix(), feminine, suffix::gender, is_motorway_like(), navigation_way::item, navigation_command::itm, navigation_command::maneuver, masculine, navigation_maneuver::merge_or_exit, mex_interchange, mex_merge, name, navigation_way::name, navigation_way::name_systematic, neuter, navigation_command::next, navigation_itm::next, attr::num, navigation_itm::prev, replace_suffix(), navigation::speech, speech_get_attr(), suffixes, item::type, navigation_maneuver::type, attr::u, unknown, and navigation_itm::way.
Referenced by show_maneuver().
|
static |
Creates and adds a new navigation_itm to a linked list of such.
routeitem has an attr. streetitem, but that is only and id and a map, allowing to fetch the actual streetitem, that will live under the same name.
Known issue: If a way splits in 2, exit_to info ends up on both continuations of the ramp, sometimes leading to wrong guidance. The case where a ramp itself splits in 2 is already covered by ignoring exit_to info in such cases.
this_ | the navigation object |
routeitem | the routeitem from which to create a navigation item |
References AF_ONEWAY, navigation_way::angle2, navigation_itm::angle_end, c, map_selection::c_rect, dbg, navigation_way::destination, navigation_way::dir, navigation_itm::end, navigation_way::exit_label, navigation_way::exit_ref, navigation::first, navigation_way::flags, navigation::hash, item::id_hi, item::id_lo, attr::item, navigation_way::item, item_attr_get(), item_coord_get(), item_hash_insert(), item_range_all, navigation::last, coord_rect::lu, lvl_debug, lvl_warning, item::map, map_convert_string(), map_rect_destroy(), map_rect_get_item(), map_rect_get_item_byid(), map_rect_new(), navigation_way::name, navigation_way::name_systematic, navigation_itm_update(), navigation_itm_ways_update(), map_selection::next, navigation_way::next, navigation_itm::next, attr::num, map_selection::order, navigation_itm::prev, map_selection::range, coord_rect::rl, road_angle(), attr::route, route_get_graph_map(), split_string_to_list(), attr::str, navigation_itm::streetname_told, attr::type, item::type, attr::u, map_selection::u, navigation_itm::way, coord::x, pcoord::x, coord::y, and pcoord::y.
Referenced by navigation_update_done(), and navigation_update_idle().
|
static |
References dbg, item_attr_get(), length, navigation_itm::length, lvl_debug, lvl_error, attr::num, navigation_itm::speed, navigation_itm::time, and attr::u.
Referenced by navigation_itm_new(), and navigation_update_idle().
|
static |
Clears the ways one can drive from itm.
itm | The item that should have its ways cleared |
References c, map_convert_free(), navigation_way::next, and navigation_itm::way.
Referenced by navigation_destroy_itms_cmds(), and navigation_itm_ways_update().
|
static |
Updates the ways one can drive from itm.
This updates the list of possible ways to drive to from itm. The item "itm" is on and the next navigation item are excluded.
itm | The item that should be updated |
graph_map | The route graph's map that these items are on |
References map_selection::c_rect, dbg, navigation_way::dir, is_same_way(), attr::item, navigation_way::item, item_attr_get(), item_is_equal, item_to_name(), coord_rect::lu, lvl_debug, lvl_warning, map_rect_destroy(), map_rect_get_item(), map_rect_new(), navigation_way::name, navigation_way::name_systematic, navigation_itm_ways_clear(), navigation_way_init(), map_selection::next, navigation_way::next, attr::num, navigation_itm::prev, coord_rect::rl, item::type, attr::u, map_selection::u, and navigation_itm::way.
Referenced by navigation_itm_new().
|
static |
|
static |
Gets the next item from the navigation map.
This function returns an item from a map rectangle on the navigation map and advances the item pointer, so that at the next call the next item will be returned.
The
member of the result, which indicates the type of maneuver, is generally copied over from
, though some exceptions apply: The first item in the map will have a type of
and the last one will have a type of
. If
indicates a merge or exit, the result will be of the corresponding merge or exit type.
Earlier versions of Navit had the entire logic for setting the maneuver type in this function, but this has been moved to
so that other functions can use the same results.
priv | The struct map_rect_priv
|
References map_rect_priv::cmd, map_rect_priv::cmd_itm, map_rect_priv::cmd_itm_next, map_rect_priv::cmd_next, dbg, navigation_itm::dest_count, item::id_lo, map_rect_priv::item, navigation_command::itm, map_rect_priv::itm, map_rect_priv::itm_next, lvl_debug, navigation_command::maneuver, navigation_maneuver::merge_or_exit, mex_exit, mex_exit_left, mex_exit_right, mex_merge, mex_merge_left, mex_merge_right, navigation_map_item_attr_rewind(), navigation_map_item_coord_rewind(), navigation_command::next, navigation_itm::next, navigation_itm::prev, map_rect_priv::show_all, item::type, and navigation_maneuver::type.
Referenced by navigation_map_get_item_byid().
|
static |
Gets the item with the specified ID from the navigation map.
This function returns the item with the ID specified in the arguments from a map rectangle on the navigation map.
Internally the function calls
, thus the same logic applies for the data of the item that is returned. See
for details.
The item pointer of the map rectangle will be moved so that a subsequent call to
will return the next item following the one returned by this function.
priv | The struct map_rect_priv
|
id_hi | The high part of the ID |
id_lo | The low part of the ID |
References item::id_hi, item::id_lo, navigation_map_get_item(), and navigation_map_rect_init().
|
static |
References _, navigation_way::angle2, angle_delta(), navigation_itm::angle_end, map_rect_priv::attr_next, map_rect_priv::cmd, map_rect_priv::cmd_itm, map_rect_priv::debug_idx, navigation_maneuver::delta, navigation_command::delta, navigation_itm::dest_length, navigation_itm::dest_time, navigation_way::destination, street_destination::destination, navigation_way::dir, navigation_way::flags, item::id_hi, item::id_lo, navigation_maneuver::is_complex_t_junction, navigation_maneuver::is_same_street, navigation_maneuver::is_unambiguous, navigation_way::item, item_to_name(), navigation_command::itm, map_rect_priv::itm, navigation_maneuver::left, navigation_command::length, navigation_command::maneuver, maneuver_required2(), navigation_maneuver::max_cat, navigation_maneuver::merge_or_exit, mex_interchange, navigation_way::name, navigation_way::name_systematic, map_rect_priv::nav, navigation_cmd_get_exit_announce(), navigation_get_announce_level(), navigation_maneuver::new_cat, navigation_way::next, attr::num, navigation_maneuver::num_new_motorways, navigation_maneuver::num_options, navigation_maneuver::num_other_ways, navigation_maneuver::num_similar_ways, navigation_maneuver::old_cat, navigation_itm::prev, navigation_maneuver::right, round_distance(), select_announced_destinations(), show_next_maneuvers(), attr::str, map_rect_priv::str, attr::type, item::type, navigation_maneuver::type, attr::u, navigation_itm::way, and map_rect_priv::ways.
|
static |
References map_rect_priv::attr_next, and map_rect_priv::debug_idx.
Referenced by navigation_map_get_item().
|
static |
References c, and map_rect_priv::ccount.
|
static |
References map_rect_priv::ccount.
Referenced by navigation_map_get_item().
|
static |
References attr_search(), attr::attrs, attr::navigation, map_priv::navigation, navigation_map_meth, and attr::u.
|
static |
References map_rect_priv::str.
|
static |
References navigation::cmd_first, map_rect_priv::cmd_itm_next, map_rect_priv::cmd_next, navigation::first, map_rect_priv::itm_next, and map_rect_priv::nav.
Referenced by navigation_map_get_item_byid(), and navigation_map_rect_new().
|
static |
struct navigation* navigation_new | ( | struct attr * | parent, |
struct attr ** | attrs | ||
) |
References navigation::announce, attr_search(), navigation::callback, callback_list_new(), navigation::callback_speech, navigation::delay, navigation::distance_turn, navigation::flags, navigation::hash, item_hash_new(), navigation::level_last, navigation_func, navigation::navit, navit_object_new(), attr::num, route_item_first, route_item_last, navigation::route_mr, navigation::tell_street_name, navigation::turn_around_limit, and attr::u.
int navigation_register_callback | ( | struct navigation * | this_, |
enum attr_type | type, | ||
struct callback * | cb | ||
) |
Registers a new callback function.
Callback functions are called whenever the attribute for which they are registered changes. It is possible to register callbacks for
, which will fire on any change.
The
object has three callback lists. They differ by the arguments which are passed to the callback function and are selected based on the attribute type:
this_ | The navigation object. |
type | The attribute type |
cb | The callback function |
References navigation::callback, attr::callback_list, callback_list_add(), navigation::callback_speech, navigation_get_attr(), type, and attr::u.
Referenced by navit_init(), navit_window_roadbook_new(), osd_navigation_status_init(), and traffic_traff_android_init().
int navigation_set_announce | ( | struct navigation * | this_, |
enum item_type | type, | ||
int * | level | ||
) |
int navigation_set_attr | ( | struct navigation * | this_, |
struct attr * | attr | ||
) |
References navigation::nav_status, navit_object_set_attr(), attr::num, attr::speech, navigation::speech, attr::type, and attr::u.
Referenced by navigation_update(), navigation_update_done(), and navit_init().
void navigation_set_route | ( | struct navigation * | this_, |
struct route * | route | ||
) |
References callback_cast, callback_new_attr_1, navigation_update(), attr::route, navigation::route, route_add_attr(), navigation::route_cb, route_get_attr(), route_remove_attr(), and callback::type.
Referenced by navit_init().
|
static |
References ATTR_INT, navit_object_callbacks(), and navigation::turn_around_count.
Referenced by show_maneuver().
void navigation_unregister_callback | ( | struct navigation * | this_, |
enum attr_type | type, | ||
struct callback * | cb | ||
) |
Unregisters a callback function.
This function removes a previously registered callback function from the callback list to which it was added. See the documentation on navigation_register_callback(struct navigation *, enum attr_type, struct callback *) for details on callback lists.
this_ | The navigation object. |
type | The attribute type |
cb | The callback function |
References navigation::callback, attr::callback_list, callback_list_remove(), navigation::callback_speech, navigation_get_attr(), type, and attr::u.
Referenced by navit_window_roadbook_destroy().
|
static |
Event handler for changes to the route.
This function is added to the callback list of the current route. It is called whenever the status of the route changes and will either discard the current list of maneuvers or build a new list.
this_ | The navigation object |
route | The route |
attr | The route status attribute |
References callback_cast, callback_new_1, dbg, event_add_idle(), navigation::idle_cb, navigation::idle_ev, lvl_debug, map_rect_new(), navigation::nav_status, navigation_flush(), navigation_set_attr(), navigation_update_done(), navigation_update_idle(), attr::num, navigation::route, route_get_attr(), route_get_flags(), route_get_map(), navigation::route_mr, route_path_flag_async, route_status_building_graph, route_status_building_path, route_status_destination_set, route_status_no_destination, route_status_not_found, route_status_path_done_incremental, route_status_path_done_new, status_busy, status_calculating, navigation::status_int, status_no_destination, status_no_route, status_position_wait, status_recalculating, attr::type, attr::u, and navigation::vehicleprofile.
Referenced by navigation_set_route().
|
static |
Cleans up and initiates maneuver creation.
This function is called by navigation_update_idle(struct navigation *) after it has retrieved all objects from the route map.
It will reset the navigation object's idle event/callback, deallocate some temporary objects and reset the
flag. Arguments correspond to those of navigation_update_idle(struct navigation *).
this_ | Points to the navigation object. After the function returns, its member will no longer be valid. |
cancel | If true, only cleanup (deallocation of objects) will be done and no maneuvers will be generated. If false, maneuvers will be generated. |
References calculate_dest_distance(), callback_destroy(), event_remove_idle(), navigation::idle_cb, navigation::idle_ev, make_maneuvers(), map_rect_destroy(), navigation_call_callbacks(), navigation_destroy_itms_cmds(), navigation_itm_new(), navigation_set_attr(), profile, navigation::route, navigation::route_mr, status_has_ritem, status_has_sitem, navigation::status_int, status_none, status_routing, and callback::type.
Referenced by navigation_update(), and navigation_update_idle().
|
static |
Idle callback function to retrieve items from the route map.
this_ | Points to the navigation object. The caller is responsible for initializing its route_mr
route_mr
|
References dbg, navigation_way::dir, navigation::hash, item::id_hi, item::id_lo, attr::item, item_attr_get(), item_hash_lookup(), lvl_debug, lvl_info, map_rect_get_item(), navigation_destroy_itms_cmds(), navigation_itm_new(), navigation_itm_update(), navigation_update_done(), attr::num, navigation::route, route_has_graph(), navigation::route_mr, status_has_ritem, status_has_sitem, navigation::status_int, navigation::turn_around, navigation::turn_around_limit, attr::u, and navigation_itm::way.
Referenced by navigation_update().
|
static |
Returns the maximum delta between a reference bearing and any segment of a given way, up to a given distance from its start.
The return value is the maximum delta (in terms of absolute value), but the sign is preserved. If the maximum delta is encountered more than once but with different signs,
controls which of the two values is returned:
will be returned if one of the following errors occurs:
If
exceeds the length of the way, the entire way is examined.
pro | The projection used by the map |
w | The way to examine |
angle | The reference bearing |
dist | The distance from the start of the way at which to determine bearing |
dir | Controls how to handle when the same delta is encountered multiple times but with different signs, permissible values are either -1 or +1 |
References angle_delta(), c, dbg, navigation_way::dir, item::id_hi, item::id_lo, invalid_angle, navigation_way::item, item_coord_get(), item_coord_rewind(), lvl_warning, item::map, map_rect_destroy(), map_rect_get_item_byid(), map_rect_new(), road_angle(), transform_distance(), and item::type.
Referenced by navigation_analyze_roundabout().
|
static |
Initializes a navigation_way.
This function analyzes the underlying map item and sets the entry bearing, names and flags for the way.
Note that entry bearing is expressed as bearing towards the opposite end of the item.
Note that this function is not suitable for ways on the route (created in
) as it may return incorrect coordinates for these ways.
w | The way to initialize. The , id_hi
id_lo
dir
|
References navigation_way::angle2, c, dbg, navigation_way::dir, navigation_way::flags, item::id_hi, item::id_lo, invalid_angle, navigation_way::item, item_attr_get(), item_coord_get(), lvl_warning, item::map, map_convert_string(), map_rect_destroy(), map_rect_get_item_byid(), map_rect_new(), navigation_way::name, navigation_way::name_systematic, attr::num, road_angle(), attr::str, item::type, and attr::u.
Referenced by navigation_itm_ways_update().
|
static |
References name.
Referenced by navigation_item_destination().
Gets the bearing from one point to another.
c1 | The first coordinate |
c2 | The second coordinate |
dir | The direction: if it is -1, the bearing from c2 to c1 is returned, else the bearing from c1 to c2 |
References c1, c2, dbg, lvl_debug, and transform_get_angle_delta().
Referenced by navigation_itm_new(), navigation_way_get_max_delta(), and navigation_way_init().
|
static |
Referenced by get_distance_str(), navigation_map_item_attr_get(), and show_maneuver().
|
static |
Restricts the distance value to a simple set of pronounceable numbers.
dist | The distance to be processed |
References dbg, distances, LAST_DISTANCE, lvl_debug, and SIZE_OF_ARRAY_DISTANCES.
Referenced by get_distance_str().
|
static |
Selects the destination-names for the next announcement from the destination-names that are registered in the following command items.
The aim of this function is to find the destination-name entry that has the most hits in the following command items so that the destination name has a relevance over several announcements. If there is no 'winner' the entry is selected that is at top of the destination.
References dbg, navigation_way::destination, street_destination::destination, get_bestranked(), navigation_command::itm, lvl_debug, navigation_command::next, street_destination::next, set_highrank(), and navigation_itm::way.
Referenced by navigation_map_item_attr_get(), and show_maneuver().
|
static |
Assigns a high rank to a matching destination in the next command having destination info, and reset existing ranks to zero.
street | destination to be given a high rank |
command |
References command(), navigation_way::destination, street_destination::destination, navigation_command::itm, navigation_command::next, street_destination::next, street_destination::rank, and navigation_itm::way.
Referenced by select_announced_destinations().
|
static |
Creates turn by turn guidance sentences for the speech and for the route description.
nav | The navigation object |
itm | The current navigation item, which is used to determine the distance to the next maneuver. In speech mode this should be set to the navigation item starting at the vehicle's current position; in route description mode this should be set to the navigation_item
|
cmd | The for which to generate an announcement |
type | The type of announcements to generate. Set to attr_navigation_long_exact
attr_navigation_speech
|
connect | Whether this is the second of two connected announcements, as in "turn left in..., then turn right" |
References _, AF_ROUNDABOUT, count_possible_turns(), dbg, navigation_itm::dest_length, navigation_way::destination, navigation::first, navigation_way::flags, get_count_str(), get_distance_str(), get_exit_count_str(), is_way_allowed(), navigation_way::item, navigation_command::itm, level_connect, level_follow, level_meters, level_now, level_soon, lvl_debug, lvl_error, navigation_command::maneuver, navigation_maneuver::merge_or_exit, mex_exit_left, mex_exit_right, mex_interchange, mex_merge_left, mex_merge_right, mex_none, navigation_cmd_get_exit_announce(), navigation_item_destination(), navigation_set_turnaround(), navigation_way::next, navigation_itm::next, navigation_command::prev, navigation_itm::prev, round_distance(), select_announced_destinations(), navigation_itm::streetname_told, navigation::turn_around, navigation::turn_around_count, navigation::turn_around_limit, item::type, type, navigation_maneuver::type, and navigation_itm::way.
Referenced by show_next_maneuvers().
|
static |
Creates announcements for maneuvers, plus maneuvers immediately following the next maneuver.
This function creates an announcement for the current maneuver and for maneuvers immediately following that maneuver, if these are very close and we're in speech navigation. The actual announcements are created by calling
.
nav | The navigation object |
itm | The current navigation item, which is used to determine the distance to the next maneuver. In speech mode this should be set to the navigation item starting at the vehicle's current position; in route description mode this should be set to the navigation_item
|
cmd | The for which to generate an announcement |
type | The type of announcements to generate. If set to attr_navigation_speech
|
References navigation::announce, navigation_itm::dest_length, navigation_way::item, navigation_command::itm, navigation_command::length, level_connect, level_meters, level_soon, navigation_get_announce_level(), navigation_get_announce_level_cmd(), next, navigation_command::next, route_item_first, show_maneuver(), navigation_itm::told, item::type, type, and navigation_itm::way.
Referenced by navigation_map_item_attr_get().
|
static |
Splits a string into a list, and sets their initial rank to 0.
The separator to split on can be any character. Preceding whitespace characters will be removed.
way | a navigation_way holding the list to be filled up |
raw_string | a string to split |
sep | a char to be used as separator to split the raw_string |
References dbg, navigation_way::destination, street_destination::destination, free_list(), lvl_debug, street_destination::next, and street_destination::rank.
Referenced by navigation_itm_new().
const int distances[] = {1,2,3,4,5,10,25,50,75,100,150,200,250,300,400,500,750} |
Set of simplified distance values that are easy to be pronounced. Used for the 'vocabulary_distances' configuration.
This method of calculating the number of elements in an array (#define SIZE_OF_ARRAY_DISTANCES, below) will work for most modern processors. It may cause problems on a few obscure processors, none of which are likely candidates for navit anyway.
It works like so: Modern processors simply stuff the elements of an int array into memory one after the other, with no gaps. Some older processors might not do so, due to memory alignment issues. This method does not take such gaps into account. For more discussion, see https://github.com/navit-gps/navit/pull/373
So if you are on an oddball processor and start getting really odd values for distances, this might be the reason. Good luck!
Referenced by round_distance_reduced(), route_get_distances(), route_path_get_distances(), and search_house_number_coordinate().
|
static |
Referenced by navigation_analyze_roundabout(), navigation_way_get_max_delta(), and navigation_way_init().
|
static |
Minimum absolute delta for a turn. Maneuvers whose absolute delta is less than this will be considered straight
Referenced by command_new(), and maneuver_required2().
struct object_func navigation_func |
Referenced by navigation_new(), and object_func_lookup().
|
static |
Referenced by navigation_map_rect_new().
|
static |
Referenced by navigation_map_new().
|
static |
Referenced by navigation_analyze_roundabout().
|
static |
Minimum absolute delta for a sharp turn. Maneuvers whose absolute delta is equal to or greater than this will be announced as "turn sharply left/right" when strength is required.
Referenced by command_new().
struct suffix suffixes[] |
Referenced by main(), and navigation_item_destination().
|
static |
Minimum absolute delta for a turn of "normal" strength (which is always just announced as "turn left/right" even when strength is required). Maneuvers whose absolute delta is less than this will be announced as "turn easily left/right" when strength is required.
Referenced by command_new().
|
static |
Minimum absolute delta for a U turn. Maneuvers whose absolute delta is less than this (but at least min_turn_limit) will always be announced as turns. Note that, depending on other conditions, even maneuvers whose delta exceeds the threshold may still be announced as (sharp) turns.
Referenced by command_new().