]> git.itanic.dy.fi Git - maemo-mapper/commitdiff
Added "Map Correction" feature, to address the rare problem of inaccurate
authorgnuite <gnuite@gmail.com>
Mon, 10 Mar 2008 01:14:51 +0000 (01:14 +0000)
committergnuite <gnuite@gmail.com>
Mon, 10 Mar 2008 01:14:51 +0000 (01:14 +0000)
road data provided by some map repositories in some locations (like Brazil
and Québec).  Please read the help file before attempting to use this
feature.

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
src/cmenu.c
src/data.c
src/data.h
src/display.c
src/settings.c

index 023d8f2f4d084812f64c022d4f0a59874e3c7d24..8e022da3dc2e5d4dab72c2e3f941ebac82f99e06 100644 (file)
           current location, and it can be used to calculate a route from
           that location. 
         </listitem>
+        <listitem>
+          <display_text>Map Correction</display_text> - 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.
+        </listitem>
       </list>
+      <note>
+        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 <i>should</i> 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).
+      </note>
       <heading>Waypoint</heading>
       <para>
         The <display_text>Waypoint</display_text> submenu performs actions
index 42791ae96ee0bdfbda97b17340b840ca6b22a77f..2ae89adaa3dee795e971b7bf8b663202d052e752 100644 (file)
@@ -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);
index 27c9f8090a431fc6461a548961cefb81657decf3..6850ff7f830e553d165ac586d475d8e9b9688e41 100644 (file)
@@ -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;
index da3e984fae99348e6f424d4bc4811de061df9c3e..9ff6e5f77034b8018c544e5b122c0a985702bcc3 100644 (file)
@@ -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;
index 313f3e849db6662e9de6505c41c96b8d423f24eb..87f4bfa7abcdc13bec807b48043192c80f972300 100644 (file)
@@ -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
index 9164f365bf08f2d1c6cffbbac4232e76b82e72ea..debe6c29e958a9591d225ad670a92508714f28bf 100644 (file)
 #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);