"Fossies" - the Fresh Open Source Software Archive

Member "navit-0.5.6/navit/route_protected.h" (6 Mar 2021, 9967 Bytes) of package /linux/privat/navit-0.5.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "route_protected.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 0.5.5_vs_0.5.6.

    1 /**
    2  * Navit, a modular navigation system.
    3  * Copyright (C) 2005-2008 Navit Team
    4  *
    5  * This program is free software; you can redistribute it and/or
    6  * modify it under the terms of the GNU Library General Public License
    7  * version 2 as published by the Free Software Foundation.
    8  *
    9  * This program is distributed in the hope that it will be useful,
   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12  * GNU Library General Public License for more details.
   13  *
   14  * You should have received a copy of the GNU Library General Public
   15  * License along with this program; if not, write to the
   16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   17  * Boston, MA  02110-1301, USA.
   18  */
   19 
   20 /**
   21  * @file route_private.h
   22  *
   23  * @brief Contains protected exports for route.c
   24  *
   25  * This file contains code that is exported by route.c. Unlike the exports in route.h, exports in this
   26  * file are intended only for use by modules which are closely related to routing. They are not part of
   27  * the public route API.
   28  */
   29 
   30 #ifndef NAVIT_ROUTE_PROTECTED_H
   31 #define NAVIT_ROUTE_PROTECTED_H
   32 
   33 #ifdef __cplusplus
   34 extern "C" {
   35 #endif
   36 
   37 
   38 #define RP_TRAFFIC_DISTORTION 1
   39 #define RP_TURN_RESTRICTION 2
   40 #define RP_TURN_RESTRICTION_RESOLVED 4
   41 
   42 #define RSD_MAXSPEED(x) *((int *)route_segment_data_field_pos((x), attr_maxspeed))
   43 
   44 /**
   45  * @brief A point in the route graph
   46  *
   47  * This represents a point in the route graph. A point usually connects two or more segments,
   48  * but there are also points which don't do that (e.g. at the end of a dead-end).
   49  */
   50 struct route_graph_point {
   51     struct route_graph_point *hash_next; /**< Pointer to a chained hashlist of all route_graph_points with this hash */
   52     struct route_graph_segment *start;   /**< Pointer to a list of segments of which this point is the start. The links
   53                                           *  of this linked-list are in route_graph_segment->start_next.*/
   54     struct route_graph_segment *end;     /**< Pointer to a list of segments of which this pointer is the end. The links
   55                                           *  of this linked-list are in route_graph_segment->end_next. */
   56     struct route_graph_segment *seg;     /**< Pointer to the segment one should use to reach the destination at
   57                                           *  least costs */
   58     struct fibheap_el *el;               /**< When this point is put on a Fibonacci heap, this is a pointer
   59                                           *  to this point's heap element */
   60     int value;                           /**< The cost at which one can reach the destination from this point on.
   61                                           *  {@code INT_MAX} indicates that the destination is unreachable from this
   62                                           *  point, or that this point has not yet been examined. */
   63     int rhs;                             /**< Lookahead value based on neighbors’ `value`; used for recalculation and
   64                                           *   equal to `value` after the route graph has been flooded. */
   65     int dst_val;                         /**< For points close to the destination, this is the cost of the point if it
   66                                           *   is the last in the graph; `INT_MAX` for all other points. */
   67     struct route_graph_segment *dst_seg; /**< For points close to the destination, this is the segment over which the
   68                                           * destination can be reached directly */
   69     struct coord c;                      /**< Coordinates of this point */
   70     int flags;                           /**< Flags for this point (e.g. traffic distortion) */
   71 };
   72 
   73 /**
   74  * @brief A segment in the route graph or path
   75  *
   76  * This is a segment in the route graph or path. A segment represents a driveable way.
   77  */
   78 struct route_segment_data {
   79     struct item item;                    /**< The item (e.g. street) that this segment represents. */
   80     int flags;                           /**< Flags e.g. for access, restrictions, segmentation or roundabouts. */
   81     int len;                             /**< Length of this segment, in meters */
   82     int score;                           /**< Used by the traffic module to give preference to some
   83                                           *   segments over others */
   84     /*NOTE: After a segment, various fields may follow, depending on what flags are set. Order of fields:
   85                 1.) maxspeed            Maximum allowed speed on this segment. Present if AF_SPEED_LIMIT is set.
   86                 2.) offset              If the item is segmented (i.e. represented by more than one segment), this
   87                                         indicates the position of this segment in the item. Present if AF_SEGMENTED is set.
   88      */
   89 };
   90 
   91 /**
   92  * @brief Size and weight limits for a route segment
   93  */
   94 struct size_weight_limit {
   95     int width;
   96     int length;
   97     int height;
   98     int weight;
   99     int axle_weight;
  100 };
  101 
  102 /**
  103  * @brief Data for a segment in the route graph
  104  */
  105 struct route_graph_segment_data {
  106     struct item *item;                    /**< The item which this segment is part of */
  107     int offset;                           /**< If the item passed in "item" is segmented (i.e. divided
  108                                            *   into several segments), this indicates the position of
  109                                            *   this segment within the item */
  110     int flags;                            /**< Flags for this segment */
  111     int len;                              /**< The length of this segment */
  112     int maxspeed;                         /**< The maximum speed allowed on this segment in km/h,
  113                                            *   -1 if not known */
  114     struct size_weight_limit size_weight; /**< Size and weight limits for this segment */
  115     int dangerous_goods;
  116     int score;                            /**< Used by the traffic module to give preference to some
  117                                            *   segments over others */
  118 };
  119 
  120 /**
  121  * @brief A segment in the route graph
  122  *
  123  * This is a segment in the route graph. A segment represents a driveable way.
  124  */
  125 struct route_graph_segment {
  126     struct route_graph_segment *next;       /**< Linked-list pointer to a list of all route_graph_segments */
  127     struct route_graph_segment *start_next; /**< Pointer to the next element in the list of segments that start at the
  128                                              *  same point. Start of this list is in route_graph_point->start. */
  129     struct route_graph_segment *end_next;   /**< Pointer to the next element in the list of segments that end at the
  130                                              *  same point. Start of this list is in route_graph_point->end. */
  131     struct route_graph_point *start;        /**< Pointer to the point this segment starts at. */
  132     struct route_graph_point *end;          /**< Pointer to the point this segment ends at. */
  133     struct route_segment_data data;         /**< The segment data */
  134 };
  135 
  136 /**
  137  * @brief A complete route graph
  138  *
  139  * The route graph holds all routable segments along with the connections between them and the cost of
  140  * each segment.
  141  */
  142 struct route_graph {
  143     int busy;                                   /**< Route calculation is in progress: the graph is being built,
  144                                                  *   flooded or the path is being built (a more detailed status can be
  145                                                  *   obtained from the route’s status attribute) */
  146     struct map_selection *sel;                  /**< The rectangle selection for the graph */
  147     struct mapset_handle *h;                    /**< Handle to the mapset */
  148     struct map *m;                              /**< Pointer to the currently active map */
  149     struct map_rect *mr;                        /**< Pointer to the currently active map rectangle */
  150     struct vehicleprofile *vehicleprofile;      /**< The vehicle profile */
  151     struct callback *idle_cb;                   /**< Idle callback to process the graph */
  152     struct callback *done_cb;                   /**< Callback when graph is done */
  153     struct event_idle *idle_ev;                 /**< The pointer to the idle event */
  154     struct route_graph_segment *route_segments; /**< Pointer to the first route_graph_segment in the linked list of all segments */
  155     struct route_graph_segment *avoid_seg;      /**< Segment to which a turnaround penalty (if active) applies */
  156     struct fibheap *heap;                       /**< Priority queue for points to be expanded */
  157 #define HASH_SIZE 8192
  158     struct route_graph_point *hash[HASH_SIZE];  /**< A hashtable containing all route_graph_points in this graph */
  159 };
  160 
  161 
  162 /* prototypes */
  163 struct route_graph * route_get_graph(struct route *this_);
  164 struct map_selection * route_get_selection(struct route * this_);
  165 void route_free_selection(struct map_selection *sel);
  166 void route_add_traffic_distortion(struct route *this_, struct item *item);
  167 void route_remove_traffic_distortion(struct route *this_, struct item *item);
  168 void route_change_traffic_distortion(struct route *this_, struct item *item);
  169 struct route_graph_point * route_graph_add_point(struct route_graph *this, struct coord *f);
  170 void route_graph_add_turn_restriction(struct route_graph *this, struct item *item);
  171 void route_graph_free_points(struct route_graph *this);
  172 struct route_graph_point *route_graph_get_point(struct route_graph *this, struct coord *c);
  173 struct route_graph_point *route_graph_get_point_next(struct route_graph *this, struct coord *c,
  174         struct route_graph_point *last);
  175 void route_graph_add_segment(struct route_graph *this, struct route_graph_point *start,
  176         struct route_graph_point *end, struct route_graph_segment_data *data);
  177 int route_graph_segment_is_duplicate(struct route_graph_point *start, struct route_graph_segment_data *data);
  178 void route_graph_free_segments(struct route_graph *this);
  179 void route_graph_build_done(struct route_graph *rg, int cancel);
  180 void route_recalculate_partial(struct route *this_);
  181 void * route_segment_data_field_pos(struct route_segment_data *seg, enum attr_type type);
  182 /* end of prototypes */
  183 #ifdef __cplusplus
  184 }
  185 #endif
  186 
  187 #endif
  188