[geocode-glib] place: Add osm-id property



commit bb25e20e55d27f438d0eae7e393515004aa764c2
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Fri Mar 14 20:19:40 2014 +0100

    place: Add osm-id property
    
    We can end up with places that have the same name when we search
    using geocode-forward. It would help to be able to keep them apart.
    Having the OpenStreetMap id as a property will also make it possible
    to reference the place to OpenStreetMap dbs for editing purpopses.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=726367

 geocode-glib/geocode-forward.c    |    2 +-
 geocode-glib/geocode-glib.symbols |    1 +
 geocode-glib/geocode-place.c      |   45 ++++++++++++++++++++++++++++++++++++-
 geocode-glib/geocode-place.h      |    2 +
 4 files changed, 48 insertions(+), 2 deletions(-)
---
diff --git a/geocode-glib/geocode-forward.c b/geocode-glib/geocode-forward.c
index 1439af3..ad2f975 100644
--- a/geocode-glib/geocode-forward.c
+++ b/geocode-glib/geocode-forward.c
@@ -603,7 +603,7 @@ static struct {
 } nominatim_to_place_map[] = {
         { "license", NULL },
         { "osm_type", NULL },
-        { "osm_id", NULL },
+        { "osm_id", "osm-id" },
         { "lat", NULL },
         { "lon", NULL },
         { "display_name", NULL },
diff --git a/geocode-glib/geocode-glib.symbols b/geocode-glib/geocode-glib.symbols
index b9265de..8664ac1 100644
--- a/geocode-glib/geocode-glib.symbols
+++ b/geocode-glib/geocode-glib.symbols
@@ -73,6 +73,7 @@ geocode_place_get_continent
 geocode_place_get_icon
 geocode_place_get_bounding_box
 geocode_place_set_bounding_box
+geocode_place_get_osm_id
 geocode_bounding_box_get_type
 geocode_bounding_box_new
 geocode_bounding_box_get_top
diff --git a/geocode-glib/geocode-place.c b/geocode-glib/geocode-place.c
index 4a7f2de..9e39242 100644
--- a/geocode-glib/geocode-place.c
+++ b/geocode-glib/geocode-place.c
@@ -56,6 +56,7 @@ struct _GeocodePlacePrivate {
         char *country_code;
         char *country;
         char *continent;
+        char *osm_id;
 };
 
 enum {
@@ -77,7 +78,8 @@ enum {
         PROP_COUNTRY,
         PROP_CONTINENT,
         PROP_ICON,
-        PROP_BBOX
+        PROP_BBOX,
+        PROP_OSM_ID
 };
 
 G_DEFINE_TYPE (GeocodePlace, geocode_place, G_TYPE_OBJECT)
@@ -176,6 +178,11 @@ geocode_place_get_property (GObject    *object,
                                     geocode_place_get_bounding_box (place));
                 break;
 
+        case PROP_OSM_ID:
+                g_value_set_string (value,
+                                    geocode_place_get_osm_id (place));
+                break;
+
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                 break;
@@ -260,6 +267,10 @@ geocode_place_set_property(GObject      *object,
                 place->priv->bbox = g_value_dup_object (value);
                 break;
 
+        case PROP_OSM_ID:
+                place->priv->osm_id = g_value_dup_string (value);
+                break;
+
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                 break;
@@ -275,6 +286,7 @@ geocode_place_dispose (GObject *gplace)
         g_clear_object (&place->priv->bbox);
 
         g_clear_pointer (&place->priv->name, g_free);
+        g_clear_pointer (&place->priv->osm_id, g_free);
         g_clear_pointer (&place->priv->street_address, g_free);
         g_clear_pointer (&place->priv->street, g_free);
         g_clear_pointer (&place->priv->building, g_free);
@@ -525,6 +537,20 @@ geocode_place_class_init (GeocodePlaceClass *klass)
                                      G_PARAM_READWRITE |
                                      G_PARAM_STATIC_STRINGS);
         g_object_class_install_property (gplace_class, PROP_BBOX, pspec);
+
+        /**
+         * GeocodePlace:osm-id:
+         *
+         * The OpenStreetMap id of the place.
+         */
+        pspec = g_param_spec_string ("osm-id",
+                                     "OSM ID",
+                                     "The OpenStreetMap ID of the place",
+                                     NULL,
+                                     G_PARAM_READWRITE |
+                                     G_PARAM_STATIC_STRINGS);
+        g_object_class_install_property (gplace_class, PROP_OSM_ID, pspec);
+
 }
 
 static void
@@ -609,6 +635,7 @@ geocode_place_get_name (GeocodePlace *place)
         g_return_val_if_fail (GEOCODE_IS_PLACE (place), NULL);
 
         return place->priv->name;
+
 }
 
 /**
@@ -1164,3 +1191,19 @@ geocode_place_set_bounding_box (GeocodePlace       *place,
         g_clear_object (&place->priv->bbox);
         place->priv->bbox = g_object_ref (bbox);
 }
+
+/**
+ * geocode_place_get_osm_id:
+ * @place: A place
+ *
+ * Gets the OpenStreetMap ID of the @place.
+ *
+ * Returns: The osm ID of the @place.
+ **/
+const char *
+geocode_place_get_osm_id (GeocodePlace *place)
+{
+        g_return_val_if_fail (GEOCODE_IS_PLACE (place), NULL);
+
+        return place->priv->osm_id;
+}
diff --git a/geocode-glib/geocode-place.h b/geocode-glib/geocode-place.h
index 525f57c..9a06471 100644
--- a/geocode-glib/geocode-place.h
+++ b/geocode-glib/geocode-place.h
@@ -206,6 +206,8 @@ const char *geocode_place_get_continent            (GeocodePlace *place);
 
 GIcon *geocode_place_get_icon                      (GeocodePlace *place);
 
+const char *geocode_place_get_osm_id               (GeocodePlace *place);
+
 G_END_DECLS
 
 #endif /* GEOCODE_PLACE_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]