From b4fae5572e32039fc1e4a0d95bc5fb1719005f56 Mon Sep 17 00:00:00 2001 From: gnuite Date: Mon, 10 Mar 2008 01:14:51 +0000 Subject: [PATCH] =?utf8?q?Added=20"Map=20Correction"=20feature,=20to=20add?= =?utf8?q?ress=20the=20rare=20problem=20of=20inaccurate=20road=20data=20pr?= =?utf8?q?ovided=20by=20some=20map=20repositories=20in=20some=20locations?= =?utf8?q?=20(like=20Brazil=20and=20Qu=C3=A9bec).=20=20Please=20read=20the?= =?utf8?q?=20help=20file=20before=20attempting=20to=20use=20this=20feature?= =?utf8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: svn+ssh://garage/var/lib/gforge/svnroot/maemo-mapper/trunk@160 6c538b50-5814-0410-93ad-8bdf4c0149d1 --- data/help/en_US/maemomapper.xml.in | 22 ++++++++++++++++++ src/cmenu.c | 37 ++++++++++++++++++++++++++++++ src/data.c | 3 +++ src/data.h | 3 +++ src/display.c | 22 ++++++++++++------ src/settings.c | 14 +++++++++++ 6 files changed, 94 insertions(+), 7 deletions(-) diff --git a/data/help/en_US/maemomapper.xml.in b/data/help/en_US/maemomapper.xml.in index 023d8f2..8e022da 100644 --- a/data/help/en_US/maemomapper.xml.in +++ b/data/help/en_US/maemomapper.xml.in @@ -574,7 +574,29 @@ current location, and it can be used to calculate a route from that location. + + Map Correction - Enables and disables + map correction. When enabling map correction, the tap point is + used as the correction reference point. See the note below for + more details. + + + Map Correction is a little-used feature that corrects a rare problem + with map data. In some locations around the world (like Brazil and + Québec), road data from a particular map repository may not be + accurate, although the error is consistent. For example, as you + travel, you may find that your actual track (as indicated by your + GPS receiver) is a few hundred meters away from the road on which + Maemo Mapper is drawing your current position. Map Correction fixes + this. When your GPS receiver has an accurate fix, and if Maemo + Mapper shows your current location as somewhere other than where you + expect to be, simply tap-and-hold on the location on the map where + you think your current location should be drawn, then select + this context menu item. The correction is saved as part of your + configuration (so it persists even if you restart Maemo Mapper or + your device). + Waypoint The Waypoint submenu performs actions diff --git a/src/cmenu.c b/src/cmenu.c index 42791ae..2ae89ad 100644 --- a/src/cmenu.c +++ b/src/cmenu.c @@ -263,6 +263,35 @@ cmenu_cb_loc_set_gps(GtkMenuItem *item) return TRUE; } +static gboolean +cmenu_cb_loc_apply_correction(GtkMenuItem *item) +{ + printf("%s()\n", __PRETTY_FUNCTION__); + + if(gtk_check_menu_item_get_active(item)) + { + /* Get difference between tap point and GPS location. */ + gint unitx, unity; + screen2unit(_cmenu_position_x, _cmenu_position_y, unitx, unity); + _map_correction_unitx = unitx - _pos.unitx; + _map_correction_unity = unity - _pos.unity; + map_refresh_mark(TRUE); + MACRO_BANNER_SHOW_INFO(_window, _("Map correction applied.")); + } + else + { + _map_correction_unitx = 0; + _map_correction_unity = 0; + map_refresh_mark(TRUE); + MACRO_BANNER_SHOW_INFO(_window, _("Map correction removed.")); + } + + printf("Map correction now set to: %d, %d\n"); + + vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__); + return TRUE; +} + static gboolean cmenu_cb_way_show_latlon(GtkMenuItem *item) { @@ -628,6 +657,12 @@ void cmenu_init() gtk_menu_append(submenu, gtk_separator_menu_item_new()); gtk_menu_append(submenu, _cmenu_loc_set_gps_item = gtk_menu_item_new_with_label(_("Set as GPS Location"))); + gtk_menu_append(submenu, _cmenu_loc_apply_correction_item + = gtk_check_menu_item_new_with_label( + _("Map Correction"))); + gtk_check_menu_item_set_active( + GTK_CHECK_MENU_ITEM(_cmenu_loc_apply_correction_item), + _map_correction_unitx != 0 || _map_correction_unity != 0); /* Setup the waypoint context menu. */ gtk_menu_append(menu, menu_item @@ -698,6 +733,8 @@ void cmenu_init() G_CALLBACK(cmenu_cb_loc_add_poi), NULL); g_signal_connect(G_OBJECT(_cmenu_loc_set_gps_item), "activate", G_CALLBACK(cmenu_cb_loc_set_gps), NULL); + g_signal_connect(G_OBJECT(_cmenu_loc_apply_correction_item), "toggled", + G_CALLBACK(cmenu_cb_loc_apply_correction), NULL); g_signal_connect(G_OBJECT(_cmenu_way_show_latlon_item), "activate", G_CALLBACK(cmenu_cb_way_show_latlon), NULL); diff --git a/src/data.c b/src/data.c index 27c9f80..6850ff7 100644 --- a/src/data.c +++ b/src/data.c @@ -119,6 +119,8 @@ gint _next_map_rotate_angle = 0; GdkPixbuf *_redraw_wait_icon = NULL; GdkRectangle _redraw_wait_bounds = { 0, 0, 0, 0}; +gint _map_correction_unitx = 0; +gint _map_correction_unity = 0; /** CACHED SCREEN INFORMATION THAT IS DEPENDENT ON THE CURRENT VIEW. */ gint _view_width_pixels = 0; @@ -319,6 +321,7 @@ GtkWidget *_cmenu_loc_add_route_item = NULL; GtkWidget *_cmenu_loc_add_way_item = NULL; GtkWidget *_cmenu_loc_add_poi_item = NULL; GtkWidget *_cmenu_loc_set_gps_item = NULL; +GtkWidget *_cmenu_loc_apply_correction_item = NULL; /* Menu items for the "Waypoint" context menu. */ GtkWidget *_cmenu_way_show_latlon_item = NULL; diff --git a/src/data.h b/src/data.h index da3e984..9ff6e5f 100644 --- a/src/data.h +++ b/src/data.h @@ -98,6 +98,8 @@ extern gint _next_map_rotate_angle; extern GdkPixbuf *_redraw_wait_icon; extern GdkRectangle _redraw_wait_bounds; +extern gint _map_correction_unitx; +extern gint _map_correction_unity; /** CACHED SCREEN INFORMATION THAT IS DEPENDENT ON THE CURRENT VIEW. */ extern gint _view_width_pixels; @@ -298,6 +300,7 @@ extern GtkWidget *_cmenu_loc_add_route_item; extern GtkWidget *_cmenu_loc_add_way_item; extern GtkWidget *_cmenu_loc_add_poi_item; extern GtkWidget *_cmenu_loc_set_gps_item; +extern GtkWidget *_cmenu_loc_apply_correction_item; /* Menu items for the "Waypoint" context menu. */ extern GtkWidget *_cmenu_way_show_latlon_item; diff --git a/src/display.c b/src/display.c index 313f3e8..87f4bfa 100644 --- a/src/display.c +++ b/src/display.c @@ -1442,7 +1442,9 @@ map_download_refresh_idle(MapUpdateTask *mut) gdk_pixbuf_rotate_matrix_mult_number( _map_rotate_matrix, 1 << zoff); gdk_pixbuf_rotate(_map_pixbuf, - destx, desty, + /* Apply Map Correction. */ + destx - unit2pixel(_map_correction_unitx), + desty - unit2pixel(_map_correction_unity), _map_rotate_matrix, mut->pixbuf, TILE_SIZE_PIXELS / 2, @@ -1649,17 +1651,19 @@ thread_render_map(MapRenderTask *mrt) + MAX(mrt->screen_width_pixels, mrt->screen_height_pixels) / 2, mrt->zoom); start_tilex = unit2ztile( - mrt->new_center.unitx - diag_halflength_units, mrt->zoom); + mrt->new_center.unitx - diag_halflength_units + + _map_correction_unitx, mrt->zoom); start_tilex = MAX(start_tilex - (cache_amount - 1), 0); start_tiley = unit2ztile( - mrt->new_center.unity - diag_halflength_units, mrt->zoom); + mrt->new_center.unity - diag_halflength_units + + _map_correction_unity, mrt->zoom); start_tiley = MAX(start_tiley - (cache_amount - 1), 0); - stop_tilex = unit2ztile(mrt->new_center.unitx + diag_halflength_units, - mrt->zoom); + stop_tilex = unit2ztile(mrt->new_center.unitx + diag_halflength_units + + _map_correction_unitx, mrt->zoom); stop_tilex = MIN(stop_tilex + (cache_amount - 1), unit2ztile(WORLD_SIZE_UNITS, mrt->zoom)); - stop_tiley = unit2ztile(mrt->new_center.unity + diag_halflength_units, - mrt->zoom); + stop_tiley = unit2ztile(mrt->new_center.unity + diag_halflength_units + + _map_correction_unity, mrt->zoom); stop_tiley = MIN(stop_tiley + (cache_amount - 1), unit2ztile(WORLD_SIZE_UNITS, mrt->zoom)); @@ -1684,6 +1688,10 @@ thread_render_map(MapRenderTask *mrt) devx, devy, mrt->new_center, mrt->zoom, matrix); + /* Apply Map Correction. */ + devx -= unit2zpixel(_map_correction_unitx, mrt->zoom); + devy -= unit2zpixel(_map_correction_unity, mrt->zoom); + /* Skip this tile under the following conditions: * devx < -tile_rothalf_pixels * devx > _view_width_pixels + tile_rothalf_pixels diff --git a/src/settings.c b/src/settings.c index 9164f36..debe6c2 100644 --- a/src/settings.c +++ b/src/settings.c @@ -107,6 +107,8 @@ #define GCONF_KEY_CENTER_LAT GCONF_KEY_PREFIX"/center_latitude" #define GCONF_KEY_CENTER_LON GCONF_KEY_PREFIX"/center_longitude" #define GCONF_KEY_CENTER_ANGLE GCONF_KEY_PREFIX"/center_angle" +#define GCONF_KEY_MAP_CORRECTION_UNITX GCONF_KEY_PREFIX"/map_correction_unitx" +#define GCONF_KEY_MAP_CORRECTION_UNITY GCONF_KEY_PREFIX"/map_correction_unity" #define GCONF_KEY_ZOOM GCONF_KEY_PREFIX"/zoom" #define GCONF_KEY_ROUTEDIR GCONF_KEY_PREFIX"/route_directory" #define GCONF_KEY_TRACKFILE GCONF_KEY_PREFIX"/track_file" @@ -344,6 +346,12 @@ settings_save() GCONF_KEY_CENTER_ANGLE, _map_rotate_angle, NULL); } + /* Save map correction. */ + gconf_client_set_int(gconf_client, + GCONF_KEY_MAP_CORRECTION_UNITX, _map_correction_unitx, NULL); + gconf_client_set_int(gconf_client, + GCONF_KEY_MAP_CORRECTION_UNITY, _map_correction_unity, NULL); + /* Save last Zoom Level. */ gconf_client_set_int(gconf_client, GCONF_KEY_ZOOM, _zoom, NULL); @@ -2168,6 +2176,12 @@ settings_init() _next_center = _center; } + /* Get map correction. Default is 0. */ + _map_correction_unitx = gconf_client_get_int(gconf_client, + GCONF_KEY_MAP_CORRECTION_UNITX, NULL); + _map_correction_unity = gconf_client_get_int(gconf_client, + GCONF_KEY_MAP_CORRECTION_UNITY, NULL); + /* Get last viewing angle. Default is 0. */ _map_rotate_angle = _next_map_rotate_angle = gconf_client_get_int( gconf_client, GCONF_KEY_CENTER_ANGLE, NULL); -- 2.44.0