]> git.itanic.dy.fi Git - maemo-mapper/commitdiff
Increased precision of latitude and longitude calculations.
authorgnuite <gnuite@gmail.com>
Sun, 18 Nov 2007 05:51:30 +0000 (05:51 +0000)
committergnuite <gnuite@gmail.com>
Sun, 18 Nov 2007 05:51:30 +0000 (05:51 +0000)
git-svn-id: svn+ssh://garage/var/lib/gforge/svnroot/maemo-mapper/trunk@127 6c538b50-5814-0410-93ad-8bdf4c0149d1

14 files changed:
src/cmenu.c
src/data.c
src/data.h
src/defines.h
src/display.c
src/gpx.c
src/maps.c
src/menu.c
src/path.c
src/poi.c
src/settings.c
src/types.h
src/util.c
src/util.h

index f86a1b4b0407bea02e3c45fc23156e331254012d..f9adcd0c5d53c2d1b1859f1082d532c84659d68d 100644 (file)
@@ -46,7 +46,7 @@
 static void
 cmenu_show_latlon(gint unitx, gint unity)
 {
-  gfloat lat, lon;
+  gdouble lat, lon;
   gchar buffer[80], tmp1[LL_FMT_LEN], tmp2[LL_FMT_LEN];
   printf("%s()\n", __PRETTY_FUNCTION__);
 
@@ -69,7 +69,7 @@ static void
 cmenu_clip_latlon(gint unitx, gint unity)
 {
     gchar buffer[80];
-    gfloat lat, lon;
+    gdouble lat, lon;
     printf("%s()\n", __PRETTY_FUNCTION__);
 
     unit2latlon(unitx, unity, lat, lon);
@@ -88,7 +88,7 @@ cmenu_route_to(gint unitx, gint unity)
     gchar buffer[80];
     gchar strlat[32];
     gchar strlon[32];
-    gfloat lat, lon;
+    gdouble lat, lon;
     printf("%s()\n", __PRETTY_FUNCTION__);
 
     unit2latlon(unitx, unity, lat, lon);
@@ -106,7 +106,7 @@ static void
 cmenu_distance_to(gint unitx, gint unity)
 {
     gchar buffer[80];
-    gfloat lat, lon;
+    gdouble lat, lon;
     printf("%s()\n", __PRETTY_FUNCTION__);
 
     unit2latlon(unitx, unity, lat, lon);
index 272529d597f6021d095ad6b138af6d07c452b98d..8885be10bc82c0d65938bb25ac15517ff1b3e388 100644 (file)
 gchar *UNITS_ENUM_TEXT[UNITS_ENUM_COUNT];
 
 /* UNITS_CONVERT, when multiplied, converts from NM. */
-gfloat UNITS_CONVERT[] =
+gdouble UNITS_CONVERT[] =
 {
     1.85200,
-    1.15077945,
-    1.f,
+    1.150779448,
+    1.0,
 };
 
 gchar *UNBLANK_ENUM_TEXT[UNBLANK_ENUM_COUNT];
index 0d1c137b7d4610407333f60d37e063d7b6f57e20..52dde626d385bb8b64dea6dc9819f54107d048f4 100644 (file)
@@ -28,7 +28,7 @@
 
 /* Constants regarding enums and defaults. */
 extern gchar *UNITS_ENUM_TEXT[UNITS_ENUM_COUNT];
-extern gfloat UNITS_CONVERT[UNITS_ENUM_COUNT];
+extern gdouble UNITS_CONVERT[UNITS_ENUM_COUNT];
 extern gchar *UNBLANK_ENUM_TEXT[UNBLANK_ENUM_COUNT];
 extern gchar *INFO_FONT_ENUM_TEXT[INFO_FONT_ENUM_COUNT];
 extern gchar *ROTATE_DIR_ENUM_TEXT[ROTATE_DIR_ENUM_COUNT];
index 004100b98317dfd3c6a5cc5f4b13c3029bbf48ae..88e5a2b15995eb8a1d1a072dd4a0f98ffe5ce4b0 100644 (file)
@@ -46,9 +46,9 @@
         (x) = (b); \
 }
 
-#define PI   (3.14159265358979323846f)
+#define PI   (3.14159265358979323846)
 
-#define EARTH_RADIUS (3440.06479f)
+#define EARTH_RADIUS (3443.91847)
 
 /** MAX_ZOOM defines the largest map zoom level we will download.
  * (MAX_ZOOM - 1) is the largest map zoom level that the user can zoom to.
@@ -70,8 +70,8 @@
 
 #define HOURGLASS_SEPARATION (7)
 
-#define deg2rad(deg) ((deg) * (PI / 180.f))
-#define rad2deg(rad) ((rad) * (180.f / PI))
+#define deg2rad(deg) ((deg) * (PI / 180.0))
+#define rad2deg(rad) ((rad) * (180.0 / PI))
 
 #define tile2pixel(TILE) ((TILE) << TILE_SIZE_P2)
 #define pixel2tile(PIXEL) ((PIXEL) >> TILE_SIZE_P2)
     gdk_pixbuf_rotate_vector(&funitx, &funity, MATRIX, \
             pixel2unit((gint)((BUFX) - _screen_halfwidth_pixels)), \
             pixel2unit((gint)((BUFY) - _screen_halfheight_pixels))); \
-    (UNITX) = funitx + CENTER.unitx; \
-    (UNITY) = funity + CENTER.unity; \
+    (UNITX) = (CENTER).unitx + (gint)funitx; \
+    (UNITY) = (CENTER).unity + (gint)funity; \
 }
 
 #define buf2unit(BUFX, BUFY, UNITX, UNITY) \
     gdk_pixbuf_rotate_vector(&fpixelx, &fpixely, MATRIX, \
             (gint)(BUFX) - _screen_halfwidth_pixels, \
             (gint)(BUFY) - _screen_halfheight_pixels); \
-    (PIXELX) = fpixelx + unit2pixel(CENTER.unitx); \
-    (PIXELY) = fpixely + unit2pixel(CENTER.unity); \
+    (PIXELX) = unit2pixel((CENTER).unitx) + (gint)fpixelx; \
+    (PIXELY) = unit2pixel((CENTER).unity) + (gint)fpixely; \
 }
 
 #define buf2pixel(BUFX, BUFY, PIXELX, PIXELY) \
 #define HELP_ID_POILIST HELP_ID_PREFIX"poilist"
 #define HELP_ID_POICAT HELP_ID_PREFIX"poicat"
 
-#define MERCATOR_SPAN (-6.28318377773622f)
-#define MERCATOR_TOP (3.14159188886811f)
+#define MERCATOR_SPAN (-6.28318377773622)
+#define MERCATOR_TOP (3.14159188886811)
 #define latlon2unit(lat, lon, unitx, unity) { \
-    gfloat tmp; \
-    unitx = (lon + 180.f) * (WORLD_SIZE_UNITS / 360.f) + 0.5f; \
-    tmp = sinf(deg2rad(lat)); \
-    unity = 0.5f + (WORLD_SIZE_UNITS / MERCATOR_SPAN) \
-        * (logf((1.f + tmp) / (1.f - tmp)) * 0.5f - MERCATOR_TOP); \
+    gdouble tmp; \
+    unitx = (lon + 180.0) * (WORLD_SIZE_UNITS / 360.0) + 0.5; \
+    tmp = sin(deg2rad(lat)); \
+    unity = 0.5 + (WORLD_SIZE_UNITS / MERCATOR_SPAN) \
+        * (log((1.0 + tmp) / (1.0 - tmp)) * 0.5 - MERCATOR_TOP); \
 }
 
 #define unit2latlon(unitx, unity, lat, lon) { \
-    (lon) = ((unitx) * (360.f / WORLD_SIZE_UNITS)) - 180.f; \
-    (lat) = (360.f * (atanf(expf(((unity) \
-                                  * (MERCATOR_SPAN / WORLD_SIZE_UNITS)) \
-                     + MERCATOR_TOP)))) * (1.f / PI) - 90.f; \
+    (lon) = ((unitx) * (360.0 / WORLD_SIZE_UNITS)) - 180.0; \
+    (lat) = (360.0 * (atan(exp(((unity) * (MERCATOR_SPAN / WORLD_SIZE_UNITS)) \
+                     + MERCATOR_TOP)))) * (1.0 / PI) - 90.0; \
 }
 
 #define MACRO_PATH_INIT(path) { \
index c4fc3822b86782589a210bc042f3b509b3f431a1..f2bf11d2e8b3dc01a24838387c994645d2e06f36 100644 (file)
@@ -904,8 +904,8 @@ map_render_segment(GdkGC *gc_norm, GdkGC *gc_alt,
     {
         gint x2, y2;
         unit2buf(unitx2, unity2, x2, y2);
-        if(((unsigned)(x2+_draw_width) < _screen_width_pixels+2*_draw_width)
-         ||((unsigned)(y2+_draw_width) < _screen_height_pixels+2*_draw_width))
+        if(((unsigned)(x2+_draw_width) <= _screen_width_pixels+2*_draw_width)
+         &&((unsigned)(y2+_draw_width) <= _screen_height_pixels+2*_draw_width))
         {
             gdk_draw_arc(_map_pixmap, gc_alt,
                     FALSE, /* FALSE: not filled. */
@@ -921,8 +921,8 @@ map_render_segment(GdkGC *gc_norm, GdkGC *gc_alt,
     {
         gint x1, y1;
         unit2buf(unitx1, unity1, x1, y1);
-        if(((unsigned)(x1+_draw_width) < _screen_width_pixels+2*_draw_width)
-         ||((unsigned)(y1+_draw_width) < _screen_height_pixels+2*_draw_width))
+        if(((unsigned)(x1+_draw_width) <= _screen_width_pixels+2*_draw_width)
+         &&((unsigned)(y1+_draw_width) <= _screen_height_pixels+2*_draw_width))
         {
             gdk_draw_arc(_map_pixmap, gc_alt,
                     FALSE, /* FALSE: not filled. */
@@ -1204,7 +1204,7 @@ map_calc_new_center(gint zoom)
             gfloat screen_pixels = _screen_width_pixels
                 + (((gint)_screen_height_pixels
                             - (gint)_screen_width_pixels)
-                        * fabs(cosf(deg2rad(
+                        * fabsf(cosf(deg2rad(
                                 ROTATE_DIR_ENUM_DEGREES[_rotate_dir] -
                                 (_center_rotate ? 0
                              : (_next_map_rotate_angle
@@ -1616,8 +1616,8 @@ thread_render_map(MapRenderTask *mrt)
      * of the screen plus the maximum additional pixels of a rotated tile.
      */
     tile_rothalf_pixels = MAX(
-            fabs(TILE_HALFDIAG_PIXELS * sinf((PI / 4) - angle_rad)),
-            fabs(TILE_HALFDIAG_PIXELS * cosf((PI / 4) - angle_rad)));
+            fabsf(TILE_HALFDIAG_PIXELS * sinf((PI / 4) - angle_rad)),
+            fabsf(TILE_HALFDIAG_PIXELS * cosf((PI / 4) - angle_rad)));
 
     mrt->zoom = _next_zoom;
 
@@ -2108,7 +2108,6 @@ map_cb_expose(GtkWidget *widget, GdkEventExpose *event)
             event->area.x, event->area.y,
             event->area.width, event->area.height);
 
-    /* Perform rotation. */
     gdk_draw_drawable(
             _map_widget->window,
             _gc[COLORABLE_MARK],
@@ -2118,25 +2117,37 @@ map_cb_expose(GtkWidget *widget, GdkEventExpose *event)
             event->area.width, event->area.height);
 
     /* Draw the mark. */
-    gdk_draw_arc(
-            _map_widget->window,
-            _gps_state == RCVR_FIXED
-                ? _gc[COLORABLE_MARK] : _gc[COLORABLE_MARK_OLD],
-            FALSE, /* not filled. */
-            _mark_bufx1 - _draw_width + _map_offset_devx,
-            _mark_bufy1 - _draw_width + _map_offset_devy,
-            2 * _draw_width, 2 * _draw_width,
-            0, 360 * 64);
-    gdk_draw_line(
-            _map_widget->window,
-            _gps_state == RCVR_FIXED
-                ? (_show_velvec
-                    ? _gc[COLORABLE_MARK_VELOCITY] : _gc[COLORABLE_MARK])
-                : _gc[COLORABLE_MARK_OLD],
-            _mark_bufx1 + _map_offset_devx,
-            _mark_bufy1 + _map_offset_devy,
-            _mark_bufx2 + _map_offset_devx,
-            _mark_bufy2 + _map_offset_devy);
+    if((((unsigned)(_mark_bufx1 + _draw_width)
+                <= _screen_width_pixels+2*_draw_width)
+             &&((unsigned)(_mark_bufy1 + _draw_width)
+                 <= _screen_height_pixels+2*_draw_width))
+        || (((unsigned)(_mark_bufx2 + _draw_width)
+                 <= _screen_width_pixels+2*_draw_width)
+             &&((unsigned)(_mark_bufy2 + _draw_width)
+                 <= _screen_height_pixels+2*_draw_width)))
+    {
+        printf("DRAWING\n");
+        /* TODO: TEST THIS. */
+        gdk_draw_arc(
+                _map_widget->window,
+                _gps_state == RCVR_FIXED
+                    ? _gc[COLORABLE_MARK] : _gc[COLORABLE_MARK_OLD],
+                FALSE, /* not filled. */
+                _mark_bufx1 - _draw_width + _map_offset_devx,
+                _mark_bufy1 - _draw_width + _map_offset_devy,
+                2 * _draw_width, 2 * _draw_width,
+                0, 360 * 64);
+        gdk_draw_line(
+                _map_widget->window,
+                _gps_state == RCVR_FIXED
+                    ? (_show_velvec
+                        ? _gc[COLORABLE_MARK_VELOCITY] : _gc[COLORABLE_MARK])
+                    : _gc[COLORABLE_MARK_OLD],
+                _mark_bufx1 + _map_offset_devx,
+                _mark_bufy1 + _map_offset_devy,
+                _mark_bufx2 + _map_offset_devx,
+                _mark_bufy2 + _map_offset_devy);
+    }
 
     /* draw zoom box if so wanted */
     if(_show_zoomlevel) {
@@ -2179,7 +2190,7 @@ map_cb_expose(GtkWidget *widget, GdkEventExpose *event)
             {
                 gchar buffer[16];
                 gfloat distance;
-                gfloat lat1, lon1, lat2, lon2;
+                gdouble lat1, lon1, lat2, lon2;
                 gint width;
 
                 unit2latlon(_center.unitx - pixel2unit(SCALE_WIDTH / 2 - 4),
index 00e9798039d27ab4d616385aab3c5ea87abfb343..7c1342ad705dccbbc16c5fe3f16aa9503feed1f4 100644 (file)
--- a/src/gpx.c
+++ b/src/gpx.c
@@ -140,7 +140,7 @@ gpx_path_start_element(PathSaxData *data,
             {
                 const xmlChar **curr_attr;
                 gchar *error_check;
-                gfloat lat = 0.f, lon = 0.f;
+                gdouble lat = 0.0, lon = 0.0;
                 gboolean has_lat, has_lon;
                 has_lat = FALSE;
                 has_lon = FALSE;
@@ -514,7 +514,7 @@ gpx_path_write(Path *path, GnomeVFSHandle *handle)
     /* Curr points to first non-zero point. */
     for(curr--; curr++ != path->tail; )
     {
-        gfloat lat, lon;
+        gdouble lat, lon;
         if(curr->unity)
         {
             gchar buffer[80];
@@ -632,7 +632,7 @@ gpx_poi_start_element(PoiSaxData *data,
             {
                 const xmlChar **curr_attr;
                 gchar *error_check;
-                gfloat lat = 0.f, lon = 0.f;
+                gdouble lat = 0.0, lon = 0.0;
                 gboolean has_lat, has_lon;
                 has_lat = FALSE;
                 has_lon = FALSE;
index 80217620bfa4fc83443743c5005918da35ae4b74..02fa7a89120b9387eab109cb6b9756a1f0d16f48 100644 (file)
@@ -745,7 +745,7 @@ map_convert_wms_to_wms(gint tilex, gint tiley, gint zoomlevel, gchar* uri)
     gchar cmd[BUFFER_SIZE], srs[BUFFER_SIZE];
     gchar *ret = NULL;
     FILE* in;
-    gfloat lon1, lat1, lon2, lat2;
+    gdouble lon1, lat1, lon2, lat2;
 
     gchar *widthstr   = strcasestr(uri,"WIDTH=");
     gchar *heightstr  = strcasestr(uri,"HEIGHT=");
@@ -1503,7 +1503,7 @@ repoman_dialog_add_repo(RepoManInfo *rmi, gchar *name)
             FALSE, FALSE, 0);
     hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(rei->num_min_zoom), 4);
     gtk_box_pack_start(GTK_BOX(hbox),
-            label = gtk_label_new(_("")),
+            label = gtk_label_new(""),
             TRUE, TRUE, 4);
     gtk_box_pack_start(GTK_BOX(hbox),
             label = gtk_label_new(_("Max.")),
@@ -1897,8 +1897,8 @@ repoman_dialog()
 }
 
 static gboolean
-mapman_by_area(gfloat start_lat, gfloat start_lon,
-        gfloat end_lat, gfloat end_lon, MapmanInfo *mapman_info,
+mapman_by_area(gdouble start_lat, gdouble start_lon,
+        gdouble end_lat, gdouble end_lon, MapmanInfo *mapman_info,
         MapUpdateType update_type,
         gint download_batch_id)
 {
@@ -2187,7 +2187,7 @@ mapman_dialog()
     static GtkWidget *lbl_center_lon = NULL;
     static MapmanInfo mapman_info;
     gchar buffer[80];
-    gfloat lat, lon;
+    gdouble lat, lon;
     gint z;
     printf("%s()\n", __PRETTY_FUNCTION__);
 
index 0b5d2457bc4e9a5d986474cc36b15b1b057492c3..c2f951413d18091d83487f0859f88cc75daae239 100644 (file)
@@ -276,7 +276,7 @@ menu_cb_track_insert_break(GtkMenuItem *item)
 static gboolean
 menu_cb_track_insert_mark(GtkMenuItem *item)
 {
-    gfloat lat, lon;
+    gdouble lat, lon;
     gchar tmp1[LL_FMT_LEN], tmp2[LL_FMT_LEN], *p_latlon;
     static GtkWidget *dialog = NULL;
     static GtkWidget *table = NULL;
@@ -816,7 +816,7 @@ menu_cb_view_goto_latlon(GtkMenuItem *item)
     /* Initialize with the current center position. */
     {
         gchar buffer[32];
-        gfloat lat, lon;
+        gdouble lat, lon;
         unit2latlon(_center.unitx, _center.unity, lat, lon);
         lat_format(lat, buffer);
         gtk_entry_set_text(GTK_ENTRY(txt_lat), buffer);
index 56a4fba11442ac46572d27a3c633c545f734544d..c1cab78f20ae3ba0c0b0b31c6666c45d86cf6d40 100644 (file)
@@ -462,7 +462,7 @@ gboolean
 route_show_distance_to(Point *point)
 {
     gchar buffer[80];
-    gfloat lat1, lon1, lat2, lon2;
+    gdouble lat1, lon1, lat2, lon2;
     gdouble sum = 0.0;
     printf("%s()\n", __PRETTY_FUNCTION__);
 
@@ -558,7 +558,7 @@ static void
 track_show_distance_from(Point *point)
 {
     gchar buffer[80];
-    gfloat lat1, lon1, lat2, lon2;
+    gdouble lat1, lon1, lat2, lon2;
     gdouble sum = 0.0;
     Point *curr;
     unit2latlon(_pos.unitx, _pos.unity, lat1, lon1);
@@ -817,7 +817,7 @@ track_add(time_t time, gboolean newly_fixed)
                     }
                     else
                     {
-                        route_dist_squared_1 = fabs((slope * _pos.unitx)
+                        route_dist_squared_1 = fabsf((slope * _pos.unitx)
                             - _pos.unity + (route_y1 - (slope * route_x1)));
                         route_dist_squared_1 =
                             route_dist_squared_1 * route_dist_squared_1
@@ -839,7 +839,7 @@ track_add(time_t time, gboolean newly_fixed)
                     }
                     else
                     {
-                        route_dist_squared_2 = fabs((slope * _pos.unitx)
+                        route_dist_squared_2 = fabsf((slope * _pos.unitx)
                             - _pos.unity + (route_y1 - (slope * route_x1)));
                         route_dist_squared_2 =
                             route_dist_squared_2 * route_dist_squared_2
@@ -1296,7 +1296,7 @@ route_download(gchar *to)
             gchar strlat[32];
             gchar strlon[32];
             Point *p;
-            gfloat lat, lon;
+            gdouble lat, lon;
 
             /* Use last non-zero route point. */
             for(p = _route.tail; !p->unity; p--) { }
@@ -1381,7 +1381,7 @@ route_download(gchar *to)
 void
 route_add_way_dialog(gint unitx, gint unity)
 {
-    gfloat lat, lon;
+    gdouble lat, lon;
     gchar tmp1[LL_FMT_LEN], tmp2[LL_FMT_LEN], *p_latlon;
     static GtkWidget *dialog = NULL;
     static GtkWidget *table = NULL;
index 1982570b8338ae0d43636eab85824459cf700cac..3d1b1b7c1ac9ec1442e85e7783412454e58c7941 100644 (file)
--- a/src/poi.c
+++ b/src/poi.c
@@ -330,7 +330,7 @@ get_nearest_poi(gint unitx, gint unity, PoiInfo *poi)
 {
     printf("%s(%d, %d)\n", __PRETTY_FUNCTION__, unitx, unity);
     gboolean result;
-    gfloat lat, lon;
+    gdouble lat, lon;
     unit2latlon(unitx, unity, lat, lon);
 
     if(SQLITE_OK == sqlite3_bind_double(_stmt_select_nearest_poi, 1, lat)
@@ -357,7 +357,7 @@ gboolean
 select_poi(gint unitx, gint unity, PoiInfo *poi, gboolean quick)
 {
     gint x, y;
-    gfloat lat1, lon1, lat2, lon2;
+    gdouble lat1, lon1, lat2, lon2;
     static GtkWidget *dialog = NULL;
     static GtkWidget *list = NULL;
     static GtkWidget *sw = NULL;
@@ -403,7 +403,7 @@ select_poi(gint unitx, gint unity, PoiInfo *poi, gboolean quick)
 
     while(SQLITE_ROW == sqlite3_step(_stmt_select_poi))
     {
-        gfloat lat, lon;
+        gdouble lat, lon;
         lat = sqlite3_column_double(_stmt_select_poi, 0);
         lon = sqlite3_column_double(_stmt_select_poi, 1);
         lat_format(lat, tmp1);
@@ -1965,7 +1965,7 @@ poi_list_goto(GtkWidget *widget, PoiListInfo *pli)
     /* Iterate through the data store and import as desired. */
     if(gtk_tree_selection_get_selected(selection, NULL, &iter))
     {
-        gfloat lat, lon;
+        gdouble lat, lon;
         Point unit;
 
         gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
@@ -2136,7 +2136,7 @@ poi_list_dialog(GtkWidget *parent, gint unitx, gint unity, GList *poi_list)
     static GtkListStore *store;
     GtkTreeIter iter;
     GList *curr;
-    gfloat src_lat, src_lon;
+    gdouble src_lat, src_lon;
     printf("%s()\n", __PRETTY_FUNCTION__);
 
     if(pli.dialog == NULL)
@@ -2608,7 +2608,7 @@ poi_download_dialog(gint unitx, gint unity)
         gchar buffer[80];
         gchar strlat[32];
         gchar strlon[32];
-        gfloat lat, lon;
+        gdouble lat, lon;
 
         unit2latlon(unitx, unity, lat, lon);
 
@@ -2690,7 +2690,7 @@ poi_download_dialog(gint unitx, gint unity)
             gchar strlat[32];
             gchar strlon[32];
             Point *p;
-            gfloat lat, lon;
+            gdouble lat, lon;
 
             /* Use last non-zero route point. */
             for(p = _route.tail; !p->unity; p--) { }
@@ -2905,7 +2905,7 @@ poi_browse_dialog(gint unitx, gint unity)
         gchar buffer[80];
         gchar strlat[32];
         gchar strlon[32];
-        gfloat lat, lon;
+        gdouble lat, lon;
 
         unit2latlon(unitx, unity, lat, lon);
 
@@ -2952,7 +2952,7 @@ poi_browse_dialog(gint unitx, gint unity)
     {
         gchar buffer[BUFFER_SIZE];
         const gchar *origin, *query;
-        gfloat lat, lon;
+        gdouble lat, lon;
         GList *poi_list = NULL;
         gint cat_id;
         gboolean is_cat = FALSE;
@@ -2974,7 +2974,7 @@ poi_browse_dialog(gint unitx, gint unity)
             gchar strlat[32];
             gchar strlon[32];
             Point *p;
-            gfloat lat, lon;
+            gdouble lat, lon;
 
             /* Use last non-zero route point. */
             for(p = _route.tail; !p->unity; p--) { }
@@ -3089,7 +3089,7 @@ void
 map_render_poi()
 {
     gint unitx, unity;
-    gfloat lat1, lat2, lon1, lon2;
+    gdouble lat1, lat2, lon1, lon2;
     gchar buffer[100];
     gint poix, poiy;
     GdkPixbuf *pixbuf = NULL;
index 7b69dbc7782a3afef6d470662557ce21e22bcdc5..eb45979b325583a6c1b7ad2b9766ffa3168ccd80 100644 (file)
@@ -220,7 +220,7 @@ settings_save()
 
     /* Save last center point. */
     {
-        gfloat center_lat, center_lon;
+        gdouble center_lat, center_lon;
         unit2latlon(_center.unitx, _center.unity, center_lat, center_lon);
 
         /* Save last center latitude. */
@@ -1900,7 +1900,7 @@ settings_init()
 
     /* Get last center point. */
     {
-        gfloat center_lat, center_lon;
+        gdouble center_lat, center_lon;
 
         /* Get last saved latitude.  Default is last saved latitude. */
         value = gconf_client_get(gconf_client, GCONF_KEY_CENTER_LAT, NULL);
index d6941da852716e57f0829062828b1b79d3515d5e..0b03d7e06526801d091717a5637911bda11c872a 100644 (file)
@@ -332,8 +332,8 @@ typedef struct _PoiInfo PoiInfo;
 struct _PoiInfo {
     gint poi_id;
     gint cat_id;
-    gfloat lat;
-    gfloat lon;
+    gdouble lat;
+    gdouble lon;
     gchar *label;
     gchar *desc;
     gchar *clabel;
@@ -387,8 +387,8 @@ typedef struct _GpsData GpsData;
 struct _GpsData {
     gint fix;
     gint fixquality;
-    gfloat lat;
-    gfloat lon;
+    gdouble lat;
+    gdouble lon;
     gfloat speed;    /* in knots */
     gfloat maxspeed;    /* in knots */
     gfloat heading;
index 146e34b4413bca42fdac8d16c1b54098f4985cd3..ab8b294f6e55066485607feefe7b3f6ae16abe80 100644 (file)
@@ -55,10 +55,10 @@ popup_error(GtkWidget *window, const gchar *error)
 }
 
 void
-deg_format(gfloat coor, gchar *scoor, gchar neg_char, gchar pos_char)
+deg_format(gdouble coor, gchar *scoor, gchar neg_char, gchar pos_char)
 {
-    gfloat min;
-    gfloat acoor = fabs(coor);
+    gdouble min;
+    gdouble acoor = fabs(coor);
     printf("%s()\n", __PRETTY_FUNCTION__);
 
     switch(_degformat)
@@ -68,11 +68,11 @@ deg_format(gfloat coor, gchar *scoor, gchar neg_char, gchar pos_char)
             break;
         case DDPDDDDD_NSEW:
             sprintf(scoor, "%.5f° %c", acoor,
-                    coor < 0.f ? neg_char : pos_char);
+                    coor < 0.0 ? neg_char : pos_char);
             break;
         case NSEW_DDPDDDDD:
             sprintf(scoor, "%c %.5f°",
-                    coor < 0.f ? neg_char : pos_char,
+                    coor < 0.0 ? neg_char : pos_char,
                     acoor);
             break;
 
@@ -83,11 +83,11 @@ deg_format(gfloat coor, gchar *scoor, gchar neg_char, gchar pos_char)
         case DD_MMPMMM_NSEW:
             sprintf(scoor, "%d°%06.3f' %c",
                     (int)acoor, (acoor - (int)acoor)*60.0,
-                    coor < 0.f ? neg_char : pos_char);
+                    coor < 0.0 ? neg_char : pos_char);
             break;
         case NSEW_DD_MMPMMM:
             sprintf(scoor, "%c %d° %06.3f'",
-                    coor < 0.f ? neg_char : pos_char,
+                    coor < 0.0 ? neg_char : pos_char,
                     (int)acoor, (acoor - (int)acoor)*60.0);
             break;
 
@@ -100,12 +100,12 @@ deg_format(gfloat coor, gchar *scoor, gchar neg_char, gchar pos_char)
             min = (acoor - (int)acoor)*60.0;
             sprintf(scoor, "%d°%02d'%04.1f\" %c", (int)acoor, (int)min,
                     ((min - (int)min)*60.0),
-                    coor < 0.f ? neg_char : pos_char);
+                    coor < 0.0 ? neg_char : pos_char);
             break;
         case NSEW_DD_MM_SSPS:
             min = (acoor - (int)acoor)*60.0;
             sprintf(scoor, "%c %d° %02d' %04.1f\"",
-                    coor < 0.f ? neg_char : pos_char,
+                    coor < 0.0 ? neg_char : pos_char,
                     (int)acoor, (int)min,
                     ((min - (int)min)*60.0));
             break;
@@ -178,12 +178,12 @@ Point locate_address(GtkWidget *parent, const gchar *addr)
 
 /**
  * Calculate the distance between two lat/lon pairs.  The distance is returned
- * in kilometers and should be converted using UNITS_CONVERT[_units].
+ * in nautical miles and should be converted using UNITS_CONVERT[_units].
  */
-gfloat
-calculate_distance(gfloat lat1, gfloat lon1, gfloat lat2, gfloat lon2)
+gdouble
+calculate_distance(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2)
 {
-    gfloat dlat, dlon, slat, slon, a;
+    gdouble dlat, dlon, slat, slon, a;
 
     /* Convert to radians. */
     lat1 = deg2rad(lat1);
@@ -194,32 +194,32 @@ calculate_distance(gfloat lat1, gfloat lon1, gfloat lat2, gfloat lon2)
     dlat = lat2 - lat1;
     dlon = lon2 - lon1;
 
-    slat = sinf(dlat / 2.f);
-    slon = sinf(dlon / 2.f);
-    a = (slat * slat) + (cosf(lat1) * cosf(lat2) * slon * slon);
+    slat = sin(dlat / 2.0);
+    slon = sin(dlon / 2.0);
+    a = (slat * slat) + (cos(lat1) * cos(lat2) * slon * slon);
 
     vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-    return ((2.f * atan2f(sqrtf(a), sqrtf(1.f - a))) * EARTH_RADIUS);
+    return ((2.0 * atan2(sqrt(a), sqrt(1.0 - a))) * EARTH_RADIUS);
 }
 
 /**
  * Calculate the bearing between two lat/lon pairs.  The bearing is returned
  * as the angle from lat1/lon1 to lat2/lon2.
  */
-gfloat
-calculate_bearing(gfloat lat1, gfloat lon1, gfloat lat2, gfloat lon2)
+gdouble
+calculate_bearing(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2)
 {
-    gfloat x, y;
-    gfloat dlon = deg2rad(lon2 - lon1);
+    gdouble x, y;
+    gdouble dlon = deg2rad(lon2 - lon1);
     lat1 = deg2rad(lat1);
     lat2 = deg2rad(lat2);
 
-    y = sinf(dlon) * cosf(lat2);
-    x = (cosf(lat1) * sinf(lat2)) - (sinf(lat1) * cosf(lat2) * cosf(dlon));
+    y = sin(dlon) * cos(lat2);
+    x = (cos(lat1) * sin(lat2)) - (sin(lat1) * cos(lat2) * cos(dlon));
 
-    dlon = rad2deg(atan2f(y, x));
-    if(dlon < 0.f)
-        dlon += 360.f;
+    dlon = rad2deg(atan2(y, x));
+    if(dlon < 0.0)
+        dlon += 360.0;
     return dlon;
 }
 
index adb46c1128dfe83d486b333b45bde505aedc7a6e..23704c5d5badfe48e2185bbf4c3f25e0a2b9ea8d 100644 (file)
@@ -30,14 +30,16 @@ void popup_error(GtkWidget *window, const gchar *error);
 
 Point locate_address(GtkWidget *parent, const gchar *address);
 
-gfloat calculate_distance(gfloat lat1, gfloat lon1, gfloat lat2, gfloat lon2);
-gfloat calculate_bearing(gfloat lat1, gfloat lon1, gfloat lat2, gfloat lon2);
+gdouble calculate_distance(gdouble lat1, gdouble lon1,
+        gdouble lat2, gdouble lon2);
+gdouble calculate_bearing(gdouble lat1, gdouble lon1,
+        gdouble lat2, gdouble lon2);
 
 void force_min_visible_bars(HildonControlbar *control_bar, gint num_bars);
 
 gboolean banner_reset();
 
-void deg_format(gfloat coor, gchar *scoor, gchar neg_char, gchar pos_char);
+void deg_format(gdouble coor, gchar *scoor, gchar neg_char, gchar pos_char);
 
 gdouble strdmstod(const gchar *nptr, gchar **endptr);