[libchamplain] Add champlain_bounding_box_covers()
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Add champlain_bounding_box_covers()
- Date: Tue, 16 Apr 2013 21:34:15 +0000 (UTC)
commit 2e2ccc34d92ad2ee71487e22565856149ee438be
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Apr 16 18:59:18 2013 +0300
Add champlain_bounding_box_covers()
Add a method to check if a particular location is covered by a bounding
box.
https://bugzilla.gnome.org/show_bug.cgi?id=698143
champlain/champlain-bounding-box.c | 21 +++++++++++++++++++++
champlain/champlain-bounding-box.h | 4 ++++
2 files changed, 25 insertions(+)
---
diff --git a/champlain/champlain-bounding-box.c b/champlain/champlain-bounding-box.c
index e84e58b..50a6238 100644
--- a/champlain/champlain-bounding-box.c
+++ b/champlain/champlain-bounding-box.c
@@ -216,3 +216,24 @@ champlain_bounding_box_is_valid (ChamplainBoundingBox *bbox)
(bbox->bottom > CHAMPLAIN_MIN_LATITUDE) && (bbox->bottom < CHAMPLAIN_MAX_LATITUDE) &&
(bbox->top > CHAMPLAIN_MIN_LATITUDE) && (bbox->top < CHAMPLAIN_MAX_LATITUDE);
}
+
+/**
+ * champlain_bounding_box_covers:
+ * @bbox: a #ChamplainBoundingBox
+ *
+ * Checks whether @bbox covers the given coordinates.
+ *
+ * Returns: TRUE when the bounding box covers given coordinates, FALSE otherwise.
+ *
+ * Since: 0.12
+ */
+gboolean
+champlain_bounding_box_covers(ChamplainBoundingBox *bbox,
+ gdouble latitude,
+ gdouble longitude)
+{
+ g_return_val_if_fail (CHAMPLAIN_BOUNDING_BOX (bbox), FALSE);
+
+ return ((latitude >= bbox->bottom && latitude <= bbox->top) &&
+ (longitude >= bbox->left && longitude <= bbox->right));
+}
diff --git a/champlain/champlain-bounding-box.h b/champlain/champlain-bounding-box.h
index 1e01a33..5ed3083 100644
--- a/champlain/champlain-bounding-box.h
+++ b/champlain/champlain-bounding-box.h
@@ -73,6 +73,10 @@ void champlain_bounding_box_extend (ChamplainBoundingBox *bbox,
gboolean champlain_bounding_box_is_valid (ChamplainBoundingBox *bbox);
+gboolean champlain_bounding_box_covers(ChamplainBoundingBox *bbox,
+ gdouble latitude,
+ gdouble longitude);
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]