]> err.no Git - libchamplain/commitdiff
Add Id to ChamplainMapSource
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Tue, 5 May 2009 00:08:02 +0000 (20:08 -0400)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Tue, 5 May 2009 00:08:02 +0000 (20:08 -0400)
champlain/champlain-map-source-factory.c
champlain/champlain-map-source.c
champlain/champlain-map-source.h
champlain/champlain-network-map-source.c
champlain/champlain-network-map-source.h

index fb93b4f3449a8c09cfb176cb1eeb37869a6d5ae2..5b5271b67ee64e0ac8ec44ff69b7f7270ccfc06a 100644 (file)
@@ -306,6 +306,7 @@ static ChamplainMapSource *
 champlain_map_source_new_osm_cyclemap (void)
 {
   return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_new_full (CHAMPLAIN_MAP_SOURCE_OSM_CYCLE_MAP,
+      "OpenStreetMap Cycle Map",
       "(CC) BY 2.0 OpenStreetMap contributors",
       "http://creativecommons.org/licenses/by/2.0/", 0, 18, 256,
       CHAMPLAIN_MAP_PROJECTION_MERCATOR,
@@ -316,6 +317,7 @@ static ChamplainMapSource *
 champlain_map_source_new_osm_osmarender (void)
 {
   return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_new_full (CHAMPLAIN_MAP_SOURCE_OSM_OSMARENDER,
+      "OpenStreetMap Osmarender",
       "(CC) BY 2.0 OpenStreetMap contributors",
       "http://creativecommons.org/licenses/by/2.0/", 0, 18, 256,
       CHAMPLAIN_MAP_PROJECTION_MERCATOR,
@@ -325,7 +327,8 @@ champlain_map_source_new_osm_osmarender (void)
 static ChamplainMapSource *
 champlain_map_source_new_osm_mapnik (void)
 {
-  return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_new_full ("OpenStreetMap Mapnik",
+  return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_new_full (CHAMPLAIN_MAP_SOURCE_OSM_MAPNIK,
+      "OpenStreetMap Mapnik",
       "(CC) BY 2.0 OpenStreetMap contributors",
       "http://creativecommons.org/licenses/by/2.0/", 0, 18, 256,
       CHAMPLAIN_MAP_PROJECTION_MERCATOR,
@@ -336,6 +339,7 @@ static ChamplainMapSource *
 champlain_map_source_new_oam (void)
 {
   return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_new_full (CHAMPLAIN_MAP_SOURCE_OAM,
+      "OpenAerialMap",
       "(CC) BY 3.0 OpenAerialMap contributors",
       "http://creativecommons.org/licenses/by/3.0/", 0, 17, 256,
       CHAMPLAIN_MAP_PROJECTION_MERCATOR,
@@ -346,6 +350,7 @@ static ChamplainMapSource *
 champlain_map_source_new_mff_relief (void)
 {
   return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_new_full (CHAMPLAIN_MAP_SOURCE_MFF_RELIEF,
+      "Maps for Free Relief",
       "Map data available under GNU Free Documentation license, Version 1.2 or later",
       "http://www.gnu.org/copyleft/fdl.html", 0, 11, 256,
       CHAMPLAIN_MAP_PROJECTION_MERCATOR,
index ef9765b1067d63cae1c83bfa8e31d23038ff0e25..1b89fbb18cecb3ad1efb8fd10b4266daa1a7f7dd 100644 (file)
@@ -60,6 +60,7 @@ enum
 enum
 {
   PROP_0,
+  PROP_ID,
   PROP_NAME,
   PROP_LICENSE,
   PROP_LICENSE_URI,
@@ -77,6 +78,7 @@ G_DEFINE_TYPE (ChamplainMapSource, champlain_map_source, G_TYPE_OBJECT);
 
 struct _ChamplainMapSourcePrivate
 {
+  gchar *id;
   gchar *name;
   gchar *license;
   gchar *license_uri;
@@ -97,6 +99,9 @@ champlain_map_source_get_property (GObject *object,
 
   switch(prop_id)
     {
+      case PROP_ID:
+        g_value_set_string (value, priv->id);
+        break;
       case PROP_NAME:
         g_value_set_string (value, priv->name);
         break;
@@ -134,6 +139,9 @@ champlain_map_source_set_property (GObject *object,
 
   switch(prop_id)
     {
+      case PROP_ID:
+        champlain_map_source_set_id (map_source,
+            g_value_get_string (value));
       case PROP_NAME:
         champlain_map_source_set_name (map_source,
             g_value_get_string (value));
@@ -187,6 +195,20 @@ champlain_map_source_class_init (ChamplainMapSourceClass *klass)
 
   klass->fill_tile = champlain_map_source_real_fill_tile;
 
+  /**
+  * ChamplainMapSource:id:
+  *
+  * The name of the map source
+  *
+  * Since: 0.4
+  */
+  pspec = g_param_spec_string ("id",
+                               "Id",
+                               "The id of the map source",
+                               "",
+                               (G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+  g_object_class_install_property (object_class, PROP_ID, pspec);
+
   /**
   * ChamplainMapSource:name:
   *
@@ -638,3 +660,38 @@ champlain_map_source_set_projection (ChamplainMapSource *map_source,
   g_object_notify (G_OBJECT (map_source), "projection");
 }
 
+/**
+ * champlain_map_source_get_id:
+ * @map_source: a #ChamplainMapSource
+ *
+ * Returns the map source's id.
+ *
+ * Since: 0.4
+ */
+const gchar *
+champlain_map_source_get_id (ChamplainMapSource *map_source)
+{
+  ChamplainMapSourcePrivate *priv = map_source->priv;
+  return priv->id;
+}
+
+/**
+ * champlain_map_source_set_id:
+ * @map_source: a #ChamplainMapSource
+ * @id: a id
+ *
+ * Sets the map source's id.
+ *
+ * Since: 0.4
+ */
+void
+champlain_map_source_set_id (ChamplainMapSource *map_source,
+    const gchar *id)
+{
+  ChamplainMapSourcePrivate *priv = map_source->priv;
+
+  g_free (priv->id);
+  priv->id = g_strdup (id);
+  g_object_notify (G_OBJECT (map_source), "id");
+}
+
index 8c821164908f1a4813f72f000133e93ea09450e5..3845926b87707fad0402159a6f9cde0779f047c4 100644 (file)
@@ -94,6 +94,10 @@ guint champlain_map_source_get_column_count (ChamplainMapSource *map_source,
 void champlain_map_source_fill_tile (ChamplainMapSource *map_source,
     ChamplainTile *tile);
 
+void champlain_map_source_set_id (ChamplainMapSource *map_source,
+    const gchar *id);
+const gchar * champlain_map_source_get_id (ChamplainMapSource *map_source);
+
 void champlain_map_source_set_name (ChamplainMapSource *map_source,
     const gchar *name);
 const gchar * champlain_map_source_get_name (ChamplainMapSource *map_source);
index 017d08854a0d177fdcc3a6deb68fb9679df6cd5a..3e1c7ea12adde886410d38ce700e36b6edc81bf6 100644 (file)
@@ -246,7 +246,8 @@ champlain_network_map_source_init (ChamplainNetworkMapSource *champlainMapSource
  * Since: 0.4
  */
 ChamplainNetworkMapSource*
-champlain_network_map_source_new_full (const gchar *name,
+champlain_network_map_source_new_full (const gchar *id,
+    const gchar *name,
     const gchar *license,
     const gchar *license_uri,
     guint min_zoom,
@@ -256,8 +257,8 @@ champlain_network_map_source_new_full (const gchar *name,
     const gchar *uri_format)
 {
   ChamplainNetworkMapSource * source;
-  source = g_object_new (CHAMPLAIN_TYPE_NETWORK_MAP_SOURCE, "name", name,
-      "license", license, "license-uri", license_uri,
+  source = g_object_new (CHAMPLAIN_TYPE_NETWORK_MAP_SOURCE, "id", id,
+      "name", name, "license", license, "license-uri", license_uri,
       "min-zoom-level", min_zoom, "max-zoom-level", max_zoom,
       "tile-size", tile_size, "projection", projection,
       "uri-format", uri_format, NULL);
index f7a4fdfb1ba16416ddb1e5d2ab0ff3fb6df6367b..4baadae0a1e18058a41da3a2453dee1a498c843e 100644 (file)
@@ -54,10 +54,15 @@ struct _ChamplainNetworkMapSourceClass
 
 GType champlain_network_map_source_get_type (void);
 
-ChamplainNetworkMapSource* champlain_network_map_source_new_full (
-    const gchar *name, const gchar *license, const gchar *license_uri,
-    guint min_zoom, guint max_zoom, guint tile_size,
-    ChamplainMapProjection projection, const gchar *uri_format);
+ChamplainNetworkMapSource* champlain_network_map_source_new_full (const gchar *id,
+    const gchar *name,
+    const gchar *license,
+    const gchar *license_uri,
+    guint min_zoom,
+    guint max_zoom,
+    guint tile_size,
+    ChamplainMapProjection projection,
+    const gchar *uri_format);
 
 gchar * champlain_network_map_source_get_tile_uri (ChamplainNetworkMapSource *source,
     gint x,