/* 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);
_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);
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];
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;
}
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;