]> Pileus Git - grits/blobdiff - src/plugins/map.c
Add Tile Map Service downloading
[grits] / src / plugins / map.c
index 7505d45ade93dd53a32fe6d8a6f9faf6bf33278d..aa4d0f27d51d3454e1ae9acdb97de45af94babab 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
+ * Copyright (C) 2009-2011 Andy Spencer <andy753421@gmail.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,7 +25,6 @@
 
 #include <time.h>
 #include <glib/gstdio.h>
-#include <GL/gl.h>
 
 #include <grits.h>
 
@@ -36,7 +35,7 @@
 #define TILE_HEIGHT    512
 
 static const guchar colormap[][2][4] = {
-       {{0x73, 0x91, 0xad}, {0x73, 0x91, 0xad, 0x20}}, // Oceans
+       {{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
@@ -87,6 +86,7 @@ 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);
        if (!path) return; // Canceled/error
 
@@ -218,6 +218,9 @@ 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",
@@ -233,7 +236,7 @@ static void grits_plugin_map_dispose(GObject *gobject)
        /* Drop references */
        if (map->viewer) {
                g_signal_handler_disconnect(map->viewer, map->sigid);
-               grits_viewer_remove(map->viewer, map->tiles);
+               grits_viewer_remove(map->viewer, GRITS_OBJECT(map->tiles));
                soup_session_abort(map->wms->http->soup);
                g_thread_pool_free(map->threads, TRUE, TRUE);
                while (gtk_events_pending())
@@ -248,6 +251,7 @@ 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_tile_free(map->tiles, _free_tile, map);
        G_OBJECT_CLASS(grits_plugin_map_parent_class)->finalize(gobject);