[geocode-glib] location: Add altitude property
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geocode-glib] location: Add altitude property
- Date: Mon, 16 Dec 2013 21:26:29 +0000 (UTC)
commit fdb74adc02f797941e96698c8847e3b19f86e3cc
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Wed Nov 13 22:50:57 2013 +0100
location: Add altitude property
Add altitude in meters to geocode-location.
https://bugzilla.gnome.org/show_bug.cgi?id=706130
geocode-glib/geocode-glib.symbols | 1 +
geocode-glib/geocode-location.c | 54 ++++++++++++++++++++++++++++++++++++-
geocode-glib/geocode-location.h | 8 +++++
3 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/geocode-glib/geocode-glib.symbols b/geocode-glib/geocode-glib.symbols
index d74680b..1115df5 100644
--- a/geocode-glib/geocode-glib.symbols
+++ b/geocode-glib/geocode-glib.symbols
@@ -6,6 +6,7 @@ geocode_location_get_description
geocode_location_get_distance_from
geocode_location_get_latitude
geocode_location_get_longitude
+geocode_location_get_altitude
geocode_location_get_timestamp
geocode_location_set_description
geocode_forward_get_type
diff --git a/geocode-glib/geocode-location.c b/geocode-glib/geocode-location.c
index 44817d3..3dae78e 100644
--- a/geocode-glib/geocode-location.c
+++ b/geocode-glib/geocode-location.c
@@ -38,6 +38,7 @@
struct _GeocodeLocationPrivate {
gdouble longitude;
gdouble latitude;
+ gdouble altitude;
gdouble accuracy;
guint64 timestamp;
char *description;
@@ -50,7 +51,8 @@ enum {
PROP_LONGITUDE,
PROP_ACCURACY,
PROP_DESCRIPTION,
- PROP_TIMESTAMP
+ PROP_TIMESTAMP,
+ PROP_ALTITUDE
};
G_DEFINE_TYPE (GeocodeLocation, geocode_location, G_TYPE_OBJECT)
@@ -79,6 +81,11 @@ geocode_location_get_property (GObject *object,
geocode_location_get_longitude (location));
break;
+ case PROP_ALTITUDE:
+ g_value_set_double (value,
+ geocode_location_get_altitude (location));
+ break;
+
case PROP_ACCURACY:
g_value_set_double (value,
geocode_location_get_accuracy (location));
@@ -115,6 +122,13 @@ geocode_location_set_longitude (GeocodeLocation *loc,
}
static void
+geocode_location_set_altitude (GeocodeLocation *loc,
+ gdouble altitude)
+{
+ loc->priv->altitude = altitude;
+}
+
+static void
geocode_location_set_accuracy (GeocodeLocation *loc,
gdouble accuracy)
{
@@ -147,6 +161,11 @@ geocode_location_set_property(GObject *object,
g_value_get_double (value));
break;
+ case PROP_ALTITUDE:
+ geocode_location_set_altitude (location,
+ g_value_get_double (value));
+ break;
+
case PROP_ACCURACY:
geocode_location_set_accuracy (location,
g_value_get_double (value));
@@ -225,6 +244,21 @@ geocode_location_class_init (GeocodeLocationClass *klass)
g_object_class_install_property (glocation_class, PROP_LONGITUDE, pspec);
/**
+ * GeocodeLocation:altitude:
+ *
+ * The altitude of this location in meters.
+ */
+ pspec = g_param_spec_double ("altitude",
+ "Altitude",
+ "The altitude of this location in meters",
+ GEOCODE_LOCATION_ALTITUDE_UNKNOWN,
+ G_MAXDOUBLE,
+ GEOCODE_LOCATION_ALTITUDE_UNKNOWN,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (glocation_class, PROP_ALTITUDE, pspec);
+
+ /**
* GeocodeLocation:accuracy:
*
* The accuracy of this location in meters.
@@ -268,6 +302,7 @@ geocode_location_init (GeocodeLocation *location)
g_get_current_time (&tv);
location->priv->timestamp = tv.tv_sec;
+ location->priv->altitude = GEOCODE_LOCATION_ALTITUDE_UNKNOWN;
}
/**
@@ -383,6 +418,23 @@ geocode_location_get_longitude (GeocodeLocation *loc)
}
/**
+ * geocode_location_get_altitude:
+ * @loc: a #GeocodeLocation
+ *
+ * Gets the altitude of location @loc.
+ *
+ * Returns: The altitude of location @loc.
+ **/
+gdouble
+geocode_location_get_altitude (GeocodeLocation *loc)
+{
+ g_return_val_if_fail (GEOCODE_IS_LOCATION (loc),
+ GEOCODE_LOCATION_ALTITUDE_UNKNOWN);
+
+ return loc->priv->altitude;
+}
+
+/**
* geocode_location_get_accuracy:
* @loc: a #GeocodeLocation
*
diff --git a/geocode-glib/geocode-location.h b/geocode-glib/geocode-location.h
index 6e1e8bf..18b9b11 100644
--- a/geocode-glib/geocode-location.h
+++ b/geocode-glib/geocode-location.h
@@ -63,6 +63,13 @@ struct _GeocodeLocationClass {
};
/**
+ * GEOCODE_LOCATION_ALTITUDE_UNKNOWN:
+ *
+ * Constant representing unknown altitude.
+ */
+#define GEOCODE_LOCATION_ALTITUDE_UNKNOWN -G_MAXDOUBLE
+
+/**
* GEOCODE_LOCATION_ACCURACY_UNKNOWN:
*
* Constant representing unknown accuracy.
@@ -125,6 +132,7 @@ const char *geocode_location_get_description (GeocodeLocation *loc);
gdouble geocode_location_get_latitude (GeocodeLocation *loc);
gdouble geocode_location_get_longitude (GeocodeLocation *loc);
+gdouble geocode_location_get_altitude (GeocodeLocation *loc);
gdouble geocode_location_get_accuracy (GeocodeLocation *loc);
guint64 geocode_location_get_timestamp (GeocodeLocation *loc);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]