diff options
author | mvglasow <mvglasow@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2014-11-22 15:50:40 +0000 |
---|---|---|
committer | mvglasow <mvglasow@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2014-11-22 15:50:40 +0000 |
commit | a35dc59a3e78e60539f205af72ea7f8eba4f96d9 (patch) | |
tree | 9352b5f64827c7d1bf58f20ff0ab7d5a7aa4ca73 /navit/navit.c | |
parent | 4a1f7ccd21c7b75a21260b13cbf23e7f0879e9e3 (diff) | |
download | navit-svn-a35dc59a3e78e60539f205af72ea7f8eba4f96d9.tar.gz |
Fix:core:Don't set map to invalid coordinates
Signed-off-by: mvglasow <michael -at- vonglasow.com>
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5956 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/navit.c')
-rw-r--r-- | navit/navit.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/navit/navit.c b/navit/navit.c index 5a58ba63..9917b585 100644 --- a/navit/navit.c +++ b/navit/navit.c @@ -2344,12 +2344,29 @@ navit_get_cursor_pnt(struct navit *this_, struct point *p, int keep_orientation, return 1; } +/** + * @brief Recalculates the map view so that the vehicle cursor is visible + * + * This function recalculates the parameters which control the visible map area, zoom and orientation. The + * caller is responsible for redrawing the map after the function returns. + * + * If the vehicle supplies a {@code position_valid} attribute and it is {@code attr_position_valid_invalid}, + * the map position is not changed. + * + * @param this_ The navit object + * @param autozoom Whether to set zoom based on current speed. If false, current zoom will be maintained. + * @param keep_orientation Whether to maintain the current map orientation. If false, the map will be rotated + * so that the bearing of the vehicle is up. + */ void navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation) { int dir; struct point pn; struct navit_vehicle *nv=this_->vehicle; + struct attr attr; + if (vehicle_get_attr(nv->vehicle, attr_position_valid, &attr, NULL) && (attr.u.num == attr_position_valid_invalid)) + return; navit_get_cursor_pnt(this_, &pn, keep_orientation, &dir); transform_set_yaw(this_->trans, dir); navit_set_center_coord_screen(this_, &nv->coord, &pn, 0); @@ -2357,6 +2374,14 @@ navit_set_center_cursor(struct navit *this_, int autozoom, int keep_orientation) navit_autozoom(this_, &nv->coord, nv->speed, 0); } +/** + * @brief Recenters the map so that the vehicle cursor is visible + * + * This function first calls {@code navit_set_center_cursor()} to recalculate the map display, then + * triggers a redraw of the map. + * + *@param this_ The navit object + */ static void navit_set_center_cursor_draw(struct navit *this_) { @@ -2365,6 +2390,14 @@ navit_set_center_cursor_draw(struct navit *this_) navit_draw_async(this_, 1); } +/** + * @brief Recenters the map so that the vehicle cursor is visible + * + * This is the callback function for the {@code set_center_cursor()} command. It is just a wrapper around + * {@code navit_set_center_cursor_draw()}. + * + *@param this_ The navit object + */ static void navit_cmd_set_center_cursor(struct navit *this_) { |