[libchamplain] Add the interfaces of ChamplainMapDataSource and ChamplainMemphisMapSource



commit 43527bbf5cdc42ec5344fd37dc156865bc363e25
Author: Simon Wenner <simon wenner ch>
Date:   Fri Jun 19 16:28:08 2009 +0200

    Add the interfaces of ChamplainMapDataSource and ChamplainMemphisMapSource

 champlain/Makefile.am                    |   11 ++
 champlain/champlain-map-data-source.c    |  103 +++++++++++++++++++
 champlain/champlain-map-data-source.h    |   63 ++++++++++++
 champlain/champlain-memphis-map-source.c |  159 ++++++++++++++++++++++++++++++
 champlain/champlain-memphis-map-source.h |   73 ++++++++++++++
 champlain/champlain.h                    |    4 +
 6 files changed, 413 insertions(+), 0 deletions(-)
---
diff --git a/champlain/Makefile.am b/champlain/Makefile.am
index a92062e..9374a72 100644
--- a/champlain/Makefile.am
+++ b/champlain/Makefile.am
@@ -110,6 +110,17 @@ AM_CPPFLAGS = 				\
 	-DCHAMPLAIN_COMPILATION 	\
 	$(WARN_CFLAGS)
 
+if ENABLE_MEMPHIS
+libchamplain_headers += champlain-memphis-map-source.h  \
+	champlain-map-data-source.h
+libchamplain_0_3_la_SOURCES += champlain-memphis-map-source.c  \
+	champlain-map-data-source.c
+libchamplain_include_HEADERS += champlain-memphis-map-source.h  \
+	champlain-map-data-source.h
+libchamplain_0_3_la_LIBADD += ../memphis/libmemphis-1.0.la
+AM_CPPFLAGS += -I$(top_srcdir)/memphis -DMEMPHIS_ENABLED
+endif
+
 EXTRA_DIST = $(CHAMPLAIN_MARSHAL_LIST)
 
 champlain-marshal.h: $(CHAMPLAIN_MARSHAL_LIST)
diff --git a/champlain/champlain-map-data-source.c b/champlain/champlain-map-data-source.c
new file mode 100644
index 0000000..2110142
--- /dev/null
+++ b/champlain/champlain-map-data-source.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2009 Simon Wenner <simon wenner ch>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "champlain-map-data-source.h"
+
+G_DEFINE_TYPE (ChamplainMapDataSource, champlain_map_data_source, G_TYPE_OBJECT)
+
+#define GET_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHAMPLAIN_TYPE_MAP_DATA_SOURCE, ChamplainMapDataSourcePrivate))
+
+typedef struct _ChamplainMapDataSourcePrivate ChamplainMapDataSourcePrivate;
+
+struct _ChamplainMapDataSourcePrivate {
+  MemphisMap *map_data;
+};
+
+static void
+champlain_map_data_source_get_property (GObject *object, guint property_id,
+                              GValue *value, GParamSpec *pspec)
+{
+  switch (property_id) {
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+  }
+}
+
+static void
+champlain_map_data_source_set_property (GObject *object, guint property_id,
+                              const GValue *value, GParamSpec *pspec)
+{
+  switch (property_id) {
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+  }
+}
+
+static void
+champlain_map_data_source_dispose (GObject *object)
+{
+  G_OBJECT_CLASS (champlain_map_data_source_parent_class)->dispose (object);
+}
+
+static void
+champlain_map_data_source_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (champlain_map_data_source_parent_class)->finalize (object);
+}
+
+static void
+champlain_map_data_source_real_get_map_data (ChamplainMapDataSource *data_source,
+      osmFile *map_data)
+{
+  g_error ("Should not be reached");
+}
+
+static void
+champlain_map_data_source_class_init (ChamplainMapDataSourceClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (ChamplainMapDataSourcePrivate));
+
+  object_class->get_property = champlain_map_data_source_get_property;
+  object_class->set_property = champlain_map_data_source_set_property;
+  object_class->dispose = champlain_map_data_source_dispose;
+  object_class->finalize = champlain_map_data_source_finalize;
+
+  klass->get_map_data = champlain_map_data_source_real_get_map_data;
+}
+
+static void
+champlain_map_data_source_init (ChamplainMapDataSource *self)
+{
+
+}
+
+ChamplainMapDataSource*
+champlain_map_data_source_new (void)
+{
+  return g_object_new (CHAMPLAIN_TYPE_MAP_DATA_SOURCE, NULL);
+}
+
+MemphisMap*
+champlain_map_data_get_map_data (ChamplainMapDataSource *data_source)
+{
+
+  return NULL;
+}
diff --git a/champlain/champlain-map-data-source.h b/champlain/champlain-map-data-source.h
new file mode 100644
index 0000000..a42328e
--- /dev/null
+++ b/champlain/champlain-map-data-source.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2009 Simon Wenner <simon wenner ch>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _CHAMPLAIN_MAP_DATA_SOURCE
+#define _CHAMPLAIN_MAP_DATA_SOURCE
+
+#include <glib-object.h>
+#include <memphis/memphis.h>
+
+G_BEGIN_DECLS
+
+#define CHAMPLAIN_TYPE_MAP_DATA_SOURCE champlain_map_data_source_get_type()
+
+#define CHAMPLAIN_MAP_DATA_SOURCE(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHAMPLAIN_TYPE_MAP_DATA_SOURCE, ChamplainMapDataSource))
+
+#define CHAMPLAIN_MAP_DATA_SOURCE_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), CHAMPLAIN_TYPE_MAP_DATA_SOURCE, ChamplainMapDataSourceClass))
+
+#define CHAMPLAIN_IS_MAP_DATA_SOURCE(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAMPLAIN_TYPE_MAP_DATA_SOURCE))
+
+#define CHAMPLAIN_IS_MAP_DATA_SOURCE_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), CHAMPLAIN_TYPE_MAP_DATA_SOURCE))
+
+#define CHAMPLAIN_MAP_DATA_SOURCE_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), CHAMPLAIN_TYPE_MAP_DATA_SOURCE, ChamplainMapDataSourceClass))
+
+typedef struct {
+  GObject parent;
+} ChamplainMapDataSource;
+
+typedef struct {
+  GObjectClass parent_class;
+  void (*get_map_data) (ChamplainMapDataSource *data_source,
+      osmFile *map_data);
+} ChamplainMapDataSourceClass;
+
+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);
+
+G_END_DECLS
+
+#endif /* _CHAMPLAIN_MAP_DATA_SOURCE */
diff --git a/champlain/champlain-memphis-map-source.c b/champlain/champlain-memphis-map-source.c
new file mode 100644
index 0000000..29f6d93
--- /dev/null
+++ b/champlain/champlain-memphis-map-source.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2009 Simon Wenner <simon wenner ch>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "champlain-memphis-map-source.h"
+#include "champlain.h"
+#include "champlain-debug.h"
+#include "champlain-cache.h"
+#include "champlain-defines.h"
+#include "champlain-enum-types.h"
+#include "champlain-marshal.h"
+#include "champlain-private.h"
+
+#include <clutter-cairo.h>
+#include <memphis/memphis.h>
+
+/* Tuning parameters */
+#define MAX_THREADS 4
+#define DEFAULT_TILE_SIZE 512
+
+G_DEFINE_TYPE (ChamplainMemphisMapSource, champlain_memphis_map_source, CHAMPLAIN_TYPE_MAP_SOURCE)
+
+#define GET_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHAMPLAIN_TYPE_MEMPHIS_MAP_SOURCE, ChamplainMemphisMapSourcePrivate))
+
+typedef struct _ChamplainMemphisMapSourcePrivate ChamplainMemphisMapSourcePrivate;
+
+struct _ChamplainMemphisMapSourcePrivate {
+  ChamplainMapDataSource *source;
+  MemphisMap *map; // remove me
+  MemphisRuleSet *rules;
+  MemphisRenderer *renderer;
+  GThreadPool* thpool;
+  //GStaticRWLock rwlock;
+};
+
+static void
+champlain_memphis_map_source_get_property (GObject *object, guint property_id,
+                              GValue *value, GParamSpec *pspec)
+{
+  switch (property_id) {
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+  }
+}
+
+static void
+champlain_memphis_map_source_set_property (GObject *object, guint property_id,
+                              const GValue *value, GParamSpec *pspec)
+{
+  switch (property_id) {
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+  }
+}
+
+static void
+champlain_memphis_map_source_dispose (GObject *object)
+{
+  ChamplainMemphisMapSource *self = (ChamplainMemphisMapSource *) object;
+  ChamplainMemphisMapSourcePrivate *priv = GET_PRIVATE(self);
+
+  g_thread_pool_free (priv->thpool, TRUE, TRUE);
+  memphis_renderer_free (priv->renderer);
+  memphis_map_free (priv->map);
+  memphis_rule_set_free (priv->rules);
+  
+  G_OBJECT_CLASS (champlain_memphis_map_source_parent_class)->dispose (object);
+}
+
+static void
+champlain_memphis_map_source_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (champlain_memphis_map_source_parent_class)->finalize (object);
+}
+
+static void
+fill_tile (ChamplainMapSource *map_source,
+    ChamplainTile *tile)
+{
+
+}
+
+static void
+memphis_worker_thread (gpointer data, gpointer user_data)
+{
+
+}
+
+static void
+champlain_memphis_map_source_class_init (ChamplainMemphisMapSourceClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  g_type_class_add_private (klass, sizeof (ChamplainMemphisMapSourcePrivate));
+
+  object_class->get_property = champlain_memphis_map_source_get_property;
+  object_class->set_property = champlain_memphis_map_source_set_property;
+  object_class->dispose = champlain_memphis_map_source_dispose;
+  object_class->finalize = champlain_memphis_map_source_finalize;
+
+  ChamplainMapSourceClass *map_source_class = CHAMPLAIN_MAP_SOURCE_CLASS (klass);
+  map_source_class->fill_tile = fill_tile;
+}
+
+static void
+champlain_memphis_map_source_init (ChamplainMemphisMapSource *self)
+{
+  ChamplainMemphisMapSourcePrivate *priv = GET_PRIVATE(self);
+  
+  priv->map = memphis_map_new ();
+  priv->rules = memphis_rule_set_new ();
+  priv->renderer = memphis_renderer_new_full (priv->rules, priv->map);
+  priv->thpool = g_thread_pool_new (memphis_worker_thread, priv->renderer,
+      MAX_THREADS, FALSE, NULL);
+}
+
+ChamplainMemphisMapSource*
+champlain_memphis_map_source_new_full (
+    ChamplainMapDataSource *data_source)
+{
+  return g_object_new (CHAMPLAIN_TYPE_MEMPHIS_MAP_SOURCE, NULL);
+}
+
+void
+champlain_memphis_map_source_set_tile_size (
+    ChamplainMemphisMapSource *map_source)
+{
+
+}
+
+void
+champlain_memphis_map_source_set_rules_path (
+    ChamplainMemphisMapSource *map_source,
+    gchar *path)
+{
+
+}
+
+void champlain_memphis_map_source_set_map_source (
+    ChamplainMemphisMapSource *map_source,
+    ChamplainMapDataSource *data_source)
+{
+
+}
diff --git a/champlain/champlain-memphis-map-source.h b/champlain/champlain-memphis-map-source.h
new file mode 100644
index 0000000..3d143ec
--- /dev/null
+++ b/champlain/champlain-memphis-map-source.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2009 Simon Wenner <simon wenner ch>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _CHAMPLAIN_MEMPHIS_MAP_SOURCE
+#define _CHAMPLAIN_MEMPHIS_MAP_SOURCE
+
+#include "champlain-map-data-source.h"
+#include "champlain-map-source.h"
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define CHAMPLAIN_TYPE_MEMPHIS_MAP_SOURCE champlain_memphis_map_source_get_type()
+
+#define CHAMPLAIN_MEMPHIS_MAP_SOURCE(obj) \
+  (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHAMPLAIN_TYPE_MEMPHIS_MAP_SOURCE, ChamplainMemphisMapSource))
+
+#define CHAMPLAIN_MEMPHIS_MAP_SOURCE_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_CAST ((klass), CHAMPLAIN_TYPE_MEMPHIS_MAP_SOURCE, ChamplainMemphisMapSourceClass))
+
+#define CHAMPLAIN_IS_MEMPHIS_MAP_SOURCE(obj) \
+  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHAMPLAIN_TYPE_MEMPHIS_MAP_SOURCE))
+
+#define CHAMPLAIN_IS_MEMPHIS_MAP_SOURCE_CLASS(klass) \
+  (G_TYPE_CHECK_CLASS_TYPE ((klass), CHAMPLAIN_TYPE_MEMPHIS_MAP_SOURCE))
+
+#define CHAMPLAIN_MEMPHIS_MAP_SOURCE_GET_CLASS(obj) \
+  (G_TYPE_INSTANCE_GET_CLASS ((obj), CHAMPLAIN_TYPE_MEMPHIS_MAP_SOURCE, ChamplainMemphisMapSourceClass))
+
+typedef struct {
+  ChamplainMapSource parent;
+} ChamplainMemphisMapSource;
+
+typedef struct {
+  ChamplainMapSourceClass parent_class;
+} ChamplainMemphisMapSourceClass;
+
+GType champlain_memphis_map_source_get_type (void);
+
+ChamplainMemphisMapSource* champlain_memphis_map_source_new_full (
+    ChamplainMapDataSource *data_source);
+
+void champlain_memphis_map_source_set_tile_size (
+    ChamplainMemphisMapSource *map_source);
+
+void champlain_memphis_map_source_set_rules_path (
+    ChamplainMemphisMapSource *map_source,
+    gchar *path);
+
+void champlain_memphis_map_source_set_map_source (
+    ChamplainMemphisMapSource *map_source,
+    ChamplainMapDataSource *data_source);
+
+
+G_END_DECLS
+
+#endif /* _CHAMPLAIN_MEMPHIS_MAP_SOURCE */
diff --git a/champlain/champlain.h b/champlain/champlain.h
index 241ff84..dc34633 100644
--- a/champlain/champlain.h
+++ b/champlain/champlain.h
@@ -41,6 +41,10 @@
 #include "champlain/champlain-map-source-factory.h"
 #include "champlain/champlain-network-map-source.h"
 #include "champlain/champlain-version.h"
+#ifdef MEMPHIS_ENABLED
+#include "champlain/champlain-memphis-map-source.h"
+#include "champlain/champlain-map-data-source.h"
+#endif
 
 #undef __CHAMPLAIN_CHAMPLAIN_H_INSIDE__
 



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