]> err.no Git - mapper/commitdiff
Formating.
authorKaj-Michael Lang <milang@onion.tal.org>
Mon, 16 Jul 2007 13:32:55 +0000 (16:32 +0300)
committerKaj-Michael Lang <milang@onion.tal.org>
Mon, 16 Jul 2007 13:32:55 +0000 (16:32 +0300)
Add debug helper

src/map.c

index ec1a4cec063d475647e0fe2a73d58c6191341c9d..03fdd4d4c3bd4b15f49072b97f618f4ceff95504 100644 (file)
--- 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;