[libchamplain] Fix layer ensure visible



commit 63f31653a23d0c24ba3495424489fce9fa752fbc
Author: JiÅ?í Techet <techet gmail com>
Date:   Sun Feb 20 19:16:31 2011 +0100

    Fix layer ensure visible
    
    We change zoom levels in the ensure visible function and cannot make
    any assumption on the conversion between pixels and latitude/longitude.

 champlain/champlain-marker-layer.c |   22 +++++++++++-----------
 champlain/champlain-path-layer.c   |   20 ++++++++++----------
 2 files changed, 21 insertions(+), 21 deletions(-)
---
diff --git a/champlain/champlain-marker-layer.c b/champlain/champlain-marker-layer.c
index 3f002f5..8601183 100644
--- a/champlain/champlain-marker-layer.c
+++ b/champlain/champlain-marker-layer.c
@@ -928,7 +928,6 @@ get_bounding_box (ChamplainLayer *layer)
   GList *elem;
   ChamplainBoundingBox *bbox;
   GList *markers;
-  gdouble x, y;
 
   g_return_val_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer), NULL);
   
@@ -949,16 +948,17 @@ get_bounding_box (ChamplainLayer *layer)
 
   g_list_free (markers);
   
-  // TODO: make the margin such that markers fit inside
-  x = champlain_view_longitude_to_x (priv->view, bbox->left);
-  y = champlain_view_latitude_to_y (priv->view, bbox->top);  
-  bbox->left = champlain_view_x_to_longitude (priv->view, x - 10);
-  bbox->top = champlain_view_y_to_latitude (priv->view, y - 10);
-
-  x = champlain_view_longitude_to_x (priv->view, bbox->right);
-  y = champlain_view_latitude_to_y (priv->view, bbox->bottom);  
-  bbox->right = champlain_view_x_to_longitude (priv->view, x + 10);
-  bbox->bottom = champlain_view_y_to_latitude (priv->view, y + 10);
+  if (bbox->left == bbox->right)
+    {
+      bbox->left -= 0.0001;
+      bbox->right += 0.0001;
+    }
+
+  if (bbox->bottom == bbox->top)
+    {
+      bbox->bottom -= 0.0001;
+      bbox->top += 0.0001;
+    }
 
   return bbox;
 }
diff --git a/champlain/champlain-path-layer.c b/champlain/champlain-path-layer.c
index 806f89c..8b61c10 100644
--- a/champlain/champlain-path-layer.c
+++ b/champlain/champlain-path-layer.c
@@ -806,7 +806,6 @@ get_bounding_box (ChamplainLayer *layer)
   ChamplainPathLayerPrivate *priv = GET_PRIVATE (layer);
   GList *elem;
   ChamplainBoundingBox *bbox;
-  gdouble x, y;
   
   bbox = champlain_bounding_box_new ();
 
@@ -821,16 +820,17 @@ get_bounding_box (ChamplainLayer *layer)
       champlain_bounding_box_extend (bbox, lat, lon); 
     }
 
-  // TODO: make the margin such that markers fit inside
-  x = champlain_view_longitude_to_x (priv->view, bbox->left);
-  y = champlain_view_latitude_to_y (priv->view, bbox->top);  
-  bbox->left = champlain_view_x_to_longitude (priv->view, x - 10);
-  bbox->top = champlain_view_y_to_latitude (priv->view, y - 10);
+  if (bbox->left == bbox->right)
+    {
+      bbox->left -= 0.0001;
+      bbox->right += 0.0001;
+    }
 
-  x = champlain_view_longitude_to_x (priv->view, bbox->right);
-  y = champlain_view_latitude_to_y (priv->view, bbox->bottom);  
-  bbox->right = champlain_view_x_to_longitude (priv->view, x + 10);
-  bbox->bottom = champlain_view_y_to_latitude (priv->view, y + 10);
+  if (bbox->bottom == bbox->top)
+    {
+      bbox->bottom -= 0.0001;
+      bbox->top += 0.0001;
+    }
 
   return bbox;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]