[geocode-glib] location: Add CRS property



commit 525c3560ad1ee3cf8cda0c62c7c29a5dd06071fb
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Mon Dec 9 13:02:52 2013 +0100

    location: Add CRS property
    
    Add a property defining the coordinate reference system of a
    geocode-location.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706130

 geocode-glib/geocode-glib.symbols |    2 +
 geocode-glib/geocode-location.c   |   72 +++++++++++++++++++++++++++++++++----
 geocode-glib/geocode-location.h   |   11 ++++++
 3 files changed, 78 insertions(+), 7 deletions(-)
---
diff --git a/geocode-glib/geocode-glib.symbols b/geocode-glib/geocode-glib.symbols
index 1115df5..38fc28b 100644
--- a/geocode-glib/geocode-glib.symbols
+++ b/geocode-glib/geocode-glib.symbols
@@ -1,4 +1,5 @@
 geocode_location_get_type
+geocode_location_crs_get_type
 geocode_location_new
 geocode_location_new_with_description
 geocode_location_get_accuracy
@@ -7,6 +8,7 @@ geocode_location_get_distance_from
 geocode_location_get_latitude
 geocode_location_get_longitude
 geocode_location_get_altitude
+geocode_location_get_crs
 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 3dae78e..9fd9ad1 100644
--- a/geocode-glib/geocode-location.c
+++ b/geocode-glib/geocode-location.c
@@ -21,6 +21,8 @@
 
  */
 
+#include <geocode-glib/geocode-error.h>
+#include <geocode-glib/geocode-enum-types.h>
 #include <math.h>
 #include "geocode-location.h"
 
@@ -36,12 +38,13 @@
  **/
 
 struct _GeocodeLocationPrivate {
-        gdouble longitude;
-        gdouble latitude;
-        gdouble altitude;
-        gdouble accuracy;
-        guint64 timestamp;
-        char   *description;
+        gdouble            longitude;
+        gdouble            latitude;
+        gdouble            altitude;
+        gdouble            accuracy;
+        guint64            timestamp;
+        char              *description;
+        GeocodeLocationCRS crs;
 };
 
 enum {
@@ -52,7 +55,8 @@ enum {
         PROP_ACCURACY,
         PROP_DESCRIPTION,
         PROP_TIMESTAMP,
-        PROP_ALTITUDE
+        PROP_ALTITUDE,
+        PROP_CRS,
 };
 
 G_DEFINE_TYPE (GeocodeLocation, geocode_location, G_TYPE_OBJECT)
@@ -91,6 +95,11 @@ geocode_location_get_property (GObject    *object,
                                     geocode_location_get_accuracy (location));
                 break;
 
+        case PROP_CRS:
+                g_value_set_enum (value,
+                                  geocode_location_get_crs (location));
+                break;
+
         case PROP_TIMESTAMP:
                 g_value_set_uint64 (value,
                                     geocode_location_get_timestamp (location));
@@ -138,6 +147,15 @@ geocode_location_set_accuracy (GeocodeLocation *loc,
 }
 
 static void
+geocode_location_set_crs(GeocodeLocation   *loc,
+                         GeocodeLocationCRS crs)
+{
+        g_return_if_fail (GEOCODE_IS_LOCATION (loc));
+
+        loc->priv->crs = crs;
+}
+
+static void
 geocode_location_set_property(GObject      *object,
                               guint         property_id,
                               const GValue *value,
@@ -171,6 +189,11 @@ geocode_location_set_property(GObject      *object,
                                                 g_value_get_double (value));
                 break;
 
+        case PROP_CRS:
+                geocode_location_set_crs (location,
+                                          g_value_get_enum (value));
+                break;
+
         default:
                 /* We don't have any other property... */
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -273,6 +296,23 @@ geocode_location_class_init (GeocodeLocationClass *klass)
                                      G_PARAM_STATIC_STRINGS);
         g_object_class_install_property (glocation_class, PROP_ACCURACY, pspec);
 
+
+        /**
+         * GeocodeLocation:crs:
+         *
+         * The Coordinate Reference System Identification of this location.
+         * Only the value 'wgs84' is currently valid.
+         */
+        pspec = g_param_spec_enum ("crs",
+                                   "Coordinate Reference System Identification",
+                                   "Coordinate Reference System Identification",
+                                   GEOCODE_TYPE_LOCATION_CRS,
+                                   GEOCODE_LOCATION_CRS_WGS84,
+                                   G_PARAM_READWRITE |
+                                   G_PARAM_CONSTRUCT_ONLY |
+                                   G_PARAM_STATIC_STRINGS);
+        g_object_class_install_property (glocation_class, PROP_CRS, pspec);
+
         /**
          * GeocodeLocation:timestamp:
          *
@@ -303,6 +343,7 @@ geocode_location_init (GeocodeLocation *location)
         g_get_current_time (&tv);
         location->priv->timestamp = tv.tv_sec;
         location->priv->altitude = GEOCODE_LOCATION_ALTITUDE_UNKNOWN;
+        location->priv->crs = GEOCODE_LOCATION_CRS_WGS84;
 }
 
 /**
@@ -452,6 +493,23 @@ geocode_location_get_accuracy (GeocodeLocation *loc)
 }
 
 /**
+ * geocode_location_get_crs:
+ * @loc: a #GeocodeLocation
+ *
+ * Gets the Coordinate Reference System Identification of location @loc.
+ *
+ * Returns: The CRS of location @loc.
+ **/
+GeocodeLocationCRS
+geocode_location_get_crs (GeocodeLocation *loc)
+{
+        g_return_val_if_fail (GEOCODE_IS_LOCATION (loc),
+                              GEOCODE_LOCATION_CRS_WGS84);
+
+        return loc->priv->crs;
+}
+
+/**
  * geocode_location_get_timestamp:
  * @loc: a #GeocodeLocation
  *
diff --git a/geocode-glib/geocode-location.h b/geocode-glib/geocode-location.h
index 18b9b11..c7ab25c 100644
--- a/geocode-glib/geocode-location.h
+++ b/geocode-glib/geocode-location.h
@@ -63,6 +63,16 @@ struct _GeocodeLocationClass {
 };
 
 /**
+ * GeocodeLocationCRS:
+ * @GEOCODE_LOCATION_CRS_WGS84: CRS is World Geodetic System, standard for Earth.
+ *
+ * Coordinate Reference System Identification for a location.
+ */
+typedef enum {
+       GEOCODE_LOCATION_CRS_WGS84 = 0
+} GeocodeLocationCRS;
+
+/**
  * GEOCODE_LOCATION_ALTITUDE_UNKNOWN:
  *
  * Constant representing unknown altitude.
@@ -133,6 +143,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);
+GeocodeLocationCRS  geocode_location_get_crs           (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]