[grits] Switch map plugin to tile map service
- From: Andy Spencer <andys src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grits] Switch map plugin to tile map service
- Date: Thu, 16 Feb 2012 23:17:09 +0000 (UTC)
commit 6374cf1c67a158f9703918d404f53d824a6d2a68
Author: Andy Spencer <andy753421 gmail com>
Date: Sat Jan 21 04:16:29 2012 +0000
Switch map plugin to tile map service
src/Makefile.am | 2 +-
src/grits-test.c | 6 ++--
src/plugins/map.c | 54 +++++++++++++++++++++++++++++-----------------------
3 files changed, 34 insertions(+), 28 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index eea8216..b5f8892 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -92,7 +92,7 @@ test: all
./grits-test
gdb: all
- gdb ./grits-test
+ gdb ./.libs/grits-test
ddd: all
ddd ./grits-test
diff --git a/src/grits-test.c b/src/grits-test.c
index c2f4195..54251ba 100644
--- a/src/grits-test.c
+++ b/src/grits-test.c
@@ -91,11 +91,11 @@ int main(int argc, char **argv)
(void)load_plugin;
load_plugin(plugins, "env", viewer, prefs, GTK_NOTEBOOK(config));
//load_plugin(plugins, "elev", viewer, prefs, GTK_NOTEBOOK(config));
- load_plugin(plugins, "sat", viewer, prefs, GTK_NOTEBOOK(config));
- //load_plugin(plugins, "map", viewer, prefs, GTK_NOTEBOOK(config));
+ //load_plugin(plugins, "sat", viewer, prefs, GTK_NOTEBOOK(config));
+ load_plugin(plugins, "map", viewer, prefs, GTK_NOTEBOOK(config));
//load_plugin(plugins, "alert", viewer, prefs, GTK_NOTEBOOK(config));
//load_plugin(plugins, "radar", viewer, prefs, GTK_NOTEBOOK(config));
- load_plugin(plugins, "test", viewer, prefs, GTK_NOTEBOOK(config));
+ //load_plugin(plugins, "test", viewer, prefs, GTK_NOTEBOOK(config));
gtk_widget_show_all(config);
gtk_main();
diff --git a/src/plugins/map.c b/src/plugins/map.c
index aa4d0f2..d129767 100644
--- a/src/plugins/map.c
+++ b/src/plugins/map.c
@@ -30,16 +30,19 @@
#include "map.h"
-#define MAX_RESOLUTION 100
-#define TILE_WIDTH 1024
-#define TILE_HEIGHT 512
+#define MAX_RESOLUTION 1
+#define TILE_WIDTH 256
+#define TILE_HEIGHT 256
+//#define MAX_RESOLUTION 100
+//#define TILE_WIDTH 1024
+//#define TILE_HEIGHT 512
static const guchar colormap[][2][4] = {
- {{0x73, 0x91, 0xad}, {0x73, 0x91, 0xad, 0x00}}, // Oceans
- {{0xf6, 0xee, 0xee}, {0xf6, 0xee, 0xee, 0x00}}, // Ground
- {{0xff, 0xff, 0xff}, {0xff, 0xff, 0xff, 0xff}}, // Borders
- {{0x73, 0x93, 0xad}, {0x73, 0x93, 0xad, 0x40}}, // Lakes
- {{0xff, 0xe1, 0x80}, {0xff, 0xe1, 0x80, 0x60}}, // Cities
+ //{{0x73, 0x91, 0xad}, {0x73, 0x91, 0xad, 0x00}}, // Oceans
+ //{{0xf6, 0xee, 0xee}, {0xf6, 0xee, 0xee, 0x00}}, // Ground
+ //{{0xff, 0xff, 0xff}, {0xff, 0xff, 0xff, 0xff}}, // Borders
+ //{{0x73, 0x93, 0xad}, {0x73, 0x93, 0xad, 0x40}}, // Lakes
+ //{{0xff, 0xe1, 0x80}, {0xff, 0xe1, 0x80, 0x60}}, // Cities
};
struct _LoadTileData {
@@ -86,8 +89,8 @@ static void _load_tile(GritsTile *tile, gpointer _map)
}
/* Download tile */
- //gchar *path = grits_tms_fetch(map->tms, tile, GRITS_ONCE, NULL, NULL);
- gchar *path = grits_wms_fetch(map->wms, tile, GRITS_ONCE, NULL, NULL);
+ gchar *path = grits_tms_fetch(map->tms, tile, GRITS_ONCE, NULL, NULL);
+ //gchar *path = grits_wms_fetch(map->wms, tile, GRITS_ONCE, NULL, NULL);
if (!path) return; // Canceled/error
/* Load pixbuf */
@@ -140,9 +143,10 @@ static gboolean _free_tile_cb(gpointer data)
}
static void _free_tile(GritsTile *tile, gpointer _map)
{
- g_debug("GritsPluginMap: _free_tile: %p", tile->data);
- if (tile->data)
+ if (tile->data) {
+ g_debug("GritsPluginMap: _free_tile: %p", tile->data);
g_idle_add_full(G_PRIORITY_LOW, _free_tile_cb, tile->data, NULL);
+ }
}
static void _update_tiles(gpointer _, gpointer _map)
@@ -193,7 +197,7 @@ GritsPluginMap *grits_plugin_map_new(GritsViewer *viewer)
G_CALLBACK(_on_location_changed), map);
/* Add renderers */
- grits_viewer_add(viewer, GRITS_OBJECT(map->tiles), GRITS_LEVEL_OVERLAY-1, 0);
+ grits_viewer_add(viewer, GRITS_OBJECT(map->tiles), GRITS_LEVEL_WORLD, FALSE);
return map;
}
@@ -218,14 +222,15 @@ static void grits_plugin_map_init(GritsPluginMap *map)
g_debug("GritsPluginMap: init");
/* Set defaults */
map->threads = g_thread_pool_new(_update_tiles, map, 1, FALSE, NULL);
- //map->tiles = grits_tile_new(NULL, 85.0511, -85.0511, EAST, WEST);
- //map->wms = grits_tms_new("http://tile.openstreetmap.org",
- // "osm/", "png");
- map->tiles = grits_tile_new(NULL, NORTH, SOUTH, EAST, WEST);
- map->wms = grits_wms_new(
- "http://vmap0.tiles.osgeo.org/wms/vmap0",
- "basic,priroad,secroad,depthcontour,clabel,statelabel",
- "image/png", "osm/", "png", TILE_WIDTH, TILE_HEIGHT);
+ map->tiles = grits_tile_new(NULL, 85.0511, -85.0511, EAST, WEST);
+ map->tms = grits_tms_new("http://tile.openstreetmap.org",
+ "osmtile/", "png");
+ map->tiles->proj = GRITS_PROJ_MERCATOR;
+ //map->tiles = grits_tile_new(NULL, NORTH, SOUTH, EAST, WEST);
+ //map->wms = grits_wms_new(
+ // "http://vmap0.tiles.osgeo.org/wms/vmap0",
+ // "basic,priroad,secroad,depthcontour,clabel,statelabel",
+ // "image/png", "osm/", "png", TILE_WIDTH, TILE_HEIGHT);
g_object_ref(map->tiles);
}
static void grits_plugin_map_dispose(GObject *gobject)
@@ -237,7 +242,8 @@ static void grits_plugin_map_dispose(GObject *gobject)
if (map->viewer) {
g_signal_handler_disconnect(map->viewer, map->sigid);
grits_viewer_remove(map->viewer, GRITS_OBJECT(map->tiles));
- soup_session_abort(map->wms->http->soup);
+ soup_session_abort(map->tms->http->soup);
+ //soup_session_abort(map->wms->http->soup);
g_thread_pool_free(map->threads, TRUE, TRUE);
while (gtk_events_pending())
gtk_main_iteration();
@@ -251,8 +257,8 @@ static void grits_plugin_map_finalize(GObject *gobject)
g_debug("GritsPluginMap: finalize");
GritsPluginMap *map = GRITS_PLUGIN_MAP(gobject);
/* Free data */
- //grits_wms_free(map->tms);
- grits_wms_free(map->wms);
+ grits_tms_free(map->tms);
+ //grits_wms_free(map->wms);
grits_tile_free(map->tiles, _free_tile, map);
G_OBJECT_CLASS(grits_plugin_map_parent_class)->finalize(gobject);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]