navit  0.5.3-trunk
route.c File Reference

Contains code related to finding a route from a position to a destination. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "navit_nls.h"
#include "glib_slice.h"
#include "config.h"
#include "point.h"
#include "graphics.h"
#include "profile.h"
#include "coord.h"
#include "projection.h"
#include "item.h"
#include "xmlconfig.h"
#include "map.h"
#include "mapset.h"
#include "route_protected.h"

Data Structures

struct  map_priv
 Represents the map from a single binfile. More...
 
struct  route_traffic_distortion
 A traffic distortion. More...
 
struct  route_path_segment
 A segment in the route path. More...
 
struct  route_info
 Usually represents a destination or position. More...
 
struct  route_path
 A complete route path. More...
 
struct  route
 A complete route. More...
 
struct  route_graph_point_iterator
 Iterator to iterate through all route graph segments in a route graph point. More...
 
struct  attr_iter
 
struct  map_rect_priv
 Implementation-specific map rect data. More...
 

Functions

static struct route_inforoute_find_nearest_street (struct vehicleprofile *vehicleprofile, struct mapset *ms, struct pcoord *pc)
 Finds the nearest street to a given coordinate. More...
 
static void route_graph_update (struct route *this, struct callback *cb, int async)
 Updates the route graph. More...
 
static struct route_pathroute_path_new (struct route_graph *this, struct route_path *oldpath, struct route_info *pos, struct route_info *dst, struct vehicleprofile *profile)
 Creates a new route path. More...
 
static void route_graph_add_street (struct route_graph *this, struct item *item, struct vehicleprofile *profile)
 Adds an item to the route graph. More...
 
static void route_graph_destroy (struct route_graph *this)
 Destroys a route graph. More...
 
static void route_path_update (struct route *this, int cancel, int async)
 Updates the route graph and the route path if something changed with the route. More...
 
static int route_time_seg (struct vehicleprofile *profile, struct route_segment_data *over, struct route_traffic_distortion *dist)
 Returns the time needed to travel along a segment, or. More...
 
static void route_graph_compute_shortest_path (struct route_graph *graph, struct vehicleprofile *profile, struct callback *cb)
 Expands (i.e. calculates the costs for) the points on the route graph’s heap. More...
 
static int route_graph_is_path_computed (struct route_graph *this_)
 Whether cost (re)calculation of route graph points has reached the start point. More...
 
static struct route_graph_segmentroute_graph_get_segment (struct route_graph *graph, struct street_data *sd, struct route_graph_segment *last)
 Gets the next route_graph_segment belonging to the specified street. More...
 
static int route_value_seg (struct vehicleprofile *profile, struct route_graph_point *from, struct route_graph_segment *over, int dir)
 Returns the "cost" of traveling along segment over in direction dir More...
 
static void route_graph_init (struct route_graph *this, struct route_info *dst, struct vehicleprofile *profile)
 Initializes potential destination nodes. More...
 
static void route_graph_reset (struct route_graph *this)
 Resets all nodes. More...
 
static enum projection route_projection (struct route *route)
 Returns the projection used for this route. More...
 
static struct route_graph_point_iterator rp_iterator_new (struct route_graph_point *p)
 Creates a new graph point iterator. More...
 
static struct route_graph_segmentrp_iterator_next (struct route_graph_point_iterator *it)
 Gets the next segment connected to a route graph point from an iterator. More...
 
static int rp_iterator_end (struct route_graph_point_iterator *it)
 Checks if the last segment returned from a route_graph_point_iterator comes from the end. More...
 
static void route_path_get_distances (struct route_path *path, struct coord *c, int count, int *distances)
 
void route_get_distances (struct route *this, struct coord *c, int count, int *distances)
 
static void route_path_destroy (struct route_path *this, int recurse)
 Destroys a route_path. More...
 
struct routeroute_new (struct attr *parent, struct attr **attrs)
 Creates a completely new route structure. More...
 
struct routeroute_dup (struct route *orig)
 Duplicates a route object. More...
 
static int route_check_roundabout (struct route_graph_segment *seg, int level, int direction, struct route_graph_segment *origin)
 Checks if a segment is part of a roundabout. More...
 
void route_set_mapset (struct route *this, struct mapset *ms)
 Sets the mapset of the route passwd. More...
 
void route_set_profile (struct route *this, struct vehicleprofile *prof)
 Sets the vehicle profile of a route. More...
 
struct mapsetroute_get_mapset (struct route *this)
 Returns the mapset of the route passed. More...
 
struct route_inforoute_get_pos (struct route *this)
 Returns the current position within the route passed. More...
 
struct route_inforoute_get_dst (struct route *this)
 Returns the destination of the route passed. More...
 
int route_get_path_set (struct route *this)
 Checks if the path is calculated for the route passed. More...
 
int route_contains (struct route *this, struct item *item)
 Checks if the route passed contains a certain item within the route path. More...
 
static struct route_inforoute_next_destination (struct route *this)
 
int route_destination_reached (struct route *this)
 Checks if a route has reached its destination. More...
 
static struct route_inforoute_previous_destination (struct route *this)
 Returns the position from which to route to the current destination of the route. More...
 
static void route_path_update_done (struct route *this, int new_graph)
 Updates or recreates the route graph. More...
 
static void route_path_update_flags (struct route *this, enum route_path_flags flags)
 Updates the route graph and the route path if something changed with the route. More...
 
static void route_info_distances (struct route_info *ri, enum projection pro)
 This will calculate all the distances stored in a route_info. More...
 
static int route_set_position_flags (struct route *this, struct pcoord *pos, enum route_path_flags flags)
 This sets the current position of the route passed. More...
 
void route_set_position (struct route *this, struct pcoord *pos)
 This sets the current position of the route passed. More...
 
void route_set_position_from_tracking (struct route *this, struct tracking *tracking, enum projection pro)
 Sets a route's current position based on coordinates from tracking. More...
 
struct map_selectionroute_rect (int order, struct coord *c1, struct coord *c2, int rel, int abs)
 Returns a single map selection. More...
 
static struct map_selectionroute_rect_add (struct map_selection *sel, int order, struct coord *c1, struct coord *c2, int rel, int abs)
 Appends a map selection to the selection list. Selection list may be NULL. More...
 
static struct map_selectionroute_calc_selection (struct coord *c, int count, struct vehicleprofile *profile)
 Returns a list of map selections useable to create a route graph. More...
 
struct map_selectionroute_get_selection (struct route *this_)
 Retrieves the map selection for the route. More...
 
void route_free_selection (struct map_selection *sel)
 Destroys a list of map selections. More...
 
static void route_info_free_g (struct route_info *inf, void *unused)
 
static void route_clear_destinations (struct route *this_)
 
void route_set_destinations (struct route *this, struct pcoord *dst, int count, int async)
 Sets the destination of a route. More...
 
int route_get_destinations (struct route *this, struct pcoord *pc, int count)
 Retrieves destinations from the route. More...
 
int route_get_destination_count (struct route *this)
 Get the destinations count for the route. More...
 
char * route_get_destination_description (struct route *this, int n)
 Returns a description for a waypoint as (type or street_name_systematic) + (label or WayID[osm_wayid]) More...
 
void route_set_destination (struct route *this, struct pcoord *dst, int async)
 Start a route given set of coordinates. More...
 
void route_append_destination (struct route *this, struct pcoord *dst, int async)
 Append a waypoint to the route. More...
 
void route_remove_nth_waypoint (struct route *this, int n)
 Remove the nth waypoint of the route. More...
 
void route_remove_waypoint (struct route *this)
 
struct route_graph_pointroute_graph_get_point_next (struct route_graph *this, struct coord *c, struct route_graph_point *last)
 Gets the next route_graph_point with the specified coordinates. More...
 
struct route_graph_pointroute_graph_get_point (struct route_graph *this, struct coord *c)
 Gets the first route_graph_point with the specified coordinates. More...
 
static struct route_graph_pointroute_graph_get_point_last (struct route_graph *this, struct coord *c)
 Gets the last route_graph_point with the specified coordinates. More...
 
static struct route_graph_pointroute_graph_point_new (struct route_graph *this, struct coord *f)
 Create a new point for the route graph with the specified coordinates. More...
 
struct route_graph_pointroute_graph_add_point (struct route_graph *this, struct coord *f)
 Inserts a point into the route graph at the specified coordinates. More...
 
void route_graph_free_points (struct route_graph *this)
 Frees all the memory used for points in the route graph passed. More...
 
void * route_segment_data_field_pos (struct route_segment_data *seg, enum attr_type type)
 Returns the position of a certain field appended to a route graph segment. More...
 
static int route_segment_data_size (int flags)
 Calculates the size of a route_segment_data struct with given flags. More...
 
int route_graph_segment_is_duplicate (struct route_graph_point *start, struct route_graph_segment_data *data)
 Checks if the route graph already contains a particular segment. More...
 
void route_graph_add_segment (struct route_graph *this, struct route_graph_point *start, struct route_graph_point *end, struct route_graph_segment_data *data)
 Inserts a new segment into the route graph. More...
 
static struct route_path_segmentroute_extract_segment_from_path (struct route_path *path, struct item *item, int offset)
 Returns and removes one segment from a path. More...
 
static void route_path_add_segment (struct route_path *this, struct route_path_segment *segment)
 Adds a segment and the end of a path. More...
 
static void route_path_add_line (struct route_path *this, struct coord *start, struct coord *end, int len)
 Adds a two coordinate line to a path. More...
 
static int route_path_add_item_from_graph (struct route_path *this, struct route_path *oldpath, struct route_graph_segment *rgs, int dir, struct route_info *pos, struct route_info *dst)
 Inserts a new segment into the path. More...
 
void route_graph_free_segments (struct route_graph *this)
 Destroys all segments of a route graph. More...
 
static int route_seg_speed (struct vehicleprofile *profile, struct route_segment_data *over, struct route_traffic_distortion *dist)
 Returns the estimated speed on a segment, or 0 for an impassable segment. More...
 
static int route_get_traffic_distortion (struct route_graph_segment *seg, int dir, struct vehicleprofile *profile, struct route_traffic_distortion *ret)
 Returns the traffic distortion for a segment. More...
 
static int route_through_traffic_allowed (struct vehicleprofile *profile, struct route_graph_segment *seg)
 
static int route_graph_segment_match (struct route_graph_segment *s1, struct route_graph_segment *s2)
 Whether two route graph segments match. More...
 
static int route_value_add (int val1, int val2)
 Adds two route values with protection against integer overflows. More...
 
static void route_graph_point_update (struct vehicleprofile *profile, struct route_graph_point *p, struct fibheap *heap)
 Updates the lookahead value of a point in the route graph and updates its heap membership. More...
 
static void route_graph_set_traffic_distortion (struct route_graph *this, struct route_graph_segment *seg, int delay)
 Sets or clears a traffic distortion for a segment. More...
 
static void route_graph_add_traffic_distortion (struct route_graph *this, struct vehicleprofile *profile, struct item *item, int update)
 Adds a traffic distortion item to the route graph. More...
 
static void route_graph_remove_traffic_distortion (struct route_graph *this, struct vehicleprofile *profile, struct item *item)
 Removes a traffic distortion item from the route graph. More...
 
static void route_graph_change_traffic_distortion (struct route_graph *this, struct vehicleprofile *profile, struct item *item)
 Changes a traffic distortion item in the route graph. More...
 
void route_graph_add_turn_restriction (struct route_graph *this, struct item *item)
 Adds a turn restriction item to the route graph. More...
 
void route_recalculate_partial (struct route *this_)
 Triggers partial recalculation of the route, based on the existing route graph. More...
 
static struct route_pathroute_path_new_offroad (struct route_graph *this, struct route_info *pos, struct route_info *dst)
 Starts an "offroad" path. More...
 
struct coord route_get_coord_dist (struct route *this_, int dist)
 Returns a coordinate at a given distance. More...
 
static int route_graph_build_next_map (struct route_graph *rg)
 
static int is_turn_allowed (struct route_graph_point *p, struct route_graph_segment *from, struct route_graph_segment *to)
 
static void route_graph_clone_segment (struct route_graph *this, struct route_graph_segment *s, struct route_graph_point *start, struct route_graph_point *end, int flags)
 
static void route_graph_process_restriction_segment (struct route_graph *this, struct route_graph_point *p, struct route_graph_segment *s, int dir)
 
static void route_graph_process_restriction_point (struct route_graph *this, struct route_graph_point *p)
 
static void route_graph_process_restrictions (struct route_graph *this)
 
void route_graph_build_done (struct route_graph *rg, int cancel)
 Releases all resources needed to build the route graph. More...
 
static void route_graph_build_idle (struct route_graph *rg, struct vehicleprofile *profile)
 
static struct route_graphroute_graph_build (struct mapset *ms, struct coord *c, int count, struct callback *done_cb, int async, struct vehicleprofile *profile)
 Builds a new route graph from a mapset. More...
 
static void route_graph_update_done (struct route *this, struct callback *cb)
 
struct street_datastreet_get_data (struct item *item)
 Gets street data for an item. More...
 
struct street_datastreet_data_dup (struct street_data *orig)
 Copies street data. More...
 
void street_data_free (struct street_data *sd)
 Frees street data. More...
 
void route_info_free (struct route_info *inf)
 Destroys a route_info. More...
 
struct street_dataroute_info_street (struct route_info *rinf)
 Returns street data for a route info. More...
 
static void rm_coord_rewind (void *priv_data)
 
static void rm_attr_rewind (void *priv_data)
 
static int rm_attr_get (void *priv_data, enum attr_type attr_type, struct attr *attr)
 
static int rm_coord_get (void *priv_data, struct coord *c, int count)
 
static void rp_attr_rewind (void *priv_data)
 
static int rp_attr_get (void *priv_data, enum attr_type attr_type, struct attr *attr)
 
static int rp_coord_get (void *priv_data, struct coord *c, int count)
 Returns the coordinates of a route graph item. More...
 
static void rp_destroy (struct map_priv *priv)
 
static void rm_destroy (struct map_priv *priv)
 
static struct map_rect_privrm_rect_new (struct map_priv *priv, struct map_selection *sel)
 
static struct map_rect_privrp_rect_new (struct map_priv *priv, struct map_selection *sel)
 Opens a new map rectangle on the route graph's map. More...
 
static void rm_rect_destroy (struct map_rect_priv *mr)
 
static struct itemrp_get_item (struct map_rect_priv *mr)
 
static struct itemrp_get_item_byid (struct map_rect_priv *mr, int id_hi, int id_lo)
 
static struct itemrm_get_item (struct map_rect_priv *mr)
 
static struct itemrm_get_item_byid (struct map_rect_priv *mr, int id_hi, int id_lo)
 
static struct map_privroute_map_new_helper (struct map_methods *meth, struct attr **attrs, int graph)
 
static struct map_privroute_map_new (struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
 
static struct map_privroute_graph_map_new (struct map_methods *meth, struct attr **attrs, struct callback_list *cbl)
 
static struct maproute_get_map_helper (struct route *this_, struct map **map, char *type, char *description)
 
void route_add_traffic_distortion (struct route *this_, struct item *item)
 Adds a traffic distortion item to the route. More...
 
void route_change_traffic_distortion (struct route *this_, struct item *item)
 Changes a traffic distortion item on the route. More...
 
struct maproute_get_map (struct route *this_)
 Returns a new map containing the route path. More...
 
struct maproute_get_graph_map (struct route *this_)
 Returns a new map containing the route graph. More...
 
enum route_path_flags route_get_flags (struct route *this_)
 Returns the flags for the route. More...
 
struct route_graphroute_get_graph (struct route *this_)
 Retrieves the route graph. More...
 
int route_has_graph (struct route *this_)
 Whether the route has a valid graph. More...
 
void route_remove_traffic_distortion (struct route *this_, struct item *item)
 Removes a traffic distortion item from the route. More...
 
void route_set_projection (struct route *this_, enum projection pro)
 
int route_set_attr (struct route *this_, struct attr *attr)
 
int route_add_attr (struct route *this_, struct attr *attr)
 
int route_remove_attr (struct route *this_, struct attr *attr)
 
int route_get_attr (struct route *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
 
struct attr_iterroute_attr_iter_new (void)
 
void route_attr_iter_destroy (struct attr_iter *iter)
 
void route_init (void)
 
void route_destroy (struct route *this_)
 

Variables

int debug_route =0
 
struct map_selectionroute_selection
 
static struct item_methods methods_route_item
 
static struct item_methods methods_point_item
 
static struct map_methods route_meth
 
static struct map_methods route_graph_meth
 
struct object_func route_func
 

Detailed Description

Contains code related to finding a route from a position to a destination.

Navit, a modular navigation system. Copyright (C) 2005-2018 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.

Routing uses segments, points and items. Items are items from the map: Streets, highways, etc. Segments represent such items, or parts of it. Generally, a segment is a driveable path. An item can be represented by more than one segment - in that case it is "segmented". Each segment has an "offset" associated, that indicates at which position in a segmented item this segment is - a segment representing a not-segmented item always has the offset 1. A point is located at the end of segments, often connecting several segments.

The code in this file will make navit find a route between a position and a destination. It accomplishes this by first building a "route graph". This graph contains segments and points.

Routing now relies on the Lifelong Planning A* (LPA*) algorithm, which builds upon the A* algorithm but allows for partial updates after the cost of some segments has changed. (With A*, one would need to recalculate the entire route graph from scratch.) A*, in turn, is an extension of the Dijkstra algorithm, with the added improvement that A* introduces a heuristic (essentially, a lower boundary for the yet-to-be-calculated remainder of the route from a given point onwards) and chooses the next point to analyze based on the sum of its cost and its heuristic, where Dijkstra uses simply the cost of the node. This makes A* more efficient than Dijkstra in some scenarios. (Navit, however, is not one of them, as we currently analyze only a subset of the entire map, and calculating the heuristic for each node turned out to cost more than it saved in tests.)

Wikipedia has articles on all three algorithms; refer to these for an in-depth discussion of the algorithms.

If the heuristic is assumed to be zero in all cases, A* behaves exactly as Dijkstra would. Similarly, LPA* behaves identically to A* if all segment costs are known prior to route calculation and do not change once route calculation has started.

Earlier versions of Navit used Dijkstra for routing. This was upgraded to LPA* when the traffic module was introduced, as it became necessary to do fast partial recalculations of the route when the traffic situation changes. Navit’s LPA* implementation differs from the canonical implementation in two important ways:

  • The heuristic is not used (or assumed to be zero), for the reasons discussed above. However, this is not set in stone and can be revisited if we find using a heuristic provides a true benefit.
  • Since the destination point may be off-road, Navit may initialize the route graph with multiple candidates for the destination point, each of which will get a nonzero cost (which may still decrease if routing later determines that it is cheaper to route from that candidate point to a different candidate point).

The cost of a node is always the cost to reach the destination, and route calculation is done “backwards”, i.e. starting at the destination and working its way to the current position (or previous waypoint). This is mandatory in LPA*, while A* and Dijkstra can also work from the start to the destination. The latter is found in most textbook descriptions of these algorithms. Navit has always calculated routes from destination to start, even with Dijkstra, as this made it easier to react to changes in the vehicle position (the start of the route).

A route graph first needs to be built with route_graph_build(), which fetches the segments from the map. Next route_graph_init() is called to initialize the destination point candidates. Then route_graph_compute_shortest_path() is called to assign a value to each node, which represents the cost of traveling from this point to the destination. Each point is also assigned a “next segment” to take in order to reach the destination from this point. Eventually a “route path” is created, i.e. the sequence of segments from the current position to the destination are extracted from the route graph and turn instructions are added where necessary.

When segment costs change, route_graph_point_update() is called for each end point which may have changed. Then route_graph_compute_shortest_path() is called to update parts of the route which may have changed, and finally the route path is recreated. This is used by the traffic module when traffic reports change the cost of individual segments.

A completely new route can be created from an existing graph, which happens e.g. between sections of a route when waypoints are used. This is done by calling route_graph_reset(), which resets all nodes to their initial state. Then route_graph_init() is called, followed by route_graph_compute_shortest_path() and eventually creation of the route path.

Function Documentation

◆ is_turn_allowed()

◆ rm_attr_get()

◆ rm_attr_rewind()

static void rm_attr_rewind ( void *  priv_data)
static

References map_rect_priv::attr_next.

Referenced by rm_get_item().

◆ rm_coord_get()

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

◆ rm_coord_rewind()

static void rm_coord_rewind ( void *  priv_data)
static

References map_rect_priv::last_coord.

Referenced by rp_get_item().

◆ rm_destroy()

static void rm_destroy ( struct map_priv priv)
static

◆ rm_get_item()

◆ rm_get_item_byid()

static struct item* rm_get_item_byid ( struct map_rect_priv mr,
int  id_hi,
int  id_lo 
)
static

◆ rm_rect_destroy()

◆ rm_rect_new()

◆ route_add_attr()

int route_add_attr ( struct route this_,
struct attr attr 
)

◆ route_add_traffic_distortion()

void route_add_traffic_distortion ( struct route this_,
struct item item 
)

Adds a traffic distortion item to the route.

Parameters
this_The route
itemThe item to add, must be of
type_traffic_distortion

References route::graph, route_graph_add_traffic_distortion(), route_has_graph(), and route::vehicleprofile.

Referenced by tm_item_update_attrs().

◆ route_append_destination()

void route_append_destination ( struct route this,
struct pcoord dst,
int  async 
)

Append a waypoint to the route.

This appends a waypoint to the current route, targetting the street nearest to the coordinates passed, and updates the route.

Parameters
thisThe route to set the destination for
dstCoordinates of the new waypoint
asyncIf set, do routing asynchronously

References pcoord::pro, route_find_nearest_street(), route_get_dst(), route_graph_destroy(), route_info_distances(), route_path_update(), and route_set_destinations().

Referenced by navit_set_destination().

◆ route_attr_iter_destroy()

void route_attr_iter_destroy ( struct attr_iter iter)

References attr_iter::iter.

Referenced by NGQProxyRoute::dropIterFunc().

◆ route_attr_iter_new()

struct attr_iter* route_attr_iter_new ( void  )

◆ route_calc_selection()

static struct map_selection* route_calc_selection ( struct coord c,
int  count,
struct vehicleprofile profile 
)
static

Returns a list of map selections useable to create a route graph.

Returns a list of map selections useable to get a map rect from which items can be retrieved to build a route graph.

Parameters
cArray containing route points, including start, intermediate and destination ones.
countnumber of route points
proiflevehicleprofile

References c, coord_rect_extend(), coord_rect::lu, profile, coord_rect::rl, and route_rect_add().

Referenced by route_get_selection(), and route_graph_build().

◆ route_change_traffic_distortion()

void route_change_traffic_distortion ( struct route this_,
struct item item 
)

Changes a traffic distortion item on the route.

Attempting to change an idem which is not in the route graph will add it.

Parameters
this_The route
itemThe item to change, must be of
type_traffic_distortion

References route::graph, route_graph_change_traffic_distortion(), route_has_graph(), and route::vehicleprofile.

Referenced by tm_item_update_attrs().

◆ route_check_roundabout()

static int route_check_roundabout ( struct route_graph_segment seg,
int  level,
int  direction,
struct route_graph_segment origin 
)
static

Checks if a segment is part of a roundabout.

This function checks if a segment is part of a roundabout.

Parameters
segThe segment to be checked
levelHow deep to scan the route graph
directionSet this to 1 if we're entering the segment through its end, to 0 otherwise
originUsed internally, set to NULL
Returns
1 If a roundabout was detected, 0 otherwise

References AF_ONEWAY, AF_ONEWAYREV, AF_ROUNDABOUT, AF_ROUNDABOUT_VALID, route_graph_segment::data, route_graph_segment::end, route_segment_data::flags, route_segment_data::item, rp_iterator_end(), rp_iterator_new(), rp_iterator_next(), route_graph_segment::start, and item::type.

Referenced by route_path_add_item_from_graph().

◆ route_clear_destinations()

static void route_clear_destinations ( struct route this_)
static

◆ route_contains()

int route_contains ( struct route this,
struct item item 
)

Checks if the route passed contains a certain item within the route path.

This function checks if a certain items exists in the path that navit will guide the user to his destination. It does not check if this item exists in the route graph!

Parameters
thisThe route to check for this item
itemThe item to search for
Returns
True if the item was found, false if the item was not found or the route was not calculated

References item_hash_lookup(), item_is_equal, and startup::pos.

Referenced by tracking_is_on_route().

◆ route_destination_reached()

int route_destination_reached ( struct route this)

Checks if a route has reached its destination.

Parameters
thisThe route to be checked
Returns
True if the destination is "reached", false otherwise.

References AF_ONEWAY, AF_ONEWAYREV, street_data::flags, street_data::item, item_is_equal, route_info::lenneg, route_info::lenpos, route_info::lp, startup::pos, projection_none, route_next_destination(), route_projection(), route_info::street, and transform_distance().

Referenced by navit_vehicle_update_position().

◆ route_destroy()

◆ route_dup()

struct route* route_dup ( struct route orig)

Duplicates a route object.

Returns
The duplicated route

References callback_list_new(), route::cbl2, route::destination_distance, route::flags, route::ms, navit_object_ref(), route_func, and route::vehicleprofile.

Referenced by request_route_dup().

◆ route_extract_segment_from_path()

static struct route_path_segment* route_extract_segment_from_path ( struct route_path path,
struct item item,
int  offset 
)
static

Returns and removes one segment from a path.

Parameters
pathThe path to take the segment from
itemThe item whose segment to remove
offsetOffset of the segment within the item to remove. If the item is not segmented this should be 1.
Returns
The segment removed

References AF_SEGMENTED, item_hash_remove(), item_is_equal, route_path_segment::next, offset, route_path::path, and route_path::path_hash.

Referenced by route_path_add_item_from_graph().

◆ route_find_nearest_street()

◆ route_free_selection()

void route_free_selection ( struct map_selection sel)

Destroys a list of map selections.

Parameters
selStart of the list to be destroyed

References map_selection::next, and next.

Referenced by route_graph_build_done(), traffic_traff_android_destroy(), and traffic_traff_android_set_selection().

◆ route_get_attr()

◆ route_get_coord_dist()

struct coord route_get_coord_dist ( struct route this_,
int  dist 
)

Returns a coordinate at a given distance.

This function returns the coordinate, where the user will be if he follows the current route for a certain distance.

Parameters
this_The route we're driving upon
distThe distance in meters
Returns
The coordinate where the user will be in that distance

References route_info::c, route_path::in_use, item_hash_new(), route_info::lenextra, route_path::path_hash, startup::pos, route_path_add_line(), and route_path::updated.

◆ route_get_destination_count()

int route_get_destination_count ( struct route this)

Get the destinations count for the route.

Parameters
thisThe route instance
Returns
destination count for the route

Referenced by navit_get_destination_count(), navit_remove_nth_waypoint(), navit_remove_waypoint(), navit_set_destination(), and navit_vehicle_update_position().

◆ route_get_destination_description()

char* route_get_destination_description ( struct route this,
int  n 
)

Returns a description for a waypoint as (type or street_name_systematic) + (label or WayID[osm_wayid])

Parameters
thisThe route instance
nThe nth waypoint
Returns
The description

References _, attr_to_text(), item::id_hi, item::id_lo, item, street_data::item, item_attr_get(), item_to_name(), label, item::map, map_rect_destroy(), map_rect_get_item_byid(), map_rect_new(), route_info::street, attr::type, item::type, and type.

Referenced by navit_get_destination_description(), and navit_vehicle_update_position().

◆ route_get_destinations()

int route_get_destinations ( struct route this,
struct pcoord pc,
int  count 
)

Retrieves destinations from the route.

Prior to calling this method, you may want to retrieve the number of destinations by calling route_get_destination_count(struct route *) and assigning a buffer of sufficient capacity.

If the return value equals count, the buffer was either just large enough or too small to hold the entire list of destinations; there is no way to tell from the result which is the case.

Parameters
thisThe route instance
pcPointer to an array of projected coordinates which will receive the destination coordinates
countCapacity of pc
Returns
The number of destinations stored in pc, never greater than count

References route_info::c, pcoord::pro, projection_mg, coord::x, pcoord::x, coord::y, and pcoord::y.

Referenced by navit_get_destinations(), navit_set_destination(), navit_vehicle_update_position(), and route_set_profile().

◆ route_get_distances()

void route_get_distances ( struct route this,
struct coord c,
int  count,
int *  distances 
)

◆ route_get_dst()

struct route_info* route_get_dst ( struct route this)

Returns the destination of the route passed.

Parameters
thisThe route to get the destination for
Returns
The destination of the route passed

Referenced by route_append_destination(), route_get_attr(), route_remove_nth_waypoint(), and route_set_destinations().

◆ route_get_flags()

enum route_path_flags route_get_flags ( struct route this_)

Returns the flags for the route.

References route::graph_map, and route_get_map_helper().

Referenced by navigation_update().

◆ route_get_graph()

struct route_graph* route_get_graph ( struct route this_)

Retrieves the route graph.

Returns
The route graph, or NULL if the route has no valid graph

References route::graph.

◆ route_get_graph_map()

struct map* route_get_graph_map ( struct route this_)

Returns a new map containing the route graph.

This function returns a new map containing the route graph.

@important Do not map_destroy() this!

Parameters
this_The route to get the map of
Returns
A new map containing the route graph

Referenced by navigation_itm_new(), and navit_init().

◆ route_get_map()

struct map* route_get_map ( struct route this_)

Returns a new map containing the route path.

This function returns a new map containing the route path.

@important Do not map_destroy() this!

Parameters
this_The route to get the map of
Returns
A new map containing the route path

References route::map, and route_get_map_helper().

Referenced by gui_internal_cmd2_route_height_profile(), gui_internal_select_waypoint(), navigation_update(), navit_init(), navit_zoom_to_route(), route_get_attr(), route_get_map_py(), and vehicle_demo_timer().

◆ route_get_map_helper()

static struct map* route_get_map_helper ( struct route this_,
struct map **  map,
char *  type,
char *  description 
)
static

◆ route_get_mapset()

struct mapset* route_get_mapset ( struct route this)

Returns the mapset of the route passed.

Parameters
thisThe route to get the mapset of
Returns
The mapset of the route passed

◆ route_get_path_set()

int route_get_path_set ( struct route this)

Checks if the path is calculated for the route passed.

Parameters
thisThe route to check
Returns
True if the path is calculated, false if not

Referenced by navit_check_route().

◆ route_get_pos()

struct route_info* route_get_pos ( struct route this)

Returns the current position within the route passed.

Parameters
thisThe route to get the position for
Returns
The position within the route passed

References startup::pos.

Referenced by traffic_process_messages_int().

◆ route_get_selection()

struct map_selection* route_get_selection ( struct route this_)

◆ route_get_traffic_distortion()

static int route_get_traffic_distortion ( struct route_graph_segment seg,
int  dir,
struct vehicleprofile profile,
struct route_traffic_distortion ret 
)
static

Returns the traffic distortion for a segment.

If multiple traffic distortions match a segment, the return value will report the lowest speed limit and greatest delay of all matching segments.

Parameters
segThe segment for which the traffic distortion is to be returned
dirThe direction of seg for which to return traffic distortions. Positive values indicate travel in the direction of the segment, negative values indicate travel against it.
profileThe current vehicle profile
retPoints to a
A traffic distortion.
Definition: route.c:135
, whose members will be filled with the distortion data
Returns
true if a traffic distortion was found, 0 if not

References AF_SPEED_LIMIT, route_graph_segment::data, dbg, route_traffic_distortion::delay, route_graph_point::end, route_graph_segment::end, route_graph_segment::end_next, route_segment_data::flags, route_segment_data::item, route_segment_data::len, lvl_warning, route_traffic_distortion::maxspeed, profile, RSD_MAXSPEED, route_graph_point::seg, route_graph_point::start, route_graph_segment::start, route_graph_segment::start_next, and item::type.

Referenced by route_value_seg().

◆ route_graph_add_point()

struct route_graph_point* route_graph_add_point ( struct route_graph this,
struct coord f 
)

Inserts a point into the route graph at the specified coordinates.

This will insert a point into the route graph at the coordinates passed in f. Note that the point is not yet linked to any segments.

If the route graph already contains a point at the specified coordinates, the existing point will be returned.

Parameters
thisThe route graph to insert the point into
fThe coordinates at which the point should be inserted
Returns
The point inserted or NULL on failure

References p, route_graph_get_point(), and route_graph_point_new().

Referenced by route_graph_add_street(), route_graph_add_traffic_distortion(), route_graph_add_turn_restriction(), and traffic_location_populate_route_graph().

◆ route_graph_add_segment()

◆ route_graph_add_street()

static void route_graph_add_street ( struct route_graph this,
struct item item,
struct vehicleprofile profile 
)
static

Adds an item to the route graph.

This adds an item (e.g. a street) to the route graph, creating as many segments as needed for a segmented item.

Parameters
thisThe route graph to add to
itemThe item to add
profileThe vehicle profile currently in use

References AF_ALL, AF_DANGEROUS_GOODS, AF_SEGMENTED, AF_SIZE_OR_WEIGHT_LIMIT, AF_SPEED_LIMIT, c, data, dbg_assert, default_flags, item, item_attr_get(), item_attr_rewind(), item_coord_get(), item_coord_is_node(), item_coord_rewind(), item_get_default_flags(), route_graph_segment_data::len, item::map, map_projection(), attr::num, profile, route_graph_add_point(), route_graph_add_segment(), route_graph_segment_is_duplicate(), transform_distance(), item::type, attr::u, and vehicleprofile_get_roadprofile().

Referenced by route_graph_build_idle().

◆ route_graph_add_traffic_distortion()

static void route_graph_add_traffic_distortion ( struct route_graph this,
struct vehicleprofile profile,
struct item item,
int  update 
)
static

Adds a traffic distortion item to the route graph.

If update is true, the end points of the traffic distortion will have their cost recalculated. Set this to true for a partial recalculation of an existing route, false when initially building the route graph.

Parameters
thisThe route graph to add to
profileThe vehicle profile to use for cost calculations
itemThe item to add, must be of
type_traffic_distortion
updateWhether to update the end points

References AF_DISTORTIONMASK, AF_ONEWAY, AF_ONEWAYREV, AF_SPEED_LIMIT, c, data, route_graph_point::flags, item, item_attr_get(), item_attr_rewind(), item_coord_get(), item_coord_rewind(), attr::num, profile, route_graph_add_point(), route_graph_add_segment(), route_graph_point_update(), RP_TRAFFIC_DISTORTION, and attr::u.

Referenced by route_add_traffic_distortion(), route_graph_build_idle(), and route_graph_change_traffic_distortion().

◆ route_graph_add_turn_restriction()

void route_graph_add_turn_restriction ( struct route_graph this,
struct item item 
)

Adds a turn restriction item to the route graph.

Parameters
thisThe route graph to add to
itemThe item to add, must be of type_street_turn_restriction_no or type_street_turn_restriction_only

References c, data, dbg, route_graph_point::flags, item, item_coord_get(), item_coord_rewind(), item_to_name(), lvl_debug, route_graph_add_point(), route_graph_add_segment(), RP_TURN_RESTRICTION, item::type, pcoord::x, and pcoord::y.

Referenced by route_graph_build_idle(), and traffic_location_populate_route_graph().

◆ route_graph_build()

static struct route_graph* route_graph_build ( struct mapset ms,
struct coord c,
int  count,
struct callback done_cb,
int  async,
struct vehicleprofile profile 
)
static

Builds a new route graph from a mapset.

This function builds a new route graph from a map. Please note that this function does not add any routing information to the route graph - this has to be done via the route_graph_flood() function.

Parameters
msThe mapset to build the route graph from
cAn array of coordinates for the current position, waypoints (if any) and destination
countNumber of coordinates in c
done_cbThe callback which will be called when graph is complete
Returns
The new route graph.

References route_graph::busy, c, callback_cast, callback_new_2, dbg, route_graph::done_cb, event_add_idle(), fh_makekeyheap(), route_graph::h, route_graph::heap, route_graph::idle_cb, route_graph::idle_ev, lvl_debug, mapset_open(), profile, route_calc_selection(), route_graph_build_done(), route_graph_build_idle(), route_graph_build_next_map(), and route_graph::sel.

Referenced by route_graph_update().

◆ route_graph_build_done()

void route_graph_build_done ( struct route_graph rg,
int  cancel 
)

Releases all resources needed to build the route graph.

If cancel is false, this function will start processing restrictions and ultimately call the route graph's done_cb callback.

The traffic module will always call this method with cancel set to true, as it does not process restrictions and has no callback. Inside the routing module, cancel will be true if, and only if, navigation has been aborted.

Parameters
rgPoints to the route graph
cancelTrue if the process was aborted before completing, false if it completed normally

References route_graph::busy, callback_call_0, callback_destroy(), dbg, route_graph::done_cb, event_remove_idle(), route_graph::h, route_graph::idle_cb, route_graph::idle_ev, lvl_debug, map_rect_destroy(), mapset_close(), route_graph::mr, route_free_selection(), route_graph_process_restrictions(), and route_graph::sel.

Referenced by route_graph_build(), route_graph_build_idle(), route_graph_destroy(), traffic_location_get_matching_points(), and traffic_location_populate_route_graph().

◆ route_graph_build_idle()

◆ route_graph_build_next_map()

static int route_graph_build_next_map ( struct route_graph rg)
static

◆ route_graph_change_traffic_distortion()

static void route_graph_change_traffic_distortion ( struct route_graph this,
struct vehicleprofile profile,
struct item item 
)
static

Changes a traffic distortion item in the route graph.

Attempting to change an idem which is not in the route graph will add it.

Parameters
thisThe route graph to change
profileThe vehicle profile to use for cost calculations
itemThe item to change, must be of
type_traffic_distortion

References profile, route_graph_add_traffic_distortion(), and route_graph_remove_traffic_distortion().

Referenced by route_change_traffic_distortion().

◆ route_graph_clone_segment()

◆ route_graph_compute_shortest_path()

static void route_graph_compute_shortest_path ( struct route_graph graph,
struct vehicleprofile profile,
struct callback cb 
)
static

Expands (i.e. calculates the costs for) the points on the route graph’s heap.

This calculates the cost for every point on the route graph’s heap, as well as any neighbors affected by the cost change, and sets the next segment.

This is part of a modified LPA* implementation.

Parameters
graphThe route graph
profileThe vehicle profile to use for routing. This determines which ways are passable and how their costs are calculated.
cbThe callback function to call when flooding is complete (can be NULL)

References callback_call_0, route_graph_segment::data, route_graph_point::el, route_graph_point::end, route_graph_segment::end, route_graph_segment::end_next, fh_extractmin(), route_graph::heap, route_segment_data::item, profile, route_graph_point::rhs, route_graph_is_path_computed(), route_graph_point_update(), route_item_first, route_item_last, route_value_seg(), route_graph_point::start, route_graph_segment::start, route_graph_segment::start_next, item::type, and route_graph_point::value.

Referenced by route_graph_update_done(), route_path_new(), route_path_update_done(), route_recalculate_partial(), and route_remove_waypoint().

◆ route_graph_destroy()

static void route_graph_destroy ( struct route_graph this)
static

◆ route_graph_free_points()

void route_graph_free_points ( struct route_graph this)

Frees all the memory used for points in the route graph passed.

Parameters
thisThe route graph to delete all points from

References route_graph_point::hash_next, HASH_SIZE, and next.

Referenced by route_graph_destroy(), and traffic_message_add_segments().

◆ route_graph_free_segments()

void route_graph_free_segments ( struct route_graph this)

Destroys all segments of a route graph.

Parameters
thisThe graph to destroy all segments from

References data, next, route_graph_segment::next, route_segment_data_size(), and size.

Referenced by route_graph_destroy(), and traffic_message_add_segments().

◆ route_graph_get_point()

struct route_graph_point* route_graph_get_point ( struct route_graph this,
struct coord c 
)

Gets the first route_graph_point with the specified coordinates.

Parameters
thisThe route in which to search
cCoordinates to search for
Returns
The point at the specified coordinates or NULL if not found

References c, and route_graph_get_point_next().

Referenced by route_graph_add_point(), route_graph_remove_traffic_distortion(), and traffic_location_get_matching_points().

◆ route_graph_get_point_last()

static struct route_graph_point* route_graph_get_point_last ( struct route_graph this,
struct coord c 
)
static

Gets the last route_graph_point with the specified coordinates.

Parameters
thisThe route in which to search
cCoordinates to search for
Returns
The point at the specified coordinates or NULL if not found

References c, p, pcoord::x, and pcoord::y.

Referenced by rp_get_item().

◆ route_graph_get_point_next()

struct route_graph_point* route_graph_get_point_next ( struct route_graph this,
struct coord c,
struct route_graph_point last 
)

Gets the next route_graph_point with the specified coordinates.

Parameters
thisThe route in which to search
cCoordinates to search for
lastThe last route graph point returned to iterate over multiple points with the same coordinates, or
NULL
to return the first point
Returns
The point at the specified coordinates or NULL if not found

References c, p, pcoord::x, and pcoord::y.

Referenced by route_graph_get_point(), route_graph_get_segment(), route_graph_set_traffic_distortion(), and traffic_location_get_matching_points().

◆ route_graph_get_segment()

static struct route_graph_segment * route_graph_get_segment ( struct route_graph graph,
struct street_data sd,
struct route_graph_segment last 
)
static

Gets the next route_graph_segment belonging to the specified street.

Parameters
graphThe route graph in which to search
sdThe street to search for
lastThe last route graph segment returned to iterate over multiple segments of the same item. If
NULL
, the first matching segment will be returned.
Returns
The route graph segment, or
NULL
if none was found.

References street_data::c, route_graph_segment::data, street_data::item, route_segment_data::item, item_is_equal, route_graph_get_point_next(), route_graph_point::start, route_graph_segment::start, and route_graph_segment::start_next.

Referenced by route_graph_init(), and route_path_new().

◆ route_graph_init()

static void route_graph_init ( struct route_graph this,
struct route_info dst,
struct vehicleprofile profile 
)
static

Initializes potential destination nodes.

This method is normally called after building a fresh route graph, or resetting an existing one. It iterates over all potential destination nodes (i.e. all nodes which are part of the destination’s street) and initializes them: The dst_val and rhs values are set according to their cost to reach the destination.

Parameters
thisThe route graph to initialize
dstThe destination of the route
profileThe vehicle profile to use for routing. This determines which ways are passable and how their costs are calculated.

References route_graph_point::dst_seg, route_graph_point::dst_val, route_graph_point::el, route_graph_segment::end, fh_insertkey(), route_info::percent, profile, route_graph_point::rhs, route_graph_get_segment(), route_value_seg(), route_graph_point::seg, route_graph_segment::start, route_info::street, and route_graph_point::value.

Referenced by route_graph_update_done(), route_path_new(), route_path_update_done(), and route_remove_waypoint().

◆ route_graph_is_path_computed()

static int route_graph_is_path_computed ( struct route_graph this_)
static

Whether cost (re)calculation of route graph points has reached the start point.

This method serves as the exit criterion for cost calculation in our LPA* implementation. When it returns true, it means that calculation of node cost has proceeded far enough to determine the cost of, and cheapest path from, the start point.

The current implementation returns true only when the heap is empty, i.e. all points have been calculated. This is not optimal in terms of efficiency, as the cost of the start point and the cheapest path from there no longer change during the last few cycles. Future versions may report true before the heap is completely empty, as soon as the cost of the start point and the cheapest path are final. However, this needs to be considered for recalculations which happen when the vehicle leaves the cheapest path: right now, any point in the route graph has its final cost and cheapest path, thus no recalculation is needed if the vehicle leaves the cheapest path. In the future, however, a (partial) recalculation may be needed if the vehicle deviates from the cheapest path.

Parameters
this_The route graph
Returns
true if calculation is complete, false if not

References fh_min(), and route_graph::heap.

Referenced by route_graph_compute_shortest_path(), and route_recalculate_partial().

◆ route_graph_map_new()

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

References route_map_new_helper().

Referenced by route_init().

◆ route_graph_point_new()

static struct route_graph_point* route_graph_point_new ( struct route_graph this,
struct coord f 
)
static

Create a new point for the route graph with the specified coordinates.

Parameters
thisThe route to insert the point into
fThe coordinates at which the point should be created
Returns
The point created

References debug_route, p, coord::x, and coord::y.

Referenced by route_graph_add_point(), and route_graph_process_restriction_segment().

◆ route_graph_point_update()

static void route_graph_point_update ( struct vehicleprofile profile,
struct route_graph_point p,
struct fibheap heap 
)
static

Updates the lookahead value of a point in the route graph and updates its heap membership.

This recalculates the lookahead value (the rhs member) of point p, based on the value of each neighbor and the cost to reach that neighbor. If the resulting p->rhs differs from p->value, p is inserted into heap using the lower of the two as its key (if p is already a member of heap, its key is changed accordingly). If the resulting p->rhs is equal to p->value and p is a member of heap, it is removed.

This is part of a modified LPA* implementation.

Parameters
profileThe vehicle profile to use for routing. This determines which ways are passable and how their costs are calculated.
pThe point to evaluate
heapThe heap

References route_graph_segment::data, route_graph_segment::end, route_graph_segment::end_next, fh_delete(), fh_insertkey(), route_segment_data::item, item_is_equal, p, profile, route_value_add(), route_value_seg(), route_graph_point::seg, route_graph_segment::start, route_graph_segment::start_next, and route_graph_point::value.

Referenced by route_graph_add_traffic_distortion(), route_graph_compute_shortest_path(), and route_graph_remove_traffic_distortion().

◆ route_graph_process_restriction_point()

◆ route_graph_process_restriction_segment()

◆ route_graph_process_restrictions()

static void route_graph_process_restrictions ( struct route_graph this)
static

◆ route_graph_remove_traffic_distortion()

static void route_graph_remove_traffic_distortion ( struct route_graph this,
struct vehicleprofile profile,
struct item item 
)
static

Removes a traffic distortion item from the route graph.

Removing a traffic distortion which is not in the graph is a no-op.

Parameters
thisThe route graph to remove from
profileThe vehicle profile to use for cost calculations
itemThe item to remove, must be of
type_traffic_distortion

References c, data, route_graph_segment::data, route_graph_point::end, route_graph_segment::end, route_graph_segment::end_next, route_graph_point::flags, route_segment_data::item, item_coord_get(), item_coord_rewind(), item_is_equal, route_graph_segment::next, profile, route_graph_get_point(), route_graph_point_update(), route_segment_data_size(), RP_TRAFFIC_DISTORTION, size, route_graph_point::start, route_graph_segment::start, route_graph_segment::start_next, and item::type.

Referenced by route_graph_change_traffic_distortion(), and route_remove_traffic_distortion().

◆ route_graph_reset()

static void route_graph_reset ( struct route_graph this)
static

Resets all nodes.

This iterates through all the points in the route graph, resetting them to their initial state. The value (cost to reach the destination via seg) and dst_val (cost to destination if this point is the last in the route) members of each point are reset toINT_MAX, the seg member (cheapest way to destination) is reset to NULL and the el member (pointer to element in Fibonacci heap) is also reset to NULL.

The Fibonacci heap is also cleared. Inconsistencies between el and Fibonacci heap membership are handled gracefully, i.e. el is reset even if it is invalid, and points are removed from the heap regardless of their el value.

After this method returns, the caller should call route_graph_init(struct route_graph *, struct route_info *, struct vehicleprofile *) to initialize potential end points. After that a route can be calculated.

References to elements of the route graph which were obtained prior to calling this function remain valid after it returns.

Parameters
thisThe route graph to reset

References route_graph_point::dst_seg, route_graph_point::dst_val, route_graph_point::el, fh_extractmin(), route_graph_point::hash_next, HASH_SIZE, route_graph_point::rhs, route_graph_point::seg, and route_graph_point::value.

Referenced by route_path_new(), route_path_update_done(), and route_remove_waypoint().

◆ route_graph_segment_is_duplicate()

int route_graph_segment_is_duplicate ( struct route_graph_point start,
struct route_graph_segment_data data 
)

Checks if the route graph already contains a particular segment.

This function compares the item IDs of both segments. If the item is segmented, the segment offset is also compared.

Parameters
startThe starting point of the segment
dataThe data for the segment

References AF_SEGMENTED, data, route_graph_segment::data, route_segment_data::item, item_is_equal, route_graph_point::start, route_graph_segment::start, and route_graph_segment::start_next.

Referenced by route_graph_add_street(), and traffic_location_populate_route_graph().

◆ route_graph_segment_match()

static int route_graph_segment_match ( struct route_graph_segment s1,
struct route_graph_segment s2 
)
static

Whether two route graph segments match.

Two segments match if both start and end at the exact same points. Other points are not considered.

Parameters
s1The first segment
s2The second segment
Returns
true if both segments match, false if not

References route_graph_point::c, route_graph_segment::end, s1, route_graph_segment::start, coord::x, and coord::y.

Referenced by route_graph_set_traffic_distortion(), and route_path_new().

◆ route_graph_set_traffic_distortion()

static void route_graph_set_traffic_distortion ( struct route_graph this,
struct route_graph_segment seg,
int  delay 
)
static

Sets or clears a traffic distortion for a segment.

This sets a delay (setting speed is not supported) or clears an existing traffic distortion. Note that, although setting a speed is not supported, calling this function with a delay of 0 will also clear an existing speed constraint.

Parameters
thisThe route graph
segThe segment to which the traffic distortion applies
delayDelay in tenths of a second, or 0 to clear an existing traffic distortion

References AF_DISTORTIONMASK, route_graph_point::c, data, route_graph_segment::data, route_graph_segment::end, route_graph_point::flags, route_segment_data::flags, item, route_segment_data::item, route_graph_add_segment(), route_graph_get_point_next(), route_graph_segment_match(), RP_TRAFFIC_DISTORTION, route_graph_point::start, route_graph_segment::start, route_graph_segment::start_next, and item::type.

Referenced by route_path_new().

◆ route_graph_update()

static void route_graph_update ( struct route this,
struct callback cb,
int  async 
)
static

Updates the route graph.

This updates the route graph after settings in the route have changed. It also adds routing information afterwards by calling route_graph_flood().

Parameters
thisThe route to update the graph for
cbThe callback function to call when the route graph update is complete (used only in asynchronous mode)
asyncSet to nonzero in order to update the route graph asynchronously

References c, route_info::c, callback_cast, callback_destroy(), callback_new_2, startup::pos, route_graph_build(), route_graph_build_idle(), route_graph_destroy(), route_graph_update_done(), route_set_attr(), and route_status_building_graph.

Referenced by route_path_update_flags().

◆ route_graph_update_done()

static void route_graph_update_done ( struct route this,
struct callback cb 
)
static

◆ route_has_graph()

int route_has_graph ( struct route this_)

Whether the route has a valid graph.

Returns
True if the route has a graph, false if not.

References route::graph.

Referenced by navigation_update_idle(), route_add_traffic_distortion(), route_change_traffic_distortion(), route_recalculate_partial(), and route_remove_traffic_distortion().

◆ route_info_distances()

static void route_info_distances ( struct route_info ri,
enum projection  pro 
)
static

◆ route_info_free()

void route_info_free ( struct route_info inf)

◆ route_info_free_g()

static void route_info_free_g ( struct route_info inf,
void *  unused 
)
static

References route_info_free().

Referenced by route_clear_destinations().

◆ route_info_street()

struct street_data* route_info_street ( struct route_info rinf)

Returns street data for a route info.

Parameters
rinfThe route info to return the street data for
Returns
Street data for the route info

References route_info::street.

◆ route_init()

void route_init ( void  )

References route_graph_map_new(), and route_map_new().

Referenced by main_real().

◆ route_map_new()

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

References route_map_new_helper().

Referenced by route_init().

◆ route_map_new_helper()

static struct map_priv* route_map_new_helper ( struct map_methods meth,
struct attr **  attrs,
int  graph 
)
static

◆ route_new()

struct route* route_new ( struct attr parent,
struct attr **  attrs 
)

Creates a completely new route structure.

Parameters
attrsNot used
Returns
The newly created route

References attr_generic_get_attr(), attr::attrs, callback_list_new(), navit_object_ref(), attr::num, route_func, and attr::u.

◆ route_next_destination()

static struct route_info* route_next_destination ( struct route this)
static

◆ route_path_add_item_from_graph()

static int route_path_add_item_from_graph ( struct route_path this,
struct route_path oldpath,
struct route_graph_segment rgs,
int  dir,
struct route_info pos,
struct route_info dst 
)
static

Inserts a new segment into the path.

This function adds a new segment to the route path. The segment is copied from the route graph. If rgs is part of a segmented item, only rgs will be added to the route path, not the other segments.

The function can be sped up by passing an old path already containing this segment in oldpath - the segment will then be extracted from this old path. Please note that in this case the direction parameter has no effect.

Parameters
thisThe path to add the item to
oldpathOld path containing the segment to be added. Speeds up the function, but can be NULL.
rgsSegment of the route graph that should be "copied" to the route path
dirOrder in which to add the coordinates. See route_path_add_item()
posInformation about start point if this is the first segment
dstInformation about end point if this is the last segment

References AF_ROUNDABOUT, AF_SEGMENTED, c, route_path_segment::c, street_data::c, route_graph_point::c, street_data::count, route_path_segment::data, route_graph_segment::data, dbg, route_path_segment::direction, route_graph_segment::end, route_segment_data::flags, item::id_hi, item::id_lo, route_segment_data::item, item_coord_get_within_range(), item_hash_insert(), item_hash_lookup(), route_segment_data::len, route_info::lenneg, route_info::lenpos, route_info::lp, lvl_debug, route_path_segment::ncoords, route_path_segment::next, offset, route_path::path_hash, startup::pos, route_info::pos, route_check_roundabout(), route_extract_segment_from_path(), route_path_add_segment(), route_segment_data_size(), route_graph_segment::start, route_info::street, coord::x, coord::y, and pcoord::y.

Referenced by route_path_new().

◆ route_path_add_line()

static void route_path_add_line ( struct route_path this,
struct coord start,
struct coord end,
int  len 
)
static

Adds a two coordinate line to a path.

This adds a new line to a path, creating a new segment for it.

Parameters
thisThe path to add the item to
startcoordinate to add to the start of the item. If none should be added, make this NULL.
endcoordinate to add to the end of the item. If none should be added, make this NULL.
lenThe length of the item

References route_path_segment::c, route_path_segment::data, dbg, route_path_segment::direction, route_segment_data::len, lvl_debug, route_path_segment::ncoords, route_path_add_segment(), coord::x, and coord::y.

Referenced by route_get_coord_dist(), and route_path_new().

◆ route_path_add_segment()

static void route_path_add_segment ( struct route_path this,
struct route_path_segment segment 
)
static

Adds a segment and the end of a path.

Parameters
thisThe path to add the segment to
segmentThe segment to add

References route_path_segment::next.

Referenced by route_path_add_item_from_graph(), and route_path_add_line().

◆ route_path_destroy()

static void route_path_destroy ( struct route_path this,
int  recurse 
)
static

◆ route_path_get_distances()

static void route_path_get_distances ( struct route_path path,
struct coord c,
int  count,
int *  distances 
)
static

◆ route_path_new()

static struct route_path * route_path_new ( struct route_graph this,
struct route_path oldpath,
struct route_info pos,
struct route_info dst,
struct vehicleprofile profile 
)
static

Creates a new route path.

This creates a new non-trivial route. It therefore needs the routing information created by route_graph_flood, so make sure to run route_graph_flood() after changing the destination before using this function.

Parameters
thisThe route graph to create the route from
oldpath(Optional) old path which may contain parts of the new part - this speeds things up a bit. May be NULL.
posThe starting position of the route
dstThe destination of the route
preferencesThe routing preferences
Returns
The new route path

References route_info::c, route_graph_segment::data, dbg, route_info::dir, route_graph_point::end, route_graph_segment::end, route_path::in_use, street_data::item, route_segment_data::item, item_hash_new(), item_is_equal, route_info::lenextra, route_info::lp, lvl_debug, lvl_error, map_projection(), route_path::path_hash, startup::pos, profile, route_graph_compute_shortest_path(), route_graph_get_segment(), route_graph_init(), route_graph_reset(), route_graph_segment_match(), route_graph_set_traffic_distortion(), route_path_add_item_from_graph(), route_path_add_line(), route_path_new_offroad(), route_value_seg(), s1, route_graph_point::seg, route_graph_point::start, route_graph_segment::start, route_info::street, transform_distance(), route_path::updated, and route_graph_point::value.

Referenced by route_path_update_done().

◆ route_path_new_offroad()

static struct route_path* route_path_new_offroad ( struct route_graph this,
struct route_info pos,
struct route_info dst 
)
static

Starts an "offroad" path.

This starts a path that is not located on a street. It creates a new route path adding only one segment, that leads from pos to dest, and which is not associated with an item.

Parameters
thisNot used
posThe starting position for the new path
dstThe destination of the new path
dirNot used
Returns
The new path

Referenced by route_path_new().

◆ route_path_update()

static void route_path_update ( struct route this,
int  cancel,
int  async 
)
static

Updates the route graph and the route path if something changed with the route.

This function is a wrapper around route_path_update_flags(route *, enum route_path).

Parameters
thisThe route to update
cancelIf true, cancel navigation, clear route graph and route path
asyncIf true, perform processing asynchronously

References route_path_flag_async, route_path_flag_cancel, and route_path_update_flags().

Referenced by route_append_destination(), route_remove_nth_waypoint(), route_set_destinations(), and route_set_position_from_tracking().

◆ route_path_update_done()

static void route_path_update_done ( struct route this,
int  new_graph 
)
static

Updates or recreates the route graph.

This function is called after the route graph has been changed or rebuilt and flooding has completed. It then updates the route path to reflect these changes.

If multiple destinations are set, this function will reset and re-flood the route graph for each destination, thus recursively calling itself for each destination.

Parameters
thisThe route object
new_graphFIXME Whether the route graph has been rebuilt from scratch

References route_path_segment::data, dbg, route_segment_data::len, lvl_debug, route_path_segment::next, route_path::next, startup::pos, route_graph_compute_shortest_path(), route_graph_init(), route_graph_reset(), route_path_destroy(), route_path_new(), route_previous_destination(), route_set_attr(), route_status_building_path, route_status_not_found, route_status_path_done_incremental, route_status_path_done_new, and route_time_seg().

Referenced by rm_rect_destroy(), route_path_update_flags(), and route_recalculate_partial().

◆ route_path_update_flags()

static void route_path_update_flags ( struct route this,
enum route_path_flags  flags 
)
static

Updates the route graph and the route path if something changed with the route.

This will update the route graph and the route path of the route if some of the route's settings (destination, position) have changed.

The behavior of this function can be controlled via flags:

These flags will be stored in the

flags
Definition: gui_internal.h:26

member of the route object.

Attention
For this to work the route graph has to be destroyed if the route's
destination is changed somewhere!
Parameters
thisThe route to update
flagsFlags to control the behavior of this function, see description

References callback_cast, callback_new_2, dbg, lvl_debug, startup::pos, route_graph_destroy(), route_graph_update(), route_path_destroy(), route_path_flag_async, route_path_flag_cancel, route_path_flag_no_rebuild, and route_path_update_done().

Referenced by route_path_update(), and route_set_position_flags().

◆ route_previous_destination()

static struct route_info* route_previous_destination ( struct route this)
static

Returns the position from which to route to the current destination of the route.

This function examines the destination list of the route. If present, it returns the destination which precedes the one indicated by the

current_dst

member of the route. Failing that, the current position of the route is returned.

Parameters
thisThe route object
Returns
The previous destination or current position, see description

References startup::pos.

Referenced by route_path_update_done().

◆ route_projection()

static enum projection route_projection ( struct route route)
static

Returns the projection used for this route.

Parameters
routeThe route to return the projection for
Returns
The projection used for this route

Referenced by route_destination_reached().

◆ route_recalculate_partial()

void route_recalculate_partial ( struct route this_)

Triggers partial recalculation of the route, based on the existing route graph.

This is currently used when traffic distortions have been added, changed or removed. Future versions may also use it if the current position has changed to a portion of the route graph which has not been flooded (which is currently not necessary because the route graph is always flooded completely).

This tends to be faster than full recalculation, as only a subset of all points in the graph needs to be evaluated.

If segment costs have changed (as is the case with traffic distortions), all affected segments must have been added to, removed from or updated in the route graph before this method is called.

After recalculation, the route path is updated.

The function uses a modified LPA* algorithm for recalculations. Most modifications were made for compatibility with the old routing algorithm:

  • The heuristic is always assumed to be zero (which would turn A* into Dijkstra, formerly the basis of the routing algorithm, and makes our keys one-dimensional)
  • Currently, each pass evaluates all locally inconsistent points, leaving an empty heap at the end (though this may change in the future).
Parameters
this_The route

References route_graph::busy, route::graph, route_graph_compute_shortest_path(), route_graph_is_path_computed(), route_has_graph(), route_path_update_done(), route_set_attr(), route_status_building_graph, attr::type, and route::vehicleprofile.

Referenced by traffic_process_messages_int().

◆ route_rect()

struct map_selection* route_rect ( int  order,
struct coord c1,
struct coord c2,
int  rel,
int  abs 
)

Returns a single map selection.

The boundaries of the selection are determined as follows: First a rectangle spanning c1 and c2 is built (the two coordinates can be any two opposite corners of the rectangle). Then its maximum extension (height or width) is determined and multiplied with the percentage specified by rel. The resulting amount of padding is added to each edge. After that, the amount specified by abs is added to each edge.

Parameters
orderMap order (deepest tile level) to select
c1First coordinate
c2Second coordinate
relRelative padding to add to the selection rectangle, in percent
absAbsolute padding to add to the selection rectangle

References c1, c2, map_selection::c_rect, dbg, coord_rect::lu, lvl_debug, item_range::max, map_selection::next, map_selection::order, map_selection::range, coord_rect::rl, route_item_first, route_item_last, map_selection::u, coord::x, and coord::y.

Referenced by route_find_nearest_street(), route_rect_add(), tracking_doupdate_lines(), and traffic_location_get_rect().

◆ route_rect_add()

static struct map_selection* route_rect_add ( struct map_selection sel,
int  order,
struct coord c1,
struct coord c2,
int  rel,
int  abs 
)
static

Appends a map selection to the selection list. Selection list may be NULL.

References c1, c2, map_selection::next, map_selection::order, and route_rect().

Referenced by route_calc_selection().

◆ route_remove_attr()

int route_remove_attr ( struct route this_,
struct attr attr 
)

◆ route_remove_nth_waypoint()

void route_remove_nth_waypoint ( struct route this,
int  n 
)

Remove the nth waypoint of the route.

Parameters
thisThe route instance
nThe waypoint to remove
Returns
nothing

References route_get_dst(), route_graph_destroy(), route_info_free(), and route_path_update().

Referenced by navit_remove_nth_waypoint().

◆ route_remove_traffic_distortion()

void route_remove_traffic_distortion ( struct route this_,
struct item item 
)

Removes a traffic distortion item from the route.

Removing a traffic distortion which is not in the route graph is a no-op.

Parameters
this_The route
itemThe item to remove, must be of
type_traffic_distortion

References route::graph, route_graph_remove_traffic_distortion(), route_has_graph(), and route::vehicleprofile.

Referenced by tm_item_unref().

◆ route_remove_waypoint()

◆ route_seg_speed()

static int route_seg_speed ( struct vehicleprofile profile,
struct route_segment_data over,
struct route_traffic_distortion dist 
)
static

Returns the estimated speed on a segment, or 0 for an impassable segment.

This function returns the estimated speed to be driven on a segment, calculated as follows:

  • Initially the route weight of the vehicle profile for the given item type is used. If the item type does not have a route weight in the vehicle profile given, it is considered impassable and 0 is returned.
  • If the
    maxspeed
    attribute of the segment's item is set, either it or the previous speed estimate for the segment is used, as governed by the vehicle profile's
    maxspeed_handling
    Definition: vehicleprofile.h:26
    attribute.
  • If a traffic distortion is present, its
    maxspeed
    is taken into account in a similar manner. Unlike the regular
    maxspeed
    , a
    maxspeed
    resulting from a traffic distortion is always considered if it limits the speed, regardless of .
  • Access restrictions for dangerous goods, size or weight are evaluated, and 0 is returned if the given vehicle profile violates one of them.
Parameters
profileThe routing preferences
overThe segment which is passed
distA traffic distortion if applicable, or
NULL
Returns
The estimated speed in km/h, or 0 if the segment is impassable

References AF_DANGEROUS_GOODS, AF_SIZE_OR_WEIGHT_LIMIT, AF_SPEED_LIMIT, size_weight_limit::axle_weight, route_segment_data::flags, size_weight_limit::height, route_segment_data::item, size_weight_limit::length, roadprofile::maxspeed, route_traffic_distortion::maxspeed, maxspeed_enforce, maxspeed_ignore, maxspeed_restrict, profile, roadprofile::route_weight, RSD_MAXSPEED, roadprofile::speed, item::type, vehicleprofile_get_roadprofile(), size_weight_limit::weight, and size_weight_limit::width.

Referenced by rm_attr_get(), route_time_seg(), and rp_attr_get().

◆ route_segment_data_field_pos()

void* route_segment_data_field_pos ( struct route_segment_data seg,
enum attr_type  type 
)

Returns the position of a certain field appended to a route graph segment.

This function returns a pointer to a field that is appended to a route graph segment.

Parameters
segThe route graph segment the field is appended to
typeType of the field that should be returned
Returns
A pointer to a field of a certain type, or NULL if no such field is present

References AF_DANGEROUS_GOODS, AF_SEGMENTED, AF_SIZE_OR_WEIGHT_LIMIT, AF_SPEED_LIMIT, route_segment_data::flags, route_graph_point::seg, and type.

◆ route_segment_data_size()

static int route_segment_data_size ( int  flags)
static

◆ route_set_attr()

◆ route_set_destination()

void route_set_destination ( struct route this,
struct pcoord dst,
int  async 
)

Start a route given set of coordinates.

Parameters
thisThe route instance
dstThe coordinate to start routing to
asyncSet to 1 to do route calculation asynchronously
Returns
nothing

References route_set_destinations().

Referenced by navit_add_former_destinations_from_file(), navit_set_destination(), and route_set_attr().

◆ route_set_destinations()

void route_set_destinations ( struct route this,
struct pcoord dst,
int  count,
int  async 
)

Sets the destination of a route.

This sets the destination of a route to the street nearest to the coordinates passed and updates the route.

Parameters
thisThe route to set the destination for
dstPoints to an array of coordinates to set as destinations, which will be visited in the order in which they appear in the array (the last one is the final destination)
countNumber of items in
dst
, 0 to clear all destinations
asyncIf set, do routing asynchronously

References callback_list_call_attr_1, pcoord::pro, profile, route_clear_destinations(), route_find_nearest_street(), route_get_dst(), route_graph_destroy(), route_info_distances(), route_path_update(), route_set_attr(), route_status_destination_set, and route_status_no_destination.

Referenced by NGQProxyRoute::addDestination(), navit_add_former_destinations_from_file(), navit_set_destinations(), route_append_destination(), route_set_destination(), and route_set_profile().

◆ route_set_mapset()

void route_set_mapset ( struct route this,
struct mapset ms 
)

Sets the mapset of the route passwd.

Parameters
thisThe route to set the mapset for
msThe mapset to set for this route

Referenced by navit_init().

◆ route_set_position()

void route_set_position ( struct route this,
struct pcoord pos 
)

This sets the current position of the route passed.

This will set the current position of the route passed to the street that is nearest to the passed coordinates. It also automatically updates the route.

Parameters
thisThe route to set the position of
posCoordinates to set as position

References startup::pos, route_path_flag_async, and route_set_position_flags().

Referenced by navit_set_position(), navit_vehicle_update_position(), and route_set_attr().

◆ route_set_position_flags()

static int route_set_position_flags ( struct route this,
struct pcoord pos,
enum route_path_flags  flags 
)
static

This sets the current position of the route passed.

This will set the current position of the route passed to the street that is nearest to the passed coordinates. It also automatically updates the route.

Parameters
thisThe route to set the position of
posCoordinates to set as position
flagsFlags to use for building the graph

References dbg, lvl_debug, startup::pos, route_find_nearest_street(), route_info_distances(), route_info_free(), and route_path_update_flags().

Referenced by route_set_attr(), and route_set_position().

◆ route_set_position_from_tracking()

void route_set_position_from_tracking ( struct route this,
struct tracking tracking,
enum projection  pro 
)

◆ route_set_profile()

void route_set_profile ( struct route this,
struct vehicleprofile prof 
)

Sets the vehicle profile of a route.

Parameters
thisThe route to set the profile for
profThe vehicle profile

References route_get_destinations(), and route_set_destinations().

Referenced by navit_set_vehicle(), and navit_set_vehicleprofile().

◆ route_set_projection()

void route_set_projection ( struct route this_,
enum projection  pro 
)

Referenced by navit_init().

◆ route_through_traffic_allowed()

static int route_through_traffic_allowed ( struct vehicleprofile profile,
struct route_graph_segment seg 
)
static

◆ route_time_seg()

static int route_time_seg ( struct vehicleprofile profile,
struct route_segment_data over,
struct route_traffic_distortion dist 
)
static

Returns the time needed to travel along a segment, or.

INT_MAX

if the segment is impassable.

This function returns the time needed to travel along the entire length of

over

in tenths of seconds. Restrictions for dangerous goods, weight or size are taken into account. Traffic distortions are also taken into account if a valid

dist

argument is given.

Parameters
profileThe vehicle profile (routing preferences)
overThe segment which is passed
distA traffic distortion if applicable, or
NULL
Returns
The time needed in tenths of seconds

References route_traffic_distortion::delay, route_segment_data::len, profile, and route_seg_speed().

Referenced by rm_attr_get(), route_path_update_done(), route_value_seg(), and rp_attr_get().

◆ route_value_add()

static int route_value_add ( int  val1,
int  val2 
)
static

Adds two route values with protection against integer overflows.

Unlike regular addition, this function is safe to use if one of the two arguments is INT_MAX (which Navit uses to express that a segment cannot be traversed or a point cannot be reached): If any of the two arguments is INT_MAX, then INT_MAX is returned; else the sum of the two arguments is returned.

Note that this currently does not cover cases in which both arguments are less than INT_MAX but add up to val1 + val2 >= INT_MAX. With Navit’s internal cost definition, INT_MAX (2^31) is equivalent to approximately 7 years, making this unlikely to become a real issue.

Referenced by route_graph_point_update().

◆ route_value_seg()

static int route_value_seg ( struct vehicleprofile profile,
struct route_graph_point from,
struct route_graph_segment over,
int  dir 
)
static

Returns the "cost" of traveling along segment over in direction dir

Cost is relative to time, indicated in tenths of seconds.

This function considers traffic distortions as well as penalties. If the segment is impassable due to traffic distortions or restrictions, INT_MAX is returned in order to prevent use of this segment for routing.

If from is specified, it must be the point at which we leave the segment (over->end if dir is positive, over->start if dir is negative); anything else will produce invalid results. If from is non-NULL, additional checks are done on from->seg (the next segment to follow after over):

  • If from->seg equals over (indicating that, after traversing over in direction dir, we would immediately traverse it again in the opposite direction), INT_MAX is returned.
  • If over loops back to itself (i.e. its start and end members are equal), INT_MAX is returned.
  • Otherwise, if over does not allow through traffic but from->seg does, the through traffic penalty of the vehicle profile (profile) is applied.
Parameters
profileThe routing preferences
fromThe point currently being visited (or NULL), see description
overThe segment we are using
dirThe direction of segment which we are traveling. Positive values indicate we are traveling in the direction of the segment (from over->start to over->end), negative values indicate we are traveling in the opposite direction. Values of +2 or -2 cause the function to ignore traffic distortions.
Returns
The "cost" needed to travel along the segment

References route_graph_segment::data, dbg, route_graph_segment::end, route_graph_point::flags, route_segment_data::flags, route_segment_data::item, lvl_warning, profile, route_get_traffic_distortion(), route_through_traffic_allowed(), route_time_seg(), RP_TRAFFIC_DISTORTION, RP_TURN_RESTRICTION, route_graph_point::seg, route_graph_segment::start, and item::type.

Referenced by route_graph_compute_shortest_path(), route_graph_init(), route_graph_point_update(), and route_path_new().

◆ rp_attr_get()

◆ rp_attr_rewind()

static void rp_attr_rewind ( void *  priv_data)
static

References map_rect_priv::attr_next.

Referenced by rp_get_item().

◆ rp_coord_get()

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

Returns the coordinates of a route graph item.

Parameters
priv_dataThe route graph item's private data
cPointer where to store the coordinates
countHow many coordinates to get at a max?
Returns
The number of coordinates retrieved

◆ rp_destroy()

static void rp_destroy ( struct map_priv priv)
static

◆ rp_get_item()

◆ rp_get_item_byid()

static struct item* rp_get_item_byid ( struct map_rect_priv mr,
int  id_hi,
int  id_lo 
)
static

References item::id_lo, and rp_get_item().

◆ rp_iterator_end()

static int rp_iterator_end ( struct route_graph_point_iterator it)
static

Checks if the last segment returned from a route_graph_point_iterator comes from the end.

Parameters
itThe route graph point iterator to be checked
Returns
1 if the last segment returned comes from the end of the route graph point, 0 otherwise

References route_graph_point_iterator::end, route_graph_point::end, route_graph_point_iterator::next, and route_graph_point_iterator::p.

Referenced by route_check_roundabout().

◆ rp_iterator_new()

static struct route_graph_point_iterator rp_iterator_new ( struct route_graph_point p)
static

Creates a new graph point iterator.

This function creates a new route graph point iterator, that can be used to iterate through all segments connected to the point.

Parameters
pThe route graph point to create the iterator from
Returns
A new iterator.

Referenced by route_check_roundabout(), and rp_get_item().

◆ rp_iterator_next()

static struct route_graph_segment* rp_iterator_next ( struct route_graph_point_iterator it)
static

Gets the next segment connected to a route graph point from an iterator.

Parameters
itThe route graph point iterator to get the segment from
Returns
The next segment or NULL if there are no more segments

References route_graph_point_iterator::end, route_graph_point::end, route_graph_segment::end_next, route_graph_point_iterator::next, route_graph_point_iterator::p, and route_graph_segment::start_next.

Referenced by route_check_roundabout(), and rp_get_item().

◆ rp_rect_new()

static struct map_rect_priv* rp_rect_new ( struct map_priv priv,
struct map_selection sel 
)
static

Opens a new map rectangle on the route graph's map.

This function opens a new map rectangle on the route graph's map. The "sel" parameter enables you to only search for a single route graph point on this map (or exactly: open a map rectangle that only contains this one point). To do this, pass here a single map selection, whose c_rect has both coordinates set to the same point. Otherwise this parameter has no effect.

Parameters
privThe route graph map's private data
selHere it's possible to specify a point for which to search. Please read the function's description.
Returns
A new map rect's private data

References map_selection::c_rect, map_rect_priv::coord_sel, dbg, route::graph, map_rect_priv::item, coord_rect::lu, lvl_debug, item::meth, methods_point_item, map_rect_priv::mpriv, item::priv_data, coord_rect::rl, map_priv::route, map_rect_priv::sel, item::type, map_selection::u, coord::x, and coord::y.

◆ street_data_dup()

struct street_data* street_data_dup ( struct street_data orig)

Copies street data.

Parameters
origThe street data to copy
Returns
The copied street data

References street_data::count, and size.

Referenced by route_set_position_from_tracking().

◆ street_data_free()

◆ street_get_data()

struct street_data* street_get_data ( struct item item)

Gets street data for an item.

Parameters
itemThe item to get the data for
Returns
Street data for the item

References AF_SPEED_LIMIT, c, street_data::c, street_data::count, street_data::flags, item, street_data::item, item_attr_get(), item_coord_get(), item_get_default_flags(), street_data::maxspeed, attr::num, item::type, and attr::u.

Referenced by route_find_nearest_street().

Variable Documentation

◆ debug_route

int debug_route =0

◆ methods_point_item

struct item_methods methods_point_item
static
Initial value:
= {
}
static int rp_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
Definition: route.c:3624
static void rp_attr_rewind(void *priv_data)
Definition: route.c:3619
static void rm_coord_rewind(void *priv_data)
Definition: route.c:3475
static int rp_coord_get(void *priv_data, struct coord *c, int count)
Returns the coordinates of a route graph item.
Definition: route.c:3759

Referenced by rp_rect_new().

◆ methods_route_item

struct item_methods methods_route_item
static
Initial value:
= {
}
static void rm_attr_rewind(void *priv_data)
Definition: route.c:3480
static int rm_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
Definition: route.c:3485
static int rm_coord_get(void *priv_data, struct coord *c, int count)
Definition: route.c:3571

Referenced by rm_rect_new().

◆ route_func

struct object_func route_func
Initial value:
= {
attr_route,
}
struct route * route_new(struct attr *parent, struct attr **attrs)
Creates a completely new route structure.
Definition: route.c:413
int route_remove_attr(struct route *this_, struct attr *attr)
Definition: route.c:4262
int route_set_attr(struct route *this_, struct attr *attr)
Definition: route.c:4212
struct route * route_dup(struct route *orig)
Duplicates a route object.
Definition: route.c:437
int route_get_attr(struct route *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Definition: route.c:4276
int route_add_attr(struct route *this_, struct attr *attr)
Definition: route.c:4252
void route_destroy(struct route *this_)
Definition: route.c:4364
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 object_func_lookup(), route_dup(), and route_new().

◆ route_graph_meth

struct map_methods route_graph_meth
static
Initial value:
= {
"utf-8",
NULL,
NULL,
NULL,
}
@ projection_mg
Definition: projection.h:25
static void rm_rect_destroy(struct map_rect_priv *mr)
Definition: route.c:3872
static struct item * rp_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo)
Definition: route.c:3955
static void rp_destroy(struct map_priv *priv)
Definition: route.c:3813
static struct map_rect_priv * rp_rect_new(struct map_priv *priv, struct map_selection *sel)
Opens a new map rectangle on the route graph's map.
Definition: route.c:3852
static struct item * rp_get_item(struct map_rect_priv *mr)
Definition: route.c:3890

Referenced by route_map_new_helper().

◆ route_meth

struct map_methods route_meth
static
Initial value:
= {
"utf-8",
NULL,
NULL,
NULL,
}
static struct map_rect_priv * rm_rect_new(struct map_priv *priv, struct map_selection *sel)
Definition: route.c:3821
static void rm_destroy(struct map_priv *priv)
Definition: route.c:3817
static struct item * rm_get_item_byid(struct map_rect_priv *mr, int id_hi, int id_lo)
Definition: route.c:4030
static struct item * rm_get_item(struct map_rect_priv *mr)
Definition: route.c:3963

Referenced by route_map_new_helper().

◆ route_selection

struct map_selection* route_selection

FIXME

Parameters
<>
Returns
<>
Author
Martin Schaller (04/2008)

Referenced by do_draw().