From: Pierre-Luc Beaudoin Date: Sun, 13 Sep 2009 03:25:44 +0000 (-0400) Subject: Fix 594963: Initial scrolling results in map being in Antarctica X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=329ab16d3395a1ae395d2c55807d98246ccaa62c;p=libchamplain Fix 594963: Initial scrolling results in map being in Antarctica The anchor that was being used was resulting in negative x or y values which were clamped back to positive values by TidyAdjustments. This patch makes sure that a new anchor is computed if the anchor would create negative x or y. --- diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c index 9477a9e..0e66a9d 100644 --- a/champlain/champlain-view.c +++ b/champlain/champlain-view.c @@ -1319,8 +1319,8 @@ champlain_view_new (void) static void view_update_anchor (ChamplainView *view, - gint x, - gint y) + gint x, /* Absolute x */ + gint y) /* Absolute y */ { ChamplainViewPrivate *priv = view->priv; gboolean need_anchor = FALSE; @@ -1331,7 +1331,9 @@ view_update_anchor (ChamplainView *view, if (priv->anchor_zoom_level != priv->zoom_level || x - priv->anchor.x + priv->viewport_size.width >= G_MAXINT16 || - y - priv->anchor.y + priv->viewport_size.height >= G_MAXINT16) + y - priv->anchor.y + priv->viewport_size.height >= G_MAXINT16 || + x - priv->anchor.x + priv->viewport_size.width <= 0 || + y - priv->anchor.y + priv->viewport_size.height <= 0 ) need_update = TRUE; if (need_anchor && need_update) @@ -1355,6 +1357,7 @@ view_update_anchor (ChamplainView *view, priv->anchor.y = max; priv->anchor_zoom_level = priv->zoom_level; + DEBUG ("New Anchor (%f, %f) at (%d, %d)", priv->anchor.x, priv->anchor.y, x, y); } if (need_anchor == FALSE) @@ -1362,8 +1365,8 @@ view_update_anchor (ChamplainView *view, priv->anchor.x = 0; priv->anchor.y = 0; priv->anchor_zoom_level = priv->zoom_level; + DEBUG ("Clear Anchor at (%d, %d)", x, y); } - DEBUG ("New Anchor (%f, %f) for (%d, %d)", priv->anchor.x, priv->anchor.y, x, y); } /** @@ -1397,6 +1400,8 @@ champlain_view_center_on (ChamplainView *view, x = champlain_map_source_get_x (priv->map_source, priv->zoom_level, longitude); y = champlain_map_source_get_y (priv->map_source, priv->zoom_level, latitude); + DEBUG ("Centering on %f, %f (%d, %d)", latitude, longitude, x, y); + view_update_anchor (view, x, y); x -= priv->anchor.x; @@ -1610,6 +1615,8 @@ champlain_view_set_zoom_level (ChamplainView *view, if (!map_zoom_to (priv->map, priv->map_source, zoom_level)) return; + DEBUG ("Zooming to %d", zoom_level); + priv->zoom_level = zoom_level; /* Fix to bug 575133: keep the lat,lon as it gets set to a wrong value * when resizing the viewport, when passing from zoom_level 7 to 6