X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/29bcf539df81f287b91df6de5760cf89179cd6e3..a31889935875a7d1d32c8dae2d6218d7938167f8:/src/google.c?ds=sidebyside diff --git a/src/google.c b/src/google.c index f13a4019..4034eccc 100644 --- a/src/google.c +++ b/src/google.c @@ -30,20 +30,26 @@ #include "google.h" #include "vikmapslayer.h" -#define GOOGLE_VERSION "w2.43" -#define GOOGLE_TRANS_VERSION "w2t.40" -#define GOOGLE_KH_VERSION "17" +#define GOOGLE_VERSION "w2.52" +#define GOOGLE_TRANS_VERSION "w2t.53" +#define GOOGLE_KH_VERSION "18" + +static int google_download ( MapCoord *src, const gchar *dest_fn ); +static int google_trans_download ( MapCoord *src, const gchar *dest_fn ); +static int google_kh_download ( MapCoord *src, const gchar *dest_fn ); +static void google_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest ); +static gboolean google_coord_to_mapcoord ( const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest ); + +static DownloadOptions google_options = { 1, "http://maps.google.com/" }; 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 }; - VikMapsLayer_MapType slippy = { 12, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, google_coord_to_mapcoord, google_mapcoord_to_center_coord, google_slippy_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); - maps_layer_register_type("Slippy Maps", 12, &slippy); } /* 1 << (x) is like a 2**(x) */ @@ -90,21 +96,23 @@ void google_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest ) dest->north_south = DEMERCLAT(180 - ((src->y+0.5) / GZ(17) * socalled_mpp * 360)); } -static void real_google_download ( MapCoord *src, const gchar *dest_fn, const char *verstr ) +static int real_google_download ( MapCoord *src, const gchar *dest_fn, const char *verstr ) { + int res; gchar *uri = g_strdup_printf ( "/mt?v=%s&x=%d&y=%d&zoom=%d", verstr, src->x, src->y, src->scale ); - a_http_download_get_url ( "mt.google.com", uri, dest_fn ); + res = a_http_download_get_url ( "mt.google.com", uri, dest_fn, &google_options ); g_free ( uri ); + return res; } -void google_download ( MapCoord *src, const gchar *dest_fn ) +static int google_download ( MapCoord *src, const gchar *dest_fn ) { - real_google_download ( src, dest_fn, GOOGLE_VERSION ); + return(real_google_download ( src, dest_fn, GOOGLE_VERSION )); } -void google_trans_download ( MapCoord *src, const gchar *dest_fn ) +static int google_trans_download ( MapCoord *src, const gchar *dest_fn ) { - real_google_download ( src, dest_fn, GOOGLE_TRANS_VERSION ); + return(real_google_download ( src, dest_fn, GOOGLE_TRANS_VERSION )); } static char *kh_encode(guint32 x, guint32 y, guint8 scale) @@ -148,18 +156,13 @@ static char *kh_encode(guint32 x, guint32 y, guint8 scale) return buf; } -void google_kh_download ( MapCoord *src, const gchar *dest_fn ) +static int google_kh_download ( MapCoord *src, const gchar *dest_fn ) { + int res; gchar *khenc = kh_encode( src->x, src->y, src->scale ); 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 ); -} - -void google_slippy_download ( MapCoord *src, const gchar *dest_fn ) -{ - gchar *uri = g_strdup_printf ( "/%d/%d/%d.png", 17-src->scale, src->x, src->y ); - a_http_download_get_url ( "tile.openstreetmap.org", uri, dest_fn ); + res = a_http_download_get_url ( "kh.google.com", uri, dest_fn, &google_options ); g_free ( uri ); + return(res); }