Skip to content

Commit

Permalink
Merge pull request #822 from navit-gps/traffic
Browse files Browse the repository at this point in the history
traffic:Improve startup performance
  • Loading branch information
mvglasow committed Aug 20, 2019
2 parents e7a70e9 + 75c5b11 commit 7ecccd4
Show file tree
Hide file tree
Showing 10 changed files with 848 additions and 153 deletions.
2 changes: 1 addition & 1 deletion docs/binfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ An object 'fits' inside of a tile if the coordinates of the object (min lat, min

Any object that cross the equator or the poles is placed in the top-most tile because it can not fit inside of any sub-tile.

Some important objects are placed into upper level tiles despite of their length to be easier reachable for routing or display purposes. This is done by specifying maximum tile name length for them in phase34_process_file() function in `navit/maptool/misc.c`__.
Some important objects are placed into upper level tiles despite of their length to be easier reachable for routing or display purposes. This is done by specifying maximum tile name length for them in item_order_by_type() function in `navit/maptool/misc.c`__.

BTW, "order" (zoom level) values used to query map and referred in <itemgra> and route_depth are equal to (tile_name_length-4).

Expand Down
23 changes: 23 additions & 0 deletions navit/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,29 @@ attr_list_dup(struct attr **attrs) {
return ret;
}

/**
* @brief Retrieves an attribute from a line in textfile format.
*
* If `name` is NULL, this function returns the first attribute found; otherwise it looks for an attribute
* named `name`.
*
* If `pos` is specified, it acts as an offset pointer: Any data in `line` before `*pos` will be skipped.
* When the function returns, the value pointed to by `pos` will be incremented by the number of characters
* parsed. This can be used to iteratively retrieve all attributes: declare a local variable, set it to zero,
* then iteratively call this function with a pointer to the same variable until it returns false.
*
* `val_ret` must be allocated (and later freed) by the caller, and have sufficient capacity to hold the
* parsed value including the terminating NULL character. The minimum safe size is
* `strlen(line) - strlen(name) - *pos` (assuming zero for NULL pointers).
*
* @param line The line to parse
* @param name The name of the attribute to retrieve; if NULL,
* @param pos Offset pointer, see description
* @param val_ret Points to a buffer which will receive the value as text
* @param name_ret Points to a buffer which will receive the name of the attribute parsed, can be NULL
*
* @return true if successful, false in case of failure
*/
int attr_from_line(char *line, char *name, int *pos, char *val_ret, char *name_ret) {
int len=0,quoted;
char *p,*e,*n;
Expand Down
1 change: 1 addition & 0 deletions navit/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ struct attr {
struct osd *osd;
struct range range;
struct navit_object *navit_object;
struct traffic *traffic;
int *dash;
enum item_type *item_types;
enum attr_type *attr_types;
Expand Down
8 changes: 8 additions & 0 deletions navit/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,14 @@ map_rect_get_item(struct map_rect *mr) {
/**
* @brief Returns the item specified by the ID
*
* Map drivers may or may not allow multiple items with identical IDs. This function is not guaranteed to be
* suitable for iterating over multiple items with identical IDs in the same manner as `map_rect_get_item()`,
* as multiple subsequent calls may return items which were already returned by earlier calls.
*
* If you are working with maps which allow multiple items with identical IDs, the only portable way to
* iterate over all items with a given ID is to use `map_rect_get_item()` and skip all items with
* non-matching IDs.
*
* @param mr The map rect to search for the item
* @param id_hi High part of the ID to be found
* @param id_lo Low part of the ID to be found
Expand Down
14 changes: 11 additions & 3 deletions navit/mapset.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,19 @@ mapset_open(struct mapset *ms) {
/**
* @brief Gets the next map from a mapset handle
*
* If you set active to true, this function will not return any maps that
* have the attr_active attribute associated with them and set to false.
* The `active` argument governs whether (and how) to limit the search to active maps:
*
* Passing 0 causes this function to cycle through all maps, whether active or not.
*
* Passing a value of 2 will return only maps which have the `attr_route_active` attribute set to true.
*
* Passing a value of 3 will return only maps which have the `attr_search_active` attribute set to true.
*
* Passing any other nonzero value will return only maps which have the `attr_active` attribute set to true,
* or not set at all.
*
* @param msh The mapset handle to get the next map of
* @param active Set to true to only get active maps (See description)
* @param active Whether to cycle only through active maps (see description)
* @return The next map
*/
struct map * mapset_next(struct mapset_handle *msh, int active) {
Expand Down
3 changes: 1 addition & 2 deletions navit/osd/core/osd_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2733,8 +2733,7 @@ static void osd_speed_warner_click(struct osd_priv_common *opc, struct navit *na
if (navit_ignore_button(nav))
return;
opc->osd_item.pressed=pressed;
if (pressed)
{
if (pressed) {
this->active = !this->active;
osd_speed_warner_draw(opc, nav, NULL);
}
Expand Down
18 changes: 18 additions & 0 deletions navit/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,24 @@ static struct map_selection *route_calc_selection(struct coord *c, int count, st
return ret;
}

/**
* @brief Retrieves the map selection for the route.
*/
struct map_selection * route_get_selection(struct route * this_) {
struct coord *c = g_alloca(sizeof(struct coord) * (1 + g_list_length(this_->destinations)));
int i = 0;
GList *tmp;

c[i++] = this_->pos->c;
tmp = this_->destinations;
while (tmp) {
struct route_info *dst = tmp->data;
c[i++] = dst->c;
tmp = g_list_next(tmp);
}
return route_calc_selection(c, i, this_->vehicleprofile);
}

/**
* @brief Destroys a list of map selections
*
Expand Down
1 change: 1 addition & 0 deletions navit/route_protected.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ struct route_graph {

/* prototypes */
struct route_graph * route_get_graph(struct route *this_);
struct map_selection * route_get_selection(struct route * this_);
void route_add_traffic_distortion(struct route *this_, struct item *item);
void route_remove_traffic_distortion(struct route *this_, struct item *item);
void route_change_traffic_distortion(struct route *this_, struct item *item);
Expand Down

0 comments on commit 7ecccd4

Please sign in to comment.