From: Kaj-Michael Lang Date: Fri, 10 Aug 2007 08:43:42 +0000 (+0300) Subject: Always use gdouble for lat, lon. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=028acbdbaa02fc61e70c96dec8003377d4720100;p=mapper Always use gdouble for lat, lon. Fix warnings. --- diff --git a/src/cb.c b/src/cb.c index 72a8774..c312cfc 100644 --- a/src/cb.c +++ b/src/cb.c @@ -23,6 +23,8 @@ #include "utils.h" #include "poi.h" #include "route.h" +#include "track.h" +#include "path.h" #include "settings.h" #include "gps.h" #include "map.h" @@ -30,8 +32,9 @@ #include "bt.h" #include "ui-common.h" #include "db.h" - +#include "latlon.h" #include "cb.h" +#include "gps-panels.h" gboolean map_cb_configure(GtkWidget * widget, GdkEventConfigure * event) { @@ -386,7 +389,7 @@ gboolean menu_cb_goto_latlon(GtkAction * action) /* Initialize with the current center position. */ { gchar buffer[32]; - gfloat lat, lon; + gdouble lat, lon; unit2latlon(_center.unitx, _center.unity, lat, lon); snprintf(buffer, sizeof(buffer), "%.06f", lat); gtk_label_set_text(GTK_LABEL(txt_lat), buffer); @@ -399,7 +402,7 @@ gboolean menu_cb_goto_latlon(GtkAction * action) while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { const gchar *text; gchar *error_check; - gfloat lat, lon; + gdouble lat, lon; guint unitx, unity; text = gtk_entry_get_text(GTK_ENTRY(txt_lat)); @@ -609,10 +612,10 @@ gboolean cb_fullscreen(GtkAction * action) if ((_fullscreen = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(_menu_fullscreen_item)))) { gtk_window_fullscreen(GTK_WINDOW(_window)); - gtk_widget_set_state(_toolbar_fullscreen_item, GTK_STATE_ACTIVE); + gtk_widget_set_state(GTK_WIDGET(_toolbar_fullscreen_item), GTK_STATE_ACTIVE); } else { gtk_window_unfullscreen(GTK_WINDOW(_window)); - gtk_widget_set_state(_toolbar_fullscreen_item, GTK_STATE_NORMAL); + gtk_widget_set_state(GTK_WIDGET(_toolbar_fullscreen_item), GTK_STATE_NORMAL); } gtk_idle_add((GSourceFunc) window_present, NULL); @@ -960,7 +963,7 @@ gboolean window_cb_key_release(GtkWidget * widget, GdkEventKey * event) void cmenu_show_latlon(guint unitx, guint unity) { - gfloat lat, lon; + gdouble lat, lon; gchar buffer[80], tmp1[16], tmp2[16]; printf("%s()\n", __PRETTY_FUNCTION__); @@ -982,7 +985,7 @@ void cmenu_show_latlon(guint unitx, guint unity) void cmenu_clip_latlon(guint unitx, guint unity) { gchar buffer[80]; - gfloat lat, lon; + gdouble lat, lon; printf("%s()\n", __PRETTY_FUNCTION__); unit2latlon(unitx, unity, lat, lon); @@ -1000,7 +1003,7 @@ void cmenu_route_to(guint unitx, guint 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); @@ -1017,7 +1020,7 @@ void cmenu_route_to(guint unitx, guint unity) void cmenu_distance_to(guint unitx, guint unity) { gchar buffer[80]; - gfloat lat, lon; + gdouble lat, lon; printf("%s()\n", __PRETTY_FUNCTION__); unit2latlon(unitx, unity, lat, lon); @@ -1043,7 +1046,7 @@ void cmenu_add_route(guint unitx, guint unity) void cmenu_route_add_way(guint unitx, guint unity) { - gfloat lat, lon; + gdouble lat, lon; gchar tmp1[16], tmp2[16], *p_latlon; GtkWidget *dialog; GtkWidget *table; diff --git a/src/config-gconf.c b/src/config-gconf.c index 23af015..0ab3097 100644 --- a/src/config-gconf.c +++ b/src/config-gconf.c @@ -29,6 +29,7 @@ #include "bt.h" #include "ui-common.h" #include "settings.h" +#include "gpx.h" void config_update_proxy(void) { diff --git a/src/gps.h b/src/gps.h index 3642526..3e46447 100644 --- a/src/gps.h +++ b/src/gps.h @@ -26,8 +26,8 @@ typedef struct _GpsData GpsData; struct _GpsData { guint fix; guint fixquality; - gfloat lat; - gfloat lon; + gdouble lat; + gdouble lon; gfloat speed; /* in knots */ gfloat maxspeed; /* in knots */ gfloat avgspeed; /* -- "" -- */ diff --git a/src/gpx.c b/src/gpx.c index 628bbb7..eb8f70e 100644 --- a/src/gpx.c +++ b/src/gpx.c @@ -95,7 +95,7 @@ write_gpx(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]; gboolean first_sub = TRUE; @@ -209,7 +209,7 @@ gpx_start_element(SaxData * data, const xmlChar * name, const xmlChar ** attrs) if (!strcmp((gchar *) name, "trkpt")) { const xmlChar **curr_attr; gchar *error_check; - gfloat lat = 0.f, lon = 0.f; + gdouble lat = 0.f, lon = 0.f; gboolean has_lat, has_lon; has_lat = FALSE; has_lon = FALSE; diff --git a/src/latlon.c b/src/latlon.c index 6cb53b0..df7bd70 100644 --- a/src/latlon.c +++ b/src/latlon.c @@ -75,11 +75,11 @@ lon2*=(M_PI_4l / 180.f); dlat=lat2 - lat1; dlon=lon2 - lon1; -slat=sinf(dlat / 2.f); -slon=sinf(dlon / 2.f); +slat=sin(dlat / 2.f); +slon=sin(dlon / 2.f); -a=(slat * slat) + (cosf(lat1) * cosf(lat2) * slon * slon); +a=(slat * slat) + (cos(lat1) * cos(lat2) * slon * slon); -return ((2.f * atan2f(sqrtf(a), sqrtf(1.f - a))) * EARTH_RADIUS); +return ((2.f * atan2(sqrt(a), sqrt(1.f - a))) * EARTH_RADIUS); } diff --git a/src/map.c b/src/map.c index 00839e4..a2ae11a 100644 --- a/src/map.c +++ b/src/map.c @@ -281,7 +281,7 @@ void map_set_mark() * given source location. It would have been nice if gdk_pixbuf provided * this method, but I guess it's not general-purpose enough. */ -void +static void map_pixbuf_scale_inplace(GdkPixbuf * pixbuf, guint ratio_p2, guint src_x, guint src_y) { @@ -341,7 +341,7 @@ map_pixbuf_scale_inplace(GdkPixbuf * pixbuf, guint ratio_p2, * Trim pixbufs that are bigger than tiles. (Those pixbufs result, when * captions should be cut off.) */ -GdkPixbuf *pixbuf_trim(GdkPixbuf * pixbuf) +static GdkPixbuf *pixbuf_trim(GdkPixbuf * pixbuf) { vprintf("%s()\n", __PRETTY_FUNCTION__); GdkPixbuf *mpixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, gdk_pixbuf_get_has_alpha(pixbuf), @@ -363,14 +363,14 @@ GdkPixbuf *pixbuf_trim(GdkPixbuf * pixbuf) * trimming. * 'proj' is used for the conversion */ -gchar *map_convert_wms_to_wms(gint tilex, gint tiley, gint zoomlevel, +static gchar *map_convert_wms_to_wms(gint tilex, gint tiley, gint zoomlevel, gchar * uri) { gint system_retcode; 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="); @@ -413,8 +413,7 @@ gchar *map_convert_wms_to_wms(gint tilex, gint tiley, gint zoomlevel, else if (!(in = g_fopen("/tmp/tmpcs2cs", "r"))) g_printerr("Cannot open results of conversion\n"); else if (5 != - fscanf(in, "%f %f %s %f %f", &lon1, &lat1, cmd, &lon2, - &lat2)) { + fscanf(in, "%lf %lf %s %lf %lf", &lon1, &lat1, cmd, &lon2, &lat2)) { g_printerr("Wrong conversion\n"); fclose(in); } else { @@ -432,7 +431,7 @@ gchar *map_convert_wms_to_wms(gint tilex, gint tiley, gint zoomlevel, * Given the xyz coordinates of our map coordinate system, write the qrst * quadtree coordinates to buffer. */ -void +static void map_convert_coords_to_quadtree_string(gint x, gint y, gint zoomlevel, gchar * buffer, const gchar initial, const gchar * const quadrant) @@ -459,7 +458,7 @@ map_convert_coords_to_quadtree_string(gint x, gint y, gint zoomlevel, * the URI format, since that would indicate a quadtree-based map coordinate * system. */ -gchar *map_construct_url(guint tilex, guint tiley, guint zoom) +static gchar *map_construct_url(guint tilex, guint tiley, guint zoom) { vprintf("%s()\n", __PRETTY_FUNCTION__); switch (_curr_repo->type) { @@ -1186,8 +1185,8 @@ void map_scale_draw(GdkEventExpose *event) /* Now calculate and draw the distance. */ { gchar buffer[16]; - gfloat distance; - gfloat lat1, lon1, lat2, lon2; + gdouble distance; + gdouble lat1, lon1, lat2, lon2; gint width; unit2latlon(_center.unitx - pixel2unit(SCALE_WIDTH / 2 - 4), diff --git a/src/map.h b/src/map.h index 6986544..de3cc4f 100644 --- a/src/map.h +++ b/src/map.h @@ -90,4 +90,12 @@ gdouble _map_location_dist; gboolean map_key_zoom_timeout(); gboolean curl_download_timeout(); +void map_set_autozoom(gboolean az); +int map_zoom(gint zdir); +void map_move_mark(); +void map_render_path(Path * path, GdkGC ** gc); +void map_center_unit(guint new_center_unitx, guint new_center_unity); +void map_pan(gint delta_unitx, gint delta_unity); +void map_set_mark(); + #endif