[libchamplain] Add champlain_view_get_bounding_box()
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Add champlain_view_get_bounding_box()
- Date: Tue, 16 Apr 2013 21:34:10 +0000 (UTC)
commit ea12c7b684a205398477740e96bd602cfbd10113
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Apr 16 18:57:47 2013 +0300
Add champlain_view_get_bounding_box()
Add method to get bounding box of the view.
https://bugzilla.gnome.org/show_bug.cgi?id=698143
champlain/champlain-view.c | 43 +++++++++++++++++++++++++++++++++++++++++++
champlain/champlain-view.h | 2 ++
2 files changed, 45 insertions(+)
---
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index 3b40bc9..aed1f99 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -2962,3 +2962,46 @@ champlain_view_get_state (ChamplainView *view)
return view->priv->state;
}
+
+/**
+ * champlain_view_get_bounding_box:
+ * @view: a #ChamplainView
+ *
+ * Gets the bounding box for view @view at current zoom-level.
+ *
+ * Returns: (transfer full): the bounding box
+ *
+ * Since: 0.12
+ */
+ChamplainBoundingBox *
+champlain_view_get_bounding_box (ChamplainView *view)
+{
+ DEBUG_LOG ()
+
+ ChamplainViewPrivate *priv = view->priv;
+ ChamplainBoundingBox *bbox;
+ gdouble x, y;
+
+ g_return_val_if_fail (CHAMPLAIN_IS_VIEW (view), NULL);
+
+ bbox = champlain_bounding_box_new ();
+
+ x = priv->viewport_x + priv->anchor_x;
+ y = priv->viewport_y + priv->anchor_y;
+
+ bbox->top = champlain_map_source_get_latitude (priv->map_source,
+ priv->zoom_level,
+ y);
+ bbox->bottom = champlain_map_source_get_latitude (priv->map_source,
+ priv->zoom_level,
+ y + priv->viewport_height);
+
+ bbox->left = champlain_map_source_get_longitude (priv->map_source,
+ priv->zoom_level,
+ x);
+ bbox->right = champlain_map_source_get_longitude (priv->map_source,
+ priv->zoom_level,
+ x + priv->viewport_width);
+
+ return bbox;
+}
diff --git a/champlain/champlain-view.h b/champlain/champlain-view.h
index 244e24b..98adc4c 100644
--- a/champlain/champlain-view.h
+++ b/champlain/champlain-view.h
@@ -160,6 +160,8 @@ void champlain_view_bin_layout_add (ChamplainView *view,
ChamplainLicense *champlain_view_get_license_actor (ChamplainView *view);
+ChamplainBoundingBox *champlain_view_get_bounding_box (ChamplainView *view);
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]