]> git.street.me.uk Git - andy/viking.git/blobdiff - src/google.c
Fix bug that causes crashes when click at the right of the track graph.
[andy/viking.git] / src / google.c
index c4375434f750474feab09695e19491e960d41bd7..22210102d1c055082096614bea595d22d59018b5 100644 (file)
 #include "http.h"
 #include "globals.h"
 #include "google.h"
+#include "vikmapslayer.h"
+
+#define GOOGLE_VERSION "w2.37"
+#define GOOGLE_TRANS_VERSION "w2t.38"
+#define GOOGLE_KH_VERSION "14"
+
+void google_init () {
+  VikMapsLayer_MapType google_1 = { 7, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, google_coord_to_mapcoord, google_mapcoord_to_center_coord, google_download };
+  VikMapsLayer_MapType google_2 = { 10, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, google_coord_to_mapcoord, google_mapcoord_to_center_coord, google_trans_download };
+  VikMapsLayer_MapType google_3 = { 11, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, google_coord_to_mapcoord, google_mapcoord_to_center_coord, google_kh_download };
+
+  maps_layer_register_type("Google Maps", 7, &google_1);
+  maps_layer_register_type("Transparent Google Maps", 10, &google_2);
+  maps_layer_register_type("Google Satellite Images", 11, &google_3);
+}
 
 /* 1 << (x) is like a 2**(x) */
 #define GZ(x) ((1<<x))
@@ -82,12 +97,12 @@ static void real_google_download ( MapCoord *src, const gchar *dest_fn, const ch
 
 void google_download ( MapCoord *src, const gchar *dest_fn )
 {
-   real_google_download ( src, dest_fn, "w2.35" );
+   real_google_download ( src, dest_fn, GOOGLE_VERSION );
 }
 
 void google_trans_download ( MapCoord *src, const gchar *dest_fn )
 {
-   real_google_download ( src, dest_fn, "w2t.1" );
+   real_google_download ( src, dest_fn, GOOGLE_TRANS_VERSION );
 }
 
 static char *kh_encode(guint32 x, guint32 y, guint8 scale)
@@ -134,7 +149,7 @@ static char *kh_encode(guint32 x, guint32 y, guint8 scale)
 void google_kh_download ( MapCoord *src, const gchar *dest_fn )
 {
    gchar *khenc = kh_encode( src->x, src->y, src->scale );
-   gchar *uri = g_strdup_printf ( "/kh?v=3&t=%s", khenc );
+   gchar *uri = g_strdup_printf ( "/kh?v=%s&t=%s", GOOGLE_KH_VERSION, khenc );
    g_free ( khenc );
    a_http_download_get_url ( "kh.google.com", uri, dest_fn );
    g_free ( uri );