[libchamplain] When calculating bounding box of a layer, add some margin



commit c7cd8f7885af572b61ac0e1bd62c18420dd19e2f
Author: JiÅ?í Techet <techet gmail com>
Date:   Thu Feb 17 23:48:54 2011 +0100

    When calculating bounding box of a layer, add some margin

 champlain/champlain-marker-layer.c |   12 ++++++++++++
 champlain/champlain-path-layer.c   |   12 ++++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/champlain/champlain-marker-layer.c b/champlain/champlain-marker-layer.c
index 1ddfa45..5578575 100644
--- a/champlain/champlain-marker-layer.c
+++ b/champlain/champlain-marker-layer.c
@@ -876,6 +876,7 @@ get_bounding_box (ChamplainLayer *layer)
   GList *elem;
   ChamplainBoundingBox *bbox;
   GList *markers;
+  double x, y;
 
   g_return_val_if_fail (CHAMPLAIN_IS_MARKER_LAYER (layer), NULL);
   
@@ -895,6 +896,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);
 
   return bbox;
 }
diff --git a/champlain/champlain-path-layer.c b/champlain/champlain-path-layer.c
index fc92c8f..773030c 100644
--- a/champlain/champlain-path-layer.c
+++ b/champlain/champlain-path-layer.c
@@ -807,6 +807,7 @@ get_bounding_box (ChamplainLayer *layer)
   ChamplainPathLayerPrivate *priv = GET_PRIVATE (layer);
   GList *elem;
   ChamplainBoundingBox *bbox;
+  gdouble x, y;
   
   bbox = champlain_bounding_box_new ();
 
@@ -821,6 +822,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);
+
+  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);
+
   return bbox;
 }
 



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