]> git.street.me.uk Git - andy/viking.git/blobdiff - src/osm.c
Add menu item for help contents
[andy/viking.git] / src / osm.c
index 0443639de4993fb2b3e69a19a741fd109ace276b..18c10a5de5382934d3f010af1732a4624060380e 100644 (file)
--- a/src/osm.c
+++ b/src/osm.c
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#ifdef HAVE_MATH_H
 #include <math.h>
+#endif
 #include "viking.h"
 #include "coords.h"
 #include "vikcoord.h"
 #include "mapcoord.h"
 #include "vikmapslayer.h"
+#include "vikwebtoolcenter.h"
+#include "vikexttools.h"
 
 #include "osm.h"
 
@@ -36,17 +44,55 @@ static void osm_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest );
 static int osm_maplint_download ( MapCoord *src, const gchar *dest_fn );
 static int osm_mapnik_download ( MapCoord *src, const gchar *dest_fn );
 static int osm_osmarender_download ( MapCoord *src, const gchar *dest_fn );
+static int osm_cycle_download ( MapCoord *src, const gchar *dest_fn );
+#ifdef VIK_CONFIG_BLUEMARBLE
+static int bluemarble_download ( MapCoord *src, const gchar *dest_fn );
+#endif
+#ifdef VIK_CONFIG_OPENAERIAL
+static int openaerialmap_download ( MapCoord *src, const gchar *dest_fn );
+#endif
 
-static DownloadOptions osm_options = { NULL, 0 };
+static DownloadOptions osm_options = { NULL, 0, a_check_map_file };
 
 /* initialisation */
 void osm_init () {
   VikMapsLayer_MapType osmarender_type = { 12, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, osm_osmarender_download };
   VikMapsLayer_MapType mapnik_type = { 13, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, osm_mapnik_download };  VikMapsLayer_MapType maplint_type = { 14, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, osm_maplint_download };
+  VikMapsLayer_MapType cycle_type = { 17, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, osm_cycle_download };
+
+#ifdef VIK_CONFIG_BLUEMARBLE
+  VikMapsLayer_MapType bluemarble_type = { 15, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, bluemarble_download };
+#endif
+
+#ifdef VIK_CONFIG_OPENAERIAL
+  VikMapsLayer_MapType openaerialmap_type = { 20, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, openaerialmap_download };
+#endif
 
   maps_layer_register_type("OpenStreetMap (Osmarender)", 12, &osmarender_type);
   maps_layer_register_type("OpenStreetMap (Mapnik)", 13, &mapnik_type);
   maps_layer_register_type("OpenStreetMap (Maplint)", 14, &maplint_type);
+  maps_layer_register_type("OpenStreetMap (Cycle)", 17, &cycle_type);
+
+#ifdef VIK_CONFIG_BLUEMARBLE
+  maps_layer_register_type("BlueMarble", 15, &bluemarble_type);
+#endif
+#ifdef VIK_CONFIG_OPENAERIAL
+  maps_layer_register_type("OpenAerialMap", 20, &openaerialmap_type);
+#endif
+
+  // Webtools
+  VikWebtoolCenter *webtool = NULL;
+  webtool = vik_webtool_center_new_with_members ( _("OSM (view)"), "http://openstreetmap.org/?lat=%s&lon=%s&zoom=%d&layers=B000FTF" );
+  vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
+  g_object_unref ( webtool );
+
+  webtool = vik_webtool_center_new_with_members ( _("OSM (edit)"), "http://www.openstreetmap.org/edit?lat=%s&lon=%s&zoom=%d" );
+  vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
+  g_object_unref ( webtool );
+
+  webtool = vik_webtool_center_new_with_members ( _("OSM (render)"), "http://www.informationfreeway.org/?lat=%s&lon=%s&zoom=%d&layers=B0000F000F" );
+  vik_ext_tools_register ( VIK_EXT_TOOL ( webtool ) );
+  g_object_unref ( webtool );
 }
 
 /* 1 << (x) is like a 2**(x) */
@@ -98,8 +144,8 @@ static void osm_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest )
 static int osm_maplint_download ( MapCoord *src, const gchar *dest_fn )
 {
    int res = -1;
-   gchar *uri = g_strdup_printf ( "/~ojw/Tiles/maplint.php/%d/%d/%d.png", 17-src->scale, src->x, src->y );
-   res = a_http_download_get_url ( "dev.openstreetmap.org", uri, dest_fn, &osm_options );
+   gchar *uri = g_strdup_printf ( "/Tiles/maplint.php/%d/%d/%d.png", 17-src->scale, src->x, src->y );
+   res = a_http_download_get_url ( "tah.openstreetmap.org", uri, dest_fn, &osm_options );
    g_free ( uri );
    return res;
 }
@@ -107,7 +153,7 @@ static int osm_maplint_download ( MapCoord *src, const gchar *dest_fn )
 static int osm_mapnik_download ( MapCoord *src, const gchar *dest_fn )
 {
    int res = -1;
-   gchar *uri = g_strdup_printf ( "/osamrender/%d/%d/%d.png", 17-src->scale, src->x, src->y );
+   gchar *uri = g_strdup_printf ( "/%d/%d/%d.png", 17-src->scale, src->x, src->y );
    res = a_http_download_get_url ( "tile.openstreetmap.org", uri, dest_fn, &osm_options );
    g_free ( uri );
    return res;
@@ -116,8 +162,42 @@ static int osm_mapnik_download ( MapCoord *src, const gchar *dest_fn )
 static int osm_osmarender_download ( MapCoord *src, const gchar *dest_fn )
 {
    int res = -1;
-   gchar *uri = g_strdup_printf ( "/~ojw/Tiles/tile.php/%d/%d/%d.png", 17-src->scale, src->x, src->y );
-   res = a_http_download_get_url ( "dev.openstreetmap.org", uri, dest_fn, &osm_options );
+   gchar *uri = g_strdup_printf ( "/Tiles/tile/%d/%d/%d.png", 17-src->scale, src->x, src->y );
+   res = a_http_download_get_url ( "tah.openstreetmap.org", uri, dest_fn, &osm_options );
+   g_free ( uri );
+   return res;
+}
+
+#ifdef VIK_CONFIG_BLUEMARBLE
+static int bluemarble_download ( MapCoord *src, const gchar *dest_fn )
+{
+   int res = -1;
+   gchar *uri = g_strdup_printf ( "/com.modestmaps.bluemarble/%d-r%d-c%d.jpg", 17-src->scale, src->y, src->x );
+   res = a_http_download_get_url ( "s3.amazonaws.com", uri, dest_fn, &osm_options );
+
+   g_free ( uri );
+   return res;
+
+}
+#endif
+   
+#ifdef VIK_CONFIG_OPENAERIAL
+static int openaerialmap_download ( MapCoord *src, const gchar *dest_fn )
+{
+   int res = -1;
+   gchar *uri = g_strdup_printf ( "/tiles/1.0.0/openaerialmap-900913/%d/%d/%d.jpg", 17-src->scale, src->x, src->y );
+   res = a_http_download_get_url ( "tile.openaerialmap.org", uri, dest_fn, &osm_options );
+
+   g_free ( uri );
+   return res;
+}
+#endif
+
+static int osm_cycle_download ( MapCoord *src, const gchar *dest_fn )
+{
+   int res = -1;
+   gchar *uri = g_strdup_printf ( "/tiles/cycle/%d/%d/%d.png", 17-src->scale, src->x, src->y );
+   res = a_http_download_get_url ( "andy.sandbox.cloudmade.com", uri, dest_fn, &osm_options );
    g_free ( uri );
    return res;
 }