]> err.no Git - libchamplain/commitdiff
Add support for OSM Cycle Map and Osmarender tiles
authorPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Wed, 11 Mar 2009 08:41:46 +0000 (10:41 +0200)
committerPierre-Luc Beaudoin <pierre-luc@pierlux.com>
Wed, 11 Mar 2009 08:41:46 +0000 (10:41 +0200)
Aslo fix a bug where tiles were assumed to have 3 bytes per pixel.

champlain/champlain-network-map-source.c
champlain/champlain-network-map-source.h
demos/launcher-gtk.c

index efd89d243f9f9e75fc82414261deaa66e6aebe6b..04788e50158c9c5b88e82cbc1fabe922f3789989 100644 (file)
@@ -277,6 +277,26 @@ champlain_network_map_source_set_tile_uri (ChamplainNetworkMapSource *network_ma
   priv->uri_format = g_strdup (uri_format);
 }
 
+ChamplainMapSource *
+champlain_map_source_new_osm_cyclemap (void)
+{
+  return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_new_full ("OpenStreetMap Cycle Map",
+      "(CC) BY 2.0 OpenStreetMap contributors",
+      "http://creativecommons.org/licenses/by/2.0/", 0, 18, 256,
+      CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+      "http://andy.sandbox.cloudmade.com/tiles/cycle/#Z#/#X#/#Y#.png"));
+}
+
+ChamplainMapSource *
+champlain_map_source_new_osm_osmarender (void)
+{
+  return CHAMPLAIN_MAP_SOURCE (champlain_network_map_source_new_full ("OpenStreetMap Osmarender",
+      "(CC) BY 2.0 OpenStreetMap contributors",
+      "http://creativecommons.org/licenses/by/2.0/", 0, 18, 256,
+      CHAMPLAIN_MAP_PROJECTION_MERCATOR,
+      "http://tah.openstreetmap.org/Tiles/tile/#Z#/#X#/#Y#.png"));
+}
+
 ChamplainMapSource *
 champlain_map_source_new_osm_mapnik (void)
 {
@@ -415,15 +435,29 @@ file_loaded_cb (SoupSession *session,
 */
   GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
   ClutterActor *actor = clutter_texture_new();
-  clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (actor),
+  gboolean ret = FALSE;
+  if (!clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (actor),
       gdk_pixbuf_get_pixels (pixbuf),
       gdk_pixbuf_get_has_alpha (pixbuf),
       gdk_pixbuf_get_width (pixbuf),
       gdk_pixbuf_get_height (pixbuf),
       gdk_pixbuf_get_rowstride (pixbuf),
-      3, 0, NULL);
+      gdk_pixbuf_get_bits_per_sample (pixbuf) *
+      gdk_pixbuf_get_n_channels (pixbuf) / 8,
+      0, &error))
+    {
+      g_print("BPP: %d", gdk_pixbuf_get_bits_per_sample (pixbuf));
+      if (error)
+        {
+          g_warning ("Unable to transfer to clutter: %s", error->message);
+          g_error_free (error);
+          create_error_tile (ctx->tile);
+          goto cleanup;
+        }
+    }
+
   champlain_tile_set_actor (ctx->tile, actor);
-  DEBUG ("Tile loaded from network");
+  DEBUG ("Tile loaded from network %d", ret);
 
 cleanup:
   g_object_unref (loader);
index 789361497654358b23122ab3b5d4a76dc0dabcdd..1eb31f69cf36acd0e498fc83b9ee60f4363c0d93 100644 (file)
@@ -57,6 +57,8 @@ ChamplainNetworkMapSource* champlain_network_map_source_new_full (gchar *name,
     guint tile_size, ChamplainMapProjection projection, gchar *uri_format);
 
 ChamplainMapSource * champlain_map_source_new_osm_mapnik (void);
+ChamplainMapSource * champlain_map_source_new_osm_cyclemap (void);
+ChamplainMapSource * champlain_map_source_new_osm_osmarender (void);
 ChamplainMapSource * champlain_map_source_new_oam (void);
 ChamplainMapSource * champlain_map_source_new_mff_relief (void);
 
index a3a3779fc2d631e55c5f200440a26909e2cb3f30..4b21944add64a5c1110dc2e1c62adbbbd0316ffb 100644 (file)
@@ -27,6 +27,8 @@
 #define OSM_MAP "Open Street Map"
 #define OAM_MAP "Open Arial Map"
 #define MFF_MAP "Maps for free - Relief"
+#define OSM_CYCLE "OSM Cycle Map"
+#define OSM_OSMA "OSM Osmarender"
 
 /*
  * Terminate the main loop.
@@ -90,6 +92,14 @@ map_source_changed (GtkWidget *widget,
     {
       g_object_set (G_OBJECT (view), "map-source", champlain_map_source_new_mff_relief (), NULL);
     }
+  else if (g_strcmp0 (selection, OSM_CYCLE) == 0)
+    {
+      g_object_set (G_OBJECT (view), "map-source", champlain_map_source_new_osm_cyclemap (), NULL);
+    }
+  else if (g_strcmp0 (selection, OSM_OSMA) == 0)
+    {
+      g_object_set (G_OBJECT (view), "map-source", champlain_map_source_new_osm_osmarender (), NULL);
+    }
 }
 
 static void 
@@ -200,6 +210,8 @@ main (int argc,
   gtk_combo_box_append_text(GTK_COMBO_BOX(button), OSM_MAP);
   gtk_combo_box_append_text(GTK_COMBO_BOX(button), OAM_MAP);
   gtk_combo_box_append_text(GTK_COMBO_BOX(button), MFF_MAP);
+  gtk_combo_box_append_text(GTK_COMBO_BOX(button), OSM_CYCLE);
+  gtk_combo_box_append_text(GTK_COMBO_BOX(button), OSM_OSMA);
   gtk_combo_box_set_active(GTK_COMBO_BOX(button), 0);
   g_signal_connect (button, "changed", G_CALLBACK (map_source_changed), view);
   gtk_container_add (GTK_CONTAINER (bbox), button);