[libchamplain] Add champlain_map_data_source_get_* functions



commit 966b2f25cac029c4ee951e24c5646ce10b6ad37f
Author: Simon Wenner <simon wenner ch>
Date:   Sat Jun 20 16:11:37 2009 +0200

    Add champlain_map_data_source_get_* functions

 champlain/champlain-map-data-source.c    |   83 +++++++++++++++++++++++++----
 champlain/champlain-map-data-source.h    |   11 +++-
 champlain/champlain-memphis-map-source.c |   18 +++---
 3 files changed, 89 insertions(+), 23 deletions(-)
---
diff --git a/champlain/champlain-map-data-source.c b/champlain/champlain-map-data-source.c
index d7406ba..75d0bb4 100644
--- a/champlain/champlain-map-data-source.c
+++ b/champlain/champlain-map-data-source.c
@@ -26,13 +26,19 @@ G_DEFINE_TYPE (ChamplainMapDataSource, champlain_map_data_source, G_TYPE_OBJECT)
 enum
 {
   PROP_0,
-  PROP_MAP_DATA
+  PROP_ID
+  // TODO
 };
 
 typedef struct _ChamplainMapDataSourcePrivate ChamplainMapDataSourcePrivate;
 
 struct _ChamplainMapDataSourcePrivate {
-  MemphisMap *map_data;
+  const char *id;
+  const char *name;
+  const char *license;
+  const char *license_uri;
+  guint min_zoom_level;
+  guint max_zoom_level;
 };
 
 static void
@@ -58,11 +64,8 @@ champlain_map_data_source_set_property (GObject *object, guint property_id,
 static void
 champlain_map_data_source_dispose (GObject *object)
 {
-  ChamplainMapDataSource *self = (ChamplainMapDataSource *) object;
-  ChamplainMapDataSourcePrivate *priv =  GET_PRIVATE(self);
-
-  if (priv->map_data)
-    memphis_map_free (priv->map_data);
+  //ChamplainMapDataSource *self = (ChamplainMapDataSource *) object;
+  //ChamplainMapDataSourcePrivate *priv =  GET_PRIVATE(self);
 
   G_OBJECT_CLASS (champlain_map_data_source_parent_class)->dispose (object);
 }
@@ -99,7 +102,12 @@ champlain_map_data_source_init (ChamplainMapDataSource *self)
 {
   ChamplainMapDataSourcePrivate *priv =  GET_PRIVATE(self);
 
-  priv->map_data = NULL;
+  priv->id = NULL;
+  priv->name = NULL;
+  priv->license = NULL;
+  priv->license_uri = NULL;
+  priv->min_zoom_level = 12;
+  priv->max_zoom_level = 18;
 }
 
 ChamplainMapDataSource*
@@ -109,12 +117,63 @@ champlain_map_data_source_new (void)
 }
 
 MemphisMap*
-champlain_map_data_get_map_data (ChamplainMapDataSource *self)
+champlain_map_data_source_get_map_data (ChamplainMapDataSource *self)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MAP_DATA_SOURCE (self), NULL);
+
+  return CHAMPLAIN_MAP_DATA_SOURCE_GET_CLASS (self)->get_map_data (self);
+}
+
+const gchar*
+champlain_map_data_source_get_id (ChamplainMapDataSource *self)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MAP_DATA_SOURCE (self), NULL);
+
+  ChamplainMapDataSourcePrivate *priv =  GET_PRIVATE(self);
+  return priv->id;
+}
+
+const gchar*
+champlain_map_data_source_get_name (ChamplainMapDataSource *self)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MAP_DATA_SOURCE (self), NULL);
+
+  ChamplainMapDataSourcePrivate *priv =  GET_PRIVATE(self);
+  return priv->name;
+}
+
+const gchar*
+champlain_map_data_source_get_license (ChamplainMapDataSource *self)
 {
+  g_return_val_if_fail (CHAMPLAIN_IS_MAP_DATA_SOURCE (self), NULL);
+
   ChamplainMapDataSourcePrivate *priv =  GET_PRIVATE(self);
+  return priv->license;
+}
+
+const gchar*
+champlain_map_data_source_get_license_uri (ChamplainMapDataSource *self)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MAP_DATA_SOURCE (self), NULL);
 
-  priv->map_data = CHAMPLAIN_MAP_DATA_SOURCE_GET_CLASS (self)
-      ->get_map_data (self);
+  ChamplainMapDataSourcePrivate *priv =  GET_PRIVATE(self);
+  return priv->license_uri;
+}
 
-  return priv->map_data;
+guint
+champlain_map_data_source_get_min_zoom_level (ChamplainMapDataSource *self)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MAP_DATA_SOURCE (self), 0);
+
+  ChamplainMapDataSourcePrivate *priv =  GET_PRIVATE(self);
+  return priv->min_zoom_level;
+}
+
+guint
+champlain_map_data_source_get_max_zoom_level (ChamplainMapDataSource *self)
+{
+  g_return_val_if_fail (CHAMPLAIN_IS_MAP_DATA_SOURCE (self), 0);
+
+  ChamplainMapDataSourcePrivate *priv =  GET_PRIVATE(self);
+  return priv->max_zoom_level;
 }
diff --git a/champlain/champlain-map-data-source.h b/champlain/champlain-map-data-source.h
index d9ea232..19eccd6 100644
--- a/champlain/champlain-map-data-source.h
+++ b/champlain/champlain-map-data-source.h
@@ -54,8 +54,15 @@ GType champlain_map_data_source_get_type (void);
 
 ChamplainMapDataSource* champlain_map_data_source_new (void);
 
-MemphisMap* champlain_map_data_get_map_data (
-    ChamplainMapDataSource *data_source);
+MemphisMap* champlain_map_data_source_get_map_data (ChamplainMapDataSource *data_source);
+
+const gchar * champlain_map_data_source_get_id (ChamplainMapDataSource *data_source);
+const gchar * champlain_map_data_source_get_name (ChamplainMapDataSource *data_source);
+const gchar * champlain_map_data_source_get_license (ChamplainMapDataSource *data_source);
+const gchar * champlain_map_data_source_get_license_uri (ChamplainMapDataSource *data_source);
+
+guint champlain_map_data_source_get_min_zoom_level (ChamplainMapDataSource *data_source);
+guint champlain_map_data_source_get_max_zoom_level (ChamplainMapDataSource *data_source);
 
 G_END_DECLS
 
diff --git a/champlain/champlain-memphis-map-source.c b/champlain/champlain-memphis-map-source.c
index b9a6372..07326e3 100644
--- a/champlain/champlain-memphis-map-source.c
+++ b/champlain/champlain-memphis-map-source.c
@@ -213,20 +213,20 @@ champlain_memphis_map_source_new_full (ChamplainMapDataSource *data_source)
   MemphisMap *map;
 
   source = g_object_new (CHAMPLAIN_TYPE_MEMPHIS_MAP_SOURCE,
-      //"id", id,
-      //"name", name,
-      //"license", license,
-      //"license-uri", license_uri,
-      //"projection", projection,
-      "min-zoom-level", 12, // TODO: read from data source
-      "max-zoom-level", 18, // TODO: read from data source
+      "id", champlain_map_data_source_get_id (data_source),
+      "name", champlain_map_data_source_get_name (data_source),
+      "license", champlain_map_data_source_get_license (data_source),
+      "license-uri", champlain_map_data_source_get_license_uri (data_source),
+      "projection", CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+      "min-zoom-level", champlain_map_data_source_get_min_zoom_level (data_source),
+      "max-zoom-level", champlain_map_data_source_get_max_zoom_level (data_source),
       "tile-size", DEFAULT_TILE_SIZE,
       NULL);
 
   priv = GET_PRIVATE(source);
   priv->data_source = g_object_ref (data_source);
 
-  map = champlain_map_data_get_map_data (priv->data_source);
+  map = champlain_map_data_source_get_map_data (priv->data_source);
 
   priv->rules = memphis_rule_set_new ();
   //memphis_rule_set_load_from_file (priv->rules, DEFAULT_RULES_PATH);
@@ -277,6 +277,6 @@ void champlain_memphis_map_source_set_map_source (
 
   priv->data_source = data_source;
 
-  map = champlain_map_data_get_map_data (priv->data_source);
+  map = champlain_map_data_source_get_map_data (priv->data_source);
   memphis_renderer_set_map (priv->renderer, map);
 }



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