navit  0.5.3-trunk
navigation.c File Reference
#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_destinationget_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 navigationnavigation_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_itmnavigation_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_commandcommand_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 mapnavigation_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_privnavigation_map_rect_new (struct map_priv *priv, struct map_selection *sel)
 
static void navigation_map_rect_destroy (struct map_rect_priv *priv)
 
static struct itemnavigation_map_get_item (struct map_rect_priv *priv)
 Gets the next item from the navigation map. More...
 
static struct itemnavigation_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_privnavigation_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
 

Detailed Description

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.

Macro Definition Documentation

◆ LAST_DISTANCE

#define LAST_DISTANCE   (SIZE_OF_ARRAY_DISTANCES - 1)

◆ mex_exit

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

◆ mex_exit_left

#define mex_exit_left   18

Exiting from a motorway-like road to the left.

See also
mex_exit for usage

◆ mex_exit_right

#define mex_exit_right   10

Exiting from a motorway-like road to the right.

See also
mex_exit for usage

◆ mex_interchange

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

◆ mex_merge

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

◆ mex_merge_left

#define mex_merge_left   17

Merging into a motorway-like road to the left (coming from the right)

◆ mex_merge_right

#define mex_merge_right   9

Merging into a motorway-like road to the right (coming from the left)

◆ mex_none

#define mex_none   0

Not merging into or exiting from a motorway_like road

◆ SIZE_OF_ARRAY_DISTANCES

#define SIZE_OF_ARRAY_DISTANCES   (sizeof (distances)/sizeof (int))

Enumeration Type Documentation

◆ announcement_level

Enum that defines the different states in announcing a turn. These states are dependent on the current distance to the turn; the distances are configured in navit.xml for every type of highway.

Enumerator
level_connect 
level_error 
level_now 
level_meters 
level_soon 
level_follow 

◆ gender

enum gender
Enumerator
unknown 
masculine 
feminine 
neuter 

◆ nav_status_int

Enumerator
status_none 
status_busy 
status_has_ritem 
status_has_sitem 

Function Documentation

◆ adjust_delta()

static int adjust_delta ( int  delta,
int  reference 
)
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.

Parameters
deltaThe delta to adjust.
abs(delta)
must be no greater than 180.
referenceThe reference delta.
abs(reference)
must be no greater then 180.
Returns
The adjusted delta, which is numerically within +/-180 degrees of the reference. If
delta
or
reference
are outside of their specified range, the result is undefined.

References dbg, and lvl_debug.

Referenced by navigation_analyze_roundabout().

◆ angle_delta()

static int angle_delta ( int  angle1,
int  angle2 
)
static

Calculates the delta between two angles.

The return value is to be interpreted as follows:

  • -179..-1:
    angle2
    is left of
    angle1
  • 0: Both angles are identical
  • 1..179:
    angle2
    is right of
    angle1
  • 180:
    angle1
    is opposite of
    angle2
Parameters
angle1The first angle
angle2The second angle
Returns
The difference between the angles, see description

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

◆ angle_median()

static int angle_median ( int  angle1,
int  angle2 
)
static

References angle_delta().

Referenced by navigation_analyze_roundabout().

◆ angle_opposite()

static int angle_opposite ( int  angle)
static

◆ calculate_dest_distance()

static void calculate_dest_distance ( struct navigation this_,
int  incr 
)
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.

Parameters
this_The navigation whose destination / time should be calculated
incrSet 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().

◆ command_new()

static struct navigation_command* command_new ( struct navigation this_,
struct navigation_itm itm,
struct navigation_maneuver maneuver 
)
static

Creates a new.

Holds information about a command for a navigation maneuver.
Definition: navigation.c:302

for a maneuver.

This function creates a new command and inserts it into the command list of

this_

. It also parses

struct navigation_maneuver * maneuver
Definition: navigation.c:309

and sets its

char type[3]
Definition: garmin_img.c:2

appropriately so that other functions can rely on that.

Parameters
this_The navigation object
itmThe navigation item following the maneuver
maneuverThe
Holds information about a navigation maneuver.
Definition: navigation.c:263
returned by
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.
Definition: navigation.c:1844
. For the destination, initialize a zeroed-out and set its member to
type_nav_destination
prior to calling this function.
Returns
The new command

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

◆ contains_suffix()

static int contains_suffix ( char *  name,
char *  suffix 
)
static

◆ count_possible_turns()

static int count_possible_turns ( struct navigation nav,
struct navigation_itm from,
struct navigation_itm to,
int  direction 
)
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.

Parameters
fromThe navigation item which should form the start
toThe navigation item which should form the end
directionSet to < 0 to count turns to the left >= 0 for turns to the right
Returns
The number of possibilities to turn or -1 on error

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

◆ free_list()

static void free_list ( struct street_destination list)
static

Frees a list as constructed with split_string_to_list()

Parameters
listthe list to be freed

References street_destination::destination, and street_destination::next.

Referenced by navigation_destroy_itms_cmds(), and split_string_to_list().

◆ get_bestranked()

static struct street_destination* get_bestranked ( struct street_destination street_destination)
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().

◆ get_count_str()

static const char* get_count_str ( int  n)
static

References _.

Referenced by show_maneuver().

◆ get_distance_str()

static char* get_distance_str ( struct navigation nav,
int  dist_meters,
enum attr_type  type,
int  is_length 
)
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.

Parameters
navThe navigation object.
dist_metersDistance in meters.
typeThe type of announcement precision.
is_length1 for length statement, 0 for distance statement.
Returns
String with length/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().

◆ get_exit_count_str()

static const char* get_exit_count_str ( int  n)
static

References _.

Referenced by show_maneuver().

◆ is_motorway_like()

static int is_motorway_like ( struct navigation_way way,
int  extended 
)
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

extended

is true and item type is either ramp or street_service

Parameters
wayThe way to examine
extendedWhether to consider ramps and service roads to be motorway-like
Returns
True for motorway-like, false otherwise

References AF_ONEWAYMASK, navigation_way::flags, navigation_way::item, item::type, and navigation_itm::way.

Referenced by maneuver_required2(), and navigation_item_destination().

◆ is_ramp()

static int is_ramp ( struct navigation_way way)
static

Checks whether a way is a ramp.

Parameters
wayThe way to be examined
Returns
True for ramp, false otherwise

References navigation_way::item, item::type, and navigation_itm::way.

Referenced by navigation_analyze_roundabout().

◆ is_same_street2()

static int is_same_street2 ( char *  old_name,
char *  old_name_systematic,
char *  new_name,
char *  new_name_systematic 
)
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.

Parameters
old_nameThe name of the first item to be checked
old_name_systematicThe systematic name of the first item to be checked
new_nameThe name of the second item to be checked
new_name_systematicThe systematic name of the second item to be checked
Returns
True if both old and new are on the same street

References dbg, and lvl_debug.

Referenced by is_same_way(), and maneuver_required2().

◆ is_same_way()

static int is_same_way ( struct navigation_way w1,
struct navigation_way w2 
)
static

Checks if two ways are identical.

This function checks if two

Definition: navigation.c:316

s are likely to represent the same way on the ground. It does this by comparing the

char name[0]
Definition: street.c:3

,

name_systematic

,

angle2

and

Represents an object on a map.
Definition: item.h:115
enum item_type type
Definition: item.h:116

members of both ways and returning

true

if all of them match.

Names are compared by calling

is_same_street()

.

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

angle2

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

◆ is_way_allowed()

static int is_way_allowed ( struct navigation nav,
struct navigation_way way,
int  mode 
)
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

nav->vehicleprofile

. Turn restrictions are not taken into account.

Parameters
navThe navigation object
wayThe way to examine
modeIf nonzero, oneway restrictions will be taken into account. If zero, only the vehicle type will be taken into account.
Returns
True if entry is permitted, false otherwise. If
nav->vehicleprofile
is null, true is returned.

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

◆ make_maneuvers()

static void make_maneuvers ( struct navigation this_,
struct route route 
)
static

Creates turn instructions where needed.

Parameters
this_The navigation object for which to create turn instructions
routeNot 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().

◆ maneuver_category()

static int maneuver_category ( enum item_type  type)
static

References type.

Referenced by maneuver_required2().

◆ maneuver_required2()

static int maneuver_required2 ( struct navigation nav,
struct navigation_itm old,
struct navigation_itm new,
struct navigation_maneuver **  maneuver 
)
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".

Parameters
oldThe old navigation item, where we're coming from
newThe new navigation item, where we're going to
maneuverPointer to a buffer that will receive a pointer to a in which detailed information on the maneuver will be stored. The buffer may receive a null pointer for some cases that do not require a maneuver. If a non-null pointer is returned, the caller is responsible for freeing up the buffer once it is no longer needed.
Returns
True if navit should guide the user, false otherwise

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

◆ nav_status_to_text()

char* nav_status_to_text ( int  status)

Converts navigation status to human-readable text.

Parameters
Thestatus. This must be one of the values for
nav_status
Definition: navigation.h:45
.
Returns
A string which corresponds to the constant value. The caller is responsible for calling
g_free()
when the result is no longer needed.

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

◆ navigation_analyze_roundabout()

static void navigation_analyze_roundabout ( struct navigation this_,
struct navigation_command cmd,
struct navigation_itm itm 
)
static

Analyzes a roundabout and sets maneuver information.

Exit from a roundabout requires a somewhat complex analysis of the ways involved in order to:

  • Calculate effective bearing change (between entry and exit) and store it in
    cmd->roundabout_delta
  • Set
    cmd->maneuver->type
    to
    nav_roundabout_{r|l}{1..8}
    , based on bearing change
  • Set
    cmd->length

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

delta1

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

delta2

here.

Combining

delta1

and

delta2

, 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

delta1

and

delta2

. This approach has produced the best results in tests. In code it is referred to as

delta3

.

Parameters
this_The navigation object
cmdA
struct navigation_cmd
, whose
delta
and
maneuver
members must be set prior to calling this function
itmThe 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().

◆ navigation_call_callbacks()

◆ navigation_cmd_get_exit_announce()

static char* navigation_cmd_get_exit_announce ( struct navigation_command this_,
char *  street_destination_announce 
)
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

street_destination_announce

, 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

street_destination_announce

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

Parameters
this_The navigation command
street_destination_announceThe 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().

◆ navigation_destroy()

◆ navigation_destroy_itms_cmds()

static void navigation_destroy_itms_cmds ( struct navigation this_,
struct navigation_itm end 
)
static

Destroys navigation items associated with a navigation object.

This function destroys all or some of the

Definition: navigation.c:329

instances associated with

this_

, starting with the first one. Data structures associated with the items will also be freed.

Parameters
this_The navigation object whose command instances are to be destroyed
endThe 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().

◆ navigation_flush()

static void navigation_flush ( struct navigation this_)
static

◆ navigation_get_announce_level()

static enum announcement_level navigation_get_announce_level ( struct navigation this_,
enum item_type  type,
int  dist 
)
static

◆ navigation_get_announce_level_cmd()

static enum announcement_level navigation_get_announce_level_cmd ( struct navigation this_,
struct navigation_itm itm,
struct navigation_command cmd,
int  distance 
)
static

◆ navigation_get_attr()

◆ navigation_get_map()

◆ navigation_init()

void navigation_init ( void  )

Referenced by main_real().

◆ navigation_item_destination()

static char* navigation_item_destination ( struct navigation nav,
struct navigation_command cmd,
struct navigation_itm next,
char *  prefix 
)
static

Creates a text description for the destination of a maneuver, which can be used in announcements.

Parameters
navThe navigation object
cmdThe for which to generate an announcement
nextThe 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
associated with the previous
prefixA 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().

◆ navigation_itm_new()

static struct navigation_itm* navigation_itm_new ( struct navigation this_,
struct item routeitem 
)
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.

Parameters
this_the navigation object
routeitemthe routeitem from which to create a navigation item
Returns
the new navigation_itm (used nowhere)

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

◆ navigation_itm_update()

static void navigation_itm_update ( struct navigation_itm itm,
struct item ritem 
)
static

◆ navigation_itm_ways_clear()

static void navigation_itm_ways_clear ( struct navigation_itm itm)
static

Clears the ways one can drive from itm.

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

◆ navigation_itm_ways_update()

static void navigation_itm_ways_update ( struct navigation_itm itm,
struct map graph_map 
)
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.

Parameters
itmThe item that should be updated
graph_mapThe 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().

◆ navigation_map_destroy()

static void navigation_map_destroy ( struct map_priv priv)
static

◆ navigation_map_get_item()

static struct item* navigation_map_get_item ( struct map_rect_priv priv)
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

maneuver->type

, though some exceptions apply: The first item in the map will have a type of

nav_position

and the last one will have a type of

nav_destination

. If

maneuver->merge_or_exit

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

static struct navigation_command * command_new(struct navigation *this_, struct navigation_itm *itm, struct navigation_maneuver *maneuver)
Creates a new.
Definition: navigation.c:2597

so that other functions can use the same results.

Parameters
privThe
Implementation-specific map rect data.
Definition: binfile.c:137
of the map rect on the navigation map from which an item is to be retrieved.
Returns
The item, or NULL if there are no more items in the map rectangle

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

◆ navigation_map_get_item_byid()

static struct item* navigation_map_get_item_byid ( struct map_rect_priv priv,
int  id_hi,
int  id_lo 
)
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

static struct item * navigation_map_get_item(struct map_rect_priv *priv)
Gets the next item from the navigation map.
Definition: navigation.c:4196

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

Parameters
privThe of the map rect on the navigation map from which an item is to be retrieved.
id_hiThe high part of the ID
id_loThe low part of the ID
Returns
The item, or NULL if an item with the ID specified was not found in the map rectangle

References item::id_hi, item::id_lo, navigation_map_get_item(), and navigation_map_rect_init().

◆ navigation_map_item_attr_get()

static int navigation_map_item_attr_get ( void *  priv_data,
enum attr_type  attr_type,
struct attr attr 
)
static

◆ navigation_map_item_attr_rewind()

static void navigation_map_item_attr_rewind ( void *  priv_data)
static

◆ navigation_map_item_coord_get()

static int navigation_map_item_coord_get ( void *  priv_data,
struct coord c,
int  count 
)
static

References c, and map_rect_priv::ccount.

◆ navigation_map_item_coord_rewind()

static void navigation_map_item_coord_rewind ( void *  priv_data)
static

◆ navigation_map_new()

static struct map_priv* navigation_map_new ( struct map_methods meth,
struct attr **  attrs,
struct callback_list cbl 
)
static

◆ navigation_map_rect_destroy()

static void navigation_map_rect_destroy ( struct map_rect_priv priv)
static

References map_rect_priv::str.

◆ navigation_map_rect_init()

◆ navigation_map_rect_new()

◆ navigation_new()

◆ navigation_register_callback()

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

attr_any

, which will fire on any change.

The

Definition: navigation.c:161

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:

  • Callbacks for the
    navigation_speech
    attribute are added to the
    callback_speech
    list.
  • Callbacks for the
    navigation_long
    attribute are added to the
    Definition: callback.c:27
    list.
  • Callbacks for any other attribute, including
    attr_any
    , are added to the list stored in the
    Definition: callback.c:37
    attribute. This functionality is inherited from
    Definition: xmlconfig.h:122
    .
Parameters
this_The navigation object.
typeThe attribute type
cbThe callback function
Returns
true on success, false on failure

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

◆ navigation_set_announce()

int navigation_set_announce ( struct navigation this_,
enum item_type  type,
int *  level 
)

◆ navigation_set_attr()

int navigation_set_attr ( struct navigation this_,
struct attr attr 
)

◆ navigation_set_route()

◆ navigation_set_turnaround()

static void navigation_set_turnaround ( struct navigation this_,
int  val 
)
static

◆ navigation_unregister_callback()

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.

Parameters
this_The navigation object.
typeThe attribute type
cbThe 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().

◆ navigation_update()

static void navigation_update ( struct navigation this_,
struct route route,
struct attr attr 
)
static

◆ navigation_update_done()

static void navigation_update_done ( struct navigation this_,
int  cancel 
)
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

busy

flag. Arguments correspond to those of navigation_update_idle(struct navigation *).

Parameters
this_Points to the navigation object. After the function returns, its
Definition: map.c:62
member will no longer be valid.
cancelIf 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().

◆ navigation_update_idle()

static void navigation_update_idle ( struct navigation this_)
static

Idle callback function to retrieve items from the route map.

Parameters
this_Points to the navigation object. The caller is responsible for initializing its
route_mr
member. After processing completes, the
route_mr
member will no longer be valid.

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

◆ navigation_way_get_max_delta()

static int navigation_way_get_max_delta ( struct navigation_way w,
enum projection  pro,
int  angle,
double  dist,
int  dir 
)
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,

dir

controls which of the two values is returned:

  • +1: Return the first maximum encountered when following the direction of the route
  • -1: Return the first maximum encountered when going against the direction of the route
static int invalid_angle
Definition: navigation.c:56

will be returned if one of the following errors occurs:

  • The item is not found on the map
  • The item is not of the correct type
  • The item has fewer than 2 points
  • dist
    is zero

If

dist

exceeds the length of the way, the entire way is examined.

Parameters
proThe projection used by the map
wThe way to examine
angleThe reference bearing
distThe distance from the start of the way at which to determine bearing
dirControls how to handle when the same delta is encountered multiple times but with different signs, permissible values are either -1 or +1
Returns
The delta,
-180 < delta <= 180
, or if an error occurred.

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

◆ navigation_way_init()

static void navigation_way_init ( struct navigation_way w)
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

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.
Definition: navigation.c:1447

) as it may return incorrect coordinates for these ways.

Parameters
wThe way to initialize. The ,
id_hi
,
id_lo
and
dir
members of this struct must be set prior to calling this function.

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

◆ replace_suffix()

static char* replace_suffix ( char *  name,
char *  search,
char *  replace 
)
static

References name.

Referenced by navigation_item_destination().

◆ road_angle()

static int road_angle ( struct coord c1,
struct coord c2,
int  dir 
)
static

Gets the bearing from one point to another.

Parameters
c1The first coordinate
c2The second coordinate
dirThe direction: if it is -1, the bearing from c2 to c1 is returned, else the bearing from c1 to c2
Returns
The bearing in degrees,
0 <= result < 360
Definition: command.c:34
.

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

◆ round_distance()

static int round_distance ( int  dist)
static

◆ round_distance_reduced()

static int round_distance_reduced ( int  dist)
static

Restricts the distance value to a simple set of pronounceable numbers.

Parameters
distThe distance to be processed
Returns
distance Simplified distance value

References dbg, distances, LAST_DISTANCE, lvl_debug, and SIZE_OF_ARRAY_DISTANCES.

Referenced by get_distance_str().

◆ select_announced_destinations()

static char* select_announced_destinations ( struct navigation_command current_command)
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().

◆ set_highrank()

static int set_highrank ( struct street_destination street_destination,
struct navigation_command command 
)
static

Assigns a high rank to a matching destination in the next command having destination info, and reset existing ranks to zero.

Parameters
streetdestination to be given a high rank
command
Returns
1 if successful, zero otherwise

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

◆ show_maneuver()

static char* show_maneuver ( struct navigation nav,
struct navigation_itm itm,
struct navigation_command cmd,
enum attr_type  type,
enum announcement_level  level 
)
static

Creates turn by turn guidance sentences for the speech and for the route description.

Parameters
navThe navigation object
itmThe 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
associated with the previous
cmdThe for which to generate an announcement
typeThe type of announcements to generate. Set to
attr_navigation_long_exact
to avoid rounding distances, or to
attr_navigation_speech
to avoid announcing street names more than once
connectWhether 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().

◆ show_next_maneuvers()

static char* show_next_maneuvers ( struct navigation nav,
struct navigation_itm itm,
struct navigation_command cmd,
enum attr_type  type 
)
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

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.
Definition: navigation.c:3038

.

Parameters
navThe navigation object
itmThe 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
associated with the previous
cmdThe for which to generate an announcement
typeThe type of announcements to generate. If set to
attr_navigation_speech
, maneuvers will be grouped ("turn left, then turn right") if we are close to the first maneuver and the second maneuver is within a short distance from the first. This parameter is passed to , where it is evaluated again. See for details.
Returns
An announcement that should be made

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

◆ split_string_to_list()

static int split_string_to_list ( struct navigation_way way,
char *  raw_string,
char  sep 
)
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.

Parameters
waya navigation_way holding the list to be filled up
raw_stringa string to split
sepa char to be used as separator to split the raw_string
Returns
the number of entries in the list

References dbg, navigation_way::destination, street_destination::destination, free_list(), lvl_debug, street_destination::next, and street_destination::rank.

Referenced by navigation_itm_new().

Variable Documentation

◆ distances

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

◆ invalid_angle

int invalid_angle = 361
static

◆ min_turn_limit

int min_turn_limit = 25
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().

◆ navigation_func

struct object_func navigation_func
Initial value:
= {
attr_navigation,
}
struct navigation * navigation_new(struct attr *parent, struct attr **attrs)
Definition: navigation.c:776
void navigation_destroy(struct navigation *this_)
Definition: navigation.c:3781
int navigation_set_attr(struct navigation *this_, struct attr *attr)
Definition: navigation.c:760
int navigation_get_attr(struct navigation *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Definition: navigation.c:708
int navit_object_remove_attr(struct navit_object *obj, struct attr *attr)
Definition: xmlconfig.c:1399
struct attr_iter * navit_object_attr_iter_new(void *unused)
Definition: xmlconfig.c:1328
void navit_object_attr_iter_destroy(struct attr_iter *iter)
Definition: xmlconfig.c:1332
int navit_object_add_attr(struct navit_object *obj, struct attr *attr)
Definition: xmlconfig.c:1377
void * navit_object_unref(struct navit_object *obj)
Definition: xmlconfig.c:1313
struct navit_object * navit_object_ref(struct navit_object *obj)
Definition: xmlconfig.c:1307
void(* object_func_iter_destroy)(struct attr_iter *)
Definition: xmlconfig.h:57
void *(* object_func_new)(struct attr *parent, struct attr **attrs)
Definition: xmlconfig.h:54
int(* object_func_remove_attr)(void *, struct attr *attr)
Definition: xmlconfig.h:60
void *(* object_func_ref)(void *)
Definition: xmlconfig.h:64
struct attr_iter *(* object_func_iter_new)(void *)
Definition: xmlconfig.h:56
int(* object_func_init)(void *)
Definition: xmlconfig.h:61
void *(* object_func_dup)(void *)
Definition: xmlconfig.h:63
int(* object_func_add_attr)(void *, struct attr *attr)
Definition: xmlconfig.h:59
void(* object_func_destroy)(void *)
Definition: xmlconfig.h:62
int(* object_func_set_attr)(void *, struct attr *attr)
Definition: xmlconfig.h:58
int(* object_func_get_attr)(void *, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Definition: xmlconfig.h:55
void *(* object_func_unref)(void *)
Definition: xmlconfig.h:65

Referenced by navigation_new(), and object_func_lookup().

◆ navigation_map_item_methods

struct item_methods navigation_map_item_methods
static
Initial value:
= {
}
static void navigation_map_item_coord_rewind(void *priv_data)
Definition: navigation.c:3905
static int navigation_map_item_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
Definition: navigation.c:3911
static int navigation_map_item_coord_get(void *priv_data, struct coord *c, int count)
Definition: navigation.c:3896
static void navigation_map_item_attr_rewind(void *priv_data)
Definition: navigation.c:4135

Referenced by navigation_map_rect_new().

◆ navigation_map_meth

struct map_methods navigation_map_meth
static
Initial value:
= {
"utf-8",
NULL,
NULL,
NULL,
}
static struct map_rect_priv * navigation_map_rect_new(struct map_priv *priv, struct map_selection *sel)
Definition: navigation.c:4158
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.
Definition: navigation.c:4270
static void navigation_map_destroy(struct map_priv *priv)
Definition: navigation.c:4149
static void navigation_map_rect_destroy(struct map_rect_priv *priv)
Definition: navigation.c:4171
@ projection_mg
Definition: projection.h:25

Referenced by navigation_map_new().

◆ roundabout_extra_length

int roundabout_extra_length =50
static

◆ sharp_turn_limit

int sharp_turn_limit = 110
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().

◆ suffixes

struct suffix suffixes[]

◆ turn_2_limit

int turn_2_limit = 45
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().

◆ u_turn_limit

int u_turn_limit = 165
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().