[geocode-glib] Add new object GeocodeBoundingBox
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geocode-glib] Add new object GeocodeBoundingBox
- Date: Thu, 5 Dec 2013 15:07:36 +0000 (UTC)
commit aed6c80fee165419326331744065ac73bdb3e52a
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Tue Dec 3 12:59:16 2013 +0100
Add new object GeocodeBoundingBox
Add an object representing a geographical area.
https://bugzilla.gnome.org/show_bug.cgi?id=719585
docs/geocode-glib-docs.xml | 1 +
geocode-glib/Makefile.am | 6 +-
geocode-glib/geocode-bounding-box.c | 335 +++++++++++++++++++++++++++++++++++
geocode-glib/geocode-bounding-box.h | 79 ++++++++
geocode-glib/geocode-glib.h | 1 +
geocode-glib/geocode-glib.symbols | 6 +
6 files changed, 426 insertions(+), 2 deletions(-)
---
diff --git a/docs/geocode-glib-docs.xml b/docs/geocode-glib-docs.xml
index ab052ed..915eb6f 100644
--- a/docs/geocode-glib-docs.xml
+++ b/docs/geocode-glib-docs.xml
@@ -23,6 +23,7 @@
<xi:include href="xml/geocode-place.xml"/>
<xi:include href="xml/geocode-reverse.xml"/>
<xi:include href="xml/geocode-enum-types.xml"/>
+ <xi:include href="xml/geocode-bounding-box.xml"/>
</chapter>
<index id="api-index-full">
diff --git a/geocode-glib/Makefile.am b/geocode-glib/Makefile.am
index c4ededb..80cda77 100644
--- a/geocode-glib/Makefile.am
+++ b/geocode-glib/Makefile.am
@@ -13,7 +13,8 @@ libgeocode_glib_la_PUBLICSOURCES = \
geocode-glib.c \
geocode-error.c \
geocode-enum-types.c \
- geocode-place.c
+ geocode-place.c \
+ geocode-bounding-box.c
libgeocode_glib_la_SOURCES = \
$(libgeocode_glib_la_PUBLICSOURCES) \
@@ -33,7 +34,8 @@ GCGLIB_HEADER_FILES = \
geocode-forward.h \
geocode-reverse.h \
geocode-error.h \
- geocode-place.h
+ geocode-place.h \
+ geocode-bounding-box.h
gcglibdir = $(includedir)/$(PACKAGE)-$(GCLIB_API_VERSION)/$(PACKAGE)
gcglib_HEADERS = \
diff --git a/geocode-glib/geocode-bounding-box.c b/geocode-glib/geocode-bounding-box.c
new file mode 100644
index 0000000..64da81d
--- /dev/null
+++ b/geocode-glib/geocode-bounding-box.c
@@ -0,0 +1,335 @@
+/*
+ Copyright (C) 2013 Jonas Danielsson
+
+ The Gnome Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA.
+
+ Authors: Jonas Danielsson <jonas threetimestwo org>
+
+ */
+
+#include <geocode-glib/geocode-bounding-box.h>
+
+/**
+ * SECTION:geocode-bounding-box
+ * @short_description: Geocode BoundingBox object
+ * @include: geocode-glib/geocode-bounding-box.h
+ *
+ * The #GeocodeBoundingBox represents a geographical area on earth, bounded
+ * by top, bottom, left and right coordinates.
+ **/
+
+struct _GeocodeBoundingBoxPrivate {
+ gdouble top;
+ gdouble bottom;
+ gdouble left;
+ gdouble right;
+};
+
+enum {
+ PROP_0,
+
+ PROP_TOP,
+ PROP_BOTTOM,
+ PROP_LEFT,
+ PROP_RIGHT
+};
+
+G_DEFINE_TYPE (GeocodeBoundingBox, geocode_bounding_box, G_TYPE_OBJECT)
+
+static void
+geocode_bounding_box_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GeocodeBoundingBox *bbox = GEOCODE_BOUNDING_BOX (object);
+
+ switch (property_id) {
+ case PROP_TOP:
+ g_value_set_double (value,
+ geocode_bounding_box_get_top (bbox));
+ break;
+
+ case PROP_BOTTOM:
+ g_value_set_double (value,
+ geocode_bounding_box_get_bottom (bbox));
+ break;
+
+ case PROP_LEFT:
+ g_value_set_double (value,
+ geocode_bounding_box_get_left (bbox));
+ break;
+
+ case PROP_RIGHT:
+ g_value_set_double (value,
+ geocode_bounding_box_get_right (bbox));
+ break;
+
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+geocode_bounding_box_set_top (GeocodeBoundingBox *bbox,
+ gdouble top)
+{
+ g_return_if_fail (top >= -90.0 && top <= 90.0);
+
+ bbox->priv->top = top;
+}
+
+static void
+geocode_bounding_box_set_bottom (GeocodeBoundingBox *bbox,
+ gdouble bottom)
+{
+ g_return_if_fail (bottom >= -90.0 && bottom <= 90.0);
+
+ bbox->priv->bottom = bottom;
+}
+
+static void
+geocode_bounding_box_set_left (GeocodeBoundingBox *bbox,
+ gdouble left)
+{
+ g_return_if_fail (left >= -180.0 && left <= 180.0);
+
+ bbox->priv->left = left;
+}
+
+static void
+geocode_bounding_box_set_right (GeocodeBoundingBox *bbox,
+ gdouble right)
+{
+ g_return_if_fail (right >= -180.0 && right <= 180.0);
+
+ bbox->priv->right = right;
+}
+
+static void
+geocode_bounding_box_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GeocodeBoundingBox *bbox = GEOCODE_BOUNDING_BOX (object);
+
+ switch (property_id) {
+ case PROP_TOP:
+ geocode_bounding_box_set_top (bbox,
+ g_value_get_double (value));
+ break;
+
+ case PROP_BOTTOM:
+ geocode_bounding_box_set_bottom (bbox,
+ g_value_get_double (value));
+ break;
+
+ case PROP_LEFT:
+ geocode_bounding_box_set_left (bbox,
+ g_value_get_double (value));
+ break;
+
+ case PROP_RIGHT:
+ geocode_bounding_box_set_right (bbox,
+ g_value_get_double (value));
+ break;
+
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+geocode_bounding_box_finalize (GObject *gbbox)
+{
+ G_OBJECT_CLASS (geocode_bounding_box_parent_class)->finalize (gbbox);
+}
+
+static void
+geocode_bounding_box_class_init (GeocodeBoundingBoxClass *klass)
+{
+ GObjectClass *gbbox_class = G_OBJECT_CLASS (klass);
+ GParamSpec *pspec;
+
+ gbbox_class->finalize = geocode_bounding_box_finalize;
+ gbbox_class->get_property = geocode_bounding_box_get_property;
+ gbbox_class->set_property = geocode_bounding_box_set_property;
+
+ g_type_class_add_private (klass, sizeof (GeocodeBoundingBoxPrivate));
+
+ /**
+ * GeocodeBoundingBox:top:
+ *
+ * Top coordinate.
+ */
+ pspec = g_param_spec_double ("top",
+ "Top",
+ "Top coordinate",
+ -90,
+ 90,
+ 0.0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (gbbox_class, PROP_TOP, pspec);
+
+ /**
+ * GeocodeBoundingBox:bottom:
+ *
+ * Bottom coordinate.
+ */
+ pspec = g_param_spec_double ("bottom",
+ "Bottom",
+ "Bottom coordinate",
+ -90,
+ 90,
+ 0.0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (gbbox_class, PROP_BOTTOM, pspec);
+
+ /**
+ * GeocodeBoundingBox:left:
+ *
+ * Left coordinate.
+ */
+ pspec = g_param_spec_double ("left",
+ "Left",
+ "Left coordinate",
+ -180,
+ 180,
+ 0.0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (gbbox_class, PROP_LEFT, pspec);
+
+ /**
+ * GeocodeBoundingBox:right:
+ *
+ * Right coordinate.
+ */
+ pspec = g_param_spec_double ("right",
+ "Right",
+ "Right coordinate",
+ -180,
+ 180,
+ 0.0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (gbbox_class, PROP_RIGHT, pspec);
+
+}
+
+static void
+geocode_bounding_box_init (GeocodeBoundingBox *bbox)
+{
+ bbox->priv = G_TYPE_INSTANCE_GET_PRIVATE ((bbox),
+ GEOCODE_TYPE_BOUNDING_BOX,
+ GeocodeBoundingBoxPrivate);
+}
+
+/**
+ * geocode_bounding_box_new:
+ *
+ * Creates a new #GeocodeBoundingBox object.
+ *
+ * Returns: a new #GeocodeBoundingBox object. Use g_object_unref() when done.
+ **/
+GeocodeBoundingBox *
+geocode_bounding_box_new (gdouble top,
+ gdouble bottom,
+ gdouble left,
+ gdouble right)
+{
+ return g_object_new (GEOCODE_TYPE_BOUNDING_BOX,
+ "top", top,
+ "bottom", bottom,
+ "left", left,
+ "right", right,
+ NULL);
+}
+
+/**
+ * geocode_bounding_box_get_top:
+ * @bbox: a #GeocodeBoundingBox
+ *
+ * Gets the top coordinate of @bbox.
+ *
+ * Returns: the top coordinate of @bbox.
+ **/
+gdouble
+geocode_bounding_box_get_top (GeocodeBoundingBox *bbox)
+{
+ g_return_val_if_fail (GEOCODE_IS_BOUNDING_BOX (bbox), 0.0);
+
+ return bbox->priv->top;
+}
+
+/**
+ * geocode_bounding_box_get_bottom:
+ * @bbox: a #GeocodeBoundingBox
+ *
+ * Gets the bottom coordinate of @bbox.
+ *
+ * Returns: the bottom coordinate of @bbox.
+ **/
+gdouble
+geocode_bounding_box_get_bottom (GeocodeBoundingBox *bbox)
+{
+ g_return_val_if_fail (GEOCODE_IS_BOUNDING_BOX (bbox), 0.0);
+
+ return bbox->priv->bottom;
+}
+
+/**
+ * geocode_bounding_box_get_left:
+ * @bbox: a #GeocodeBoundingBox
+ *
+ * Gets the left coordinate of @bbox.
+ *
+ * Returns: the left coordinate of @bbox.
+ **/
+gdouble
+geocode_bounding_box_get_left (GeocodeBoundingBox *bbox)
+{
+ g_return_val_if_fail (GEOCODE_IS_BOUNDING_BOX (bbox), 0.0);
+
+ return bbox->priv->left;
+}
+
+/**
+ * geocode_bounding_box_get_right:
+ * @bbox: a #GeocodeBoundingBox
+ *
+ * Gets the right coordinate of @bbox.
+ *
+ * Returns: the right coordinate of @bbox.
+ **/
+gdouble
+geocode_bounding_box_get_right (GeocodeBoundingBox *bbox)
+{
+ g_return_val_if_fail (GEOCODE_IS_BOUNDING_BOX (bbox), 0.0);
+
+ return bbox->priv->right;
+}
diff --git a/geocode-glib/geocode-bounding-box.h b/geocode-glib/geocode-bounding-box.h
new file mode 100644
index 0000000..5de55ea
--- /dev/null
+++ b/geocode-glib/geocode-bounding-box.h
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2013 Jonas Danielsson
+
+ The Gnome Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301 USA.
+
+ Authors: Jonas Danielsson <jonas threetimestwo org>
+
+ */
+
+#ifndef GEOCODE_BOUNDING_BOX_H
+#define GEOCODE_BOUNDING_BOX_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+GType geocode_bounding_box_get_type (void) G_GNUC_CONST;
+
+#define GEOCODE_TYPE_BOUNDING_BOX (geocode_bounding_box_get_type ())
+#define GEOCODE_BOUNDING_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GEOCODE_TYPE_BOUNDING_BOX, GeocodeBoundingBox))
+#define GEOCODE_IS_BOUNDING_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GEOCODE_TYPE_BOUNDING_BOX))
+#define GEOCODE_BOUNDING_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GEOCODE_TYPE_BOUNDING_BOX, GeocodeBoundingBoxClass))
+#define GEOCODE_IS_BOUNDING_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GEOCODE_TYPE_BOUNDING_BOX))
+#define GEOCODE_BOUNDING_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GEOCODE_TYPE_BOUNDING_BOX, GeocodeBoundingBoxClass))
+
+
+typedef struct _GeocodeBoundingBox GeocodeBoundingBox;
+typedef struct _GeocodeBoundingBoxClass GeocodeBoundingBoxClass;
+typedef struct _GeocodeBoundingBoxPrivate GeocodeBoundingBoxPrivate;
+
+/**
+ * GeocodeBoundingBox:
+ *
+ * All the fields in the #GeocodeLocation structure are private and should
+ * never be accessed directly.
+**/
+struct _GeocodeBoundingBox {
+ /* <private> */
+ GObject parent_instance;
+ GeocodeBoundingBoxPrivate *priv;
+};
+
+/**
+ * GeocodeBoundingBoxClass:
+ *
+ * All the fields in the #GeocodeBoundingBoxClass structure are private and
+ * should never be accessed directly.
+**/
+struct _GeocodeBoundingBoxClass {
+ /* <private> */
+ GObjectClass parent_class;
+};
+
+GeocodeBoundingBox *geocode_bounding_box_new (gdouble top,
+ gdouble bottom,
+ gdouble left,
+ gdouble right);
+
+gdouble geocode_bounding_box_get_top (GeocodeBoundingBox *bbox);
+gdouble geocode_bounding_box_get_bottom (GeocodeBoundingBox *bbox);
+gdouble geocode_bounding_box_get_left (GeocodeBoundingBox *bbox);
+gdouble geocode_bounding_box_get_right (GeocodeBoundingBox *bbox);
+
+G_END_DECLS
+
+#endif /* GEOCODE_BOUNDING_BOX_H */
diff --git a/geocode-glib/geocode-glib.h b/geocode-glib/geocode-glib.h
index 7b7a5e8..a72c045 100644
--- a/geocode-glib/geocode-glib.h
+++ b/geocode-glib/geocode-glib.h
@@ -29,6 +29,7 @@
#include <geocode-glib/geocode-place.h>
#include <geocode-glib/geocode-forward.h>
#include <geocode-glib/geocode-reverse.h>
+#include <geocode-glib/geocode-bounding-box.h>
#include <geocode-glib/geocode-error.h>
#include <geocode-glib/geocode-enum-types.h>
diff --git a/geocode-glib/geocode-glib.symbols b/geocode-glib/geocode-glib.symbols
index b4e7d04..9a09bb5 100644
--- a/geocode-glib/geocode-glib.symbols
+++ b/geocode-glib/geocode-glib.symbols
@@ -63,3 +63,9 @@ geocode_place_get_country
geocode_place_set_continent
geocode_place_get_continent
geocode_place_get_icon
+geocode_bounding_box_get_type
+geocode_bounding_box_new
+geocode_bounding_box_get_top
+geocode_bounding_box_get_bottom
+geocode_bounding_box_get_left
+geocode_bounding_box_get_right
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]