navit  0.5.3-trunk
route.h File Reference

Contains exported code for route.c. More...

Go to the source code of this file.

Data Structures

struct  route_crossing
 
struct  route_crossings
 
struct  street_data
 Information about a street. More...
 

Enumerations

enum  route_path_flags { route_path_flag_none =0 , route_path_flag_cancel =1 , route_path_flag_async =2 , route_path_flag_no_rebuild =4 }
 
enum  route_status {
  route_status_no_destination =0 , route_status_destination_set =1 , route_status_not_found =1|2 , route_status_building_path =1|4 ,
  route_status_building_graph =1|4|8 , route_status_path_done_new =1|16 , route_status_path_done_incremental =1|32
}
 

Functions

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...
 
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...
 
int route_destination_reached (struct route *this_)
 Checks if a route has reached its destination. 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...
 
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...
 
void route_get_distances (struct route *this_, struct coord *c, int count, int *distances)
 
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_)
 
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...
 
struct coord route_get_coord_dist (struct route *this_, int dist)
 Returns a coordinate at a given distance. More...
 
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...
 
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...
 
int route_has_graph (struct route *this_)
 Whether the route has a valid graph. 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)
 
struct attr_iterroute_attr_iter_new (void)
 
void route_attr_iter_destroy (struct attr_iter *iter)
 
int route_get_attr (struct route *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
 
void route_init (void)
 
void route_destroy (struct route *this_)
 

Detailed Description

Contains exported code for route.c.

Navit, a modular navigation system. Copyright (C) 2005-2008 Navit Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

This file contains code that works together with route.c and that is exported to other modules.

Enumeration Type Documentation

◆ route_path_flags

Enumerator
route_path_flag_none 
route_path_flag_cancel 
route_path_flag_async 
route_path_flag_no_rebuild 

◆ route_status

Enumerator
route_status_no_destination 
route_status_destination_set 
route_status_not_found 
route_status_building_path 
route_status_building_graph 
route_status_path_done_new 
route_status_path_done_incremental 

Function Documentation

◆ route_add_attr()

int route_add_attr ( struct route this_,
struct attr attr 
)

◆ 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_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_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_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_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_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_free()

void route_info_free ( struct route_info inf)

◆ 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_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_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_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_waypoint()

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

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