From bc552140975521d09a1b4aafe97f68bea1866e44 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Mon, 16 Jul 2007 16:32:55 +0300 Subject: [PATCH] Formating. Add debug helper --- src/map.c | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/src/map.c b/src/map.c index ec1a4ce..03fdd4d 100644 --- a/src/map.c +++ b/src/map.c @@ -781,17 +781,13 @@ void map_set_zoom(guint new_zoom) /* Update center bounds to reflect new zoom level. */ _min_center.unitx = pixel2unit(grid2pixel(_screen_grids_halfwidth)); _min_center.unity = pixel2unit(grid2pixel(_screen_grids_halfheight)); - _max_center.unitx = - WORLD_SIZE_UNITS - grid2unit(_screen_grids_halfwidth) - 1; - _max_center.unity = - WORLD_SIZE_UNITS - grid2unit(_screen_grids_halfheight) - 1; + _max_center.unitx = WORLD_SIZE_UNITS - grid2unit(_screen_grids_halfwidth) - 1; + _max_center.unity = WORLD_SIZE_UNITS - grid2unit(_screen_grids_halfheight) - 1; BOUND(_center.unitx, _min_center.unitx, _max_center.unitx); BOUND(_center.unity, _min_center.unity, _max_center.unity); - _base_tilex = grid2tile((gint) pixel2grid((gint) - unit2pixel((gint) _center. - unitx)) + _base_tilex = grid2tile((gint) pixel2grid((gint) unit2pixel((gint) _center.unitx)) - (gint) _screen_grids_halfwidth); _base_tiley = grid2tile(pixel2grid(unit2pixel(_center.unity)) - _screen_grids_halfheight); @@ -827,10 +823,8 @@ void map_center_unit(guint new_center_unitx, guint new_center_unity) _center.unitx = new_center_unitx; _center.unity = new_center_unity; - new_base_tilex = grid2tile((gint) pixel2grid((gint) - unit2pixel((gint) _center. - unitx)) - - (gint) _screen_grids_halfwidth); + new_base_tilex = grid2tile((gint) pixel2grid((gint)unit2pixel((gint) _center.unitx)) + - (gint)_screen_grids_halfwidth); new_base_tiley = grid2tile(pixel2grid(unit2pixel(_center.unity)) - _screen_grids_halfheight); @@ -1182,11 +1176,9 @@ void map_scale_draw(GdkEventExpose *event) gfloat lat1, lon1, lat2, lon2; gint width; - unit2latlon(_center.unitx - - pixel2unit(SCALE_WIDTH / 2 - 4), + unit2latlon(_center.unitx - pixel2unit(SCALE_WIDTH / 2 - 4), _center.unity, lat1, lon1); - unit2latlon(_center.unitx + - pixel2unit(SCALE_WIDTH / 2 - 4), + unit2latlon(_center.unitx + pixel2unit(SCALE_WIDTH / 2 - 4), _center.unity, lat2, lon2); distance = calculate_distance(lat1, lon1, lat2, lon2) * UNITS_CONVERT[_units]; @@ -1360,13 +1352,30 @@ static void map_draw_track(gint x, gint y) refresh_mark(); } +static void map_print_int_latlon(gint x, gint y) +{ +gint ux, uy; +gdouble lat,lon; + +ux = x2unit((gint) (x + 0.5)); +uy = y2unit((gint) (y + 0.5)); +unit2latlon(ux, uy, lat, lon); + +g_printf("IntPos: %d , %d\n", lat2mp_int(lat), lon2mp_int(lon)); +} + gboolean map_cb_scroll_event(GtkWidget * widget, GdkEventScroll * event) { - if (event->direction == GDK_SCROLL_UP) + if (event->direction == GDK_SCROLL_UP) { + map_center_unit(x2unit((gint) (event->x + 0.5)), + y2unit((gint) (event->y + 0.5))); map_set_zoom(_zoom - 1); - else if (event->direction == GDK_SCROLL_DOWN) + } else if (event->direction == GDK_SCROLL_DOWN) { + map_center_unit(x2unit((gint) (event->x + 0.5)), + y2unit((gint) (event->y + 0.5))); map_set_zoom(_zoom + 1); + } return FALSE; } @@ -1433,8 +1442,11 @@ gboolean map_cb_button_release(GtkWidget * widget, GdkEventButton * event) break; } + map_print_int_latlon(event->x,event->y); + map_center_unit(x2unit((gint) (event->x + 0.5)), y2unit((gint) (event->y + 0.5))); + break; case 2: release[0] = event->x; -- 2.39.5