summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Techet <techet@gmail.com>2013-05-02 18:20:55 +0200
committerJiří Techet <techet@gmail.com>2013-05-02 18:20:55 +0200
commit8f73a29d16f2ddb54610ca3c37aca3099a81f737 (patch)
tree0bf4268a0482418732fc10a061862d0bf1434064
parent13fc7124b8da15343d4d327b03399c0284d94727 (diff)
downloadlibchamplain-8f73a29d16f2ddb54610ca3c37aca3099a81f737.tar.gz
Add more tile coordinate checks
-rw-r--r--champlain/champlain-view.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index 1cc40ff..212b91a 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -1802,18 +1802,18 @@ view_load_visible_tiles (ChamplainView *view)
size = champlain_map_source_get_tile_size (priv->map_source);
+ max_x_end = champlain_map_source_get_column_count (priv->map_source, priv->zoom_level);
+ max_y_end = champlain_map_source_get_row_count (priv->map_source, priv->zoom_level);
+
x_count = ceil ((gfloat) priv->viewport_width / size) + 1;
y_count = ceil ((gfloat) priv->viewport_height / size) + 1;
- x_first = priv->viewport_x / size;
- y_first = priv->viewport_y / size;
+ x_first = CLAMP (priv->viewport_x / size, 0, max_x_end);
+ y_first = CLAMP (priv->viewport_y / size, 0, max_y_end);
x_end = x_first + x_count;
y_end = y_first + y_count;
- max_x_end = champlain_map_source_get_column_count (priv->map_source, priv->zoom_level);
- max_y_end = champlain_map_source_get_row_count (priv->map_source, priv->zoom_level);
-
x_end = CLAMP (x_end, x_first, max_x_end);
y_end = CLAMP (y_end, y_first, max_y_end);
@@ -2390,12 +2390,16 @@ show_zoom_actor (ChamplainView *view,
gint size;
gint x_first, y_first;
gdouble zoom_actor_width, zoom_actor_height;
+ gdouble max_x_end, max_y_end;
size = champlain_map_source_get_tile_size (priv->map_source);
- x_first = priv->viewport_x / size;
- y_first = priv->viewport_y / size;
-
+ max_x_end = champlain_map_source_get_column_count (priv->map_source, priv->zoom_level);
+ max_y_end = champlain_map_source_get_row_count (priv->map_source, priv->zoom_level);
+
+ x_first = CLAMP (priv->viewport_x / size, 0, max_x_end);
+ y_first = CLAMP (priv->viewport_y / size, 0, max_y_end);
+
priv->anim_start_zoom_level = priv->zoom_level;
priv->zoom_actor_viewport_x = priv->viewport_x;
priv->zoom_actor_viewport_y = priv->viewport_y;