static int google_download ( MapCoord *src, const gchar *dest_fn );
static int google_trans_download ( MapCoord *src, const gchar *dest_fn );
+static int google_terrain_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 );
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 google_4 = { 16, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, google_coord_to_mapcoord, google_mapcoord_to_center_coord, google_terrain_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("Google Terrain Maps", 16, &google_4);
}
/* 1 << (x) is like a 2**(x) */
TYPE_GOOGLE_MAPS = 0,
TYPE_GOOGLE_TRANS,
TYPE_GOOGLE_SAT,
+ TYPE_GOOGLE_TERRAIN,
TYPE_GOOGLE_NUM
} GoogleType;
static const gchar *google_version_number(MapCoord *mapcoord, GoogleType google_type)
{
static gboolean first = TRUE;
- static char *vers[] = { "w2.60", "w2t.60", "20" };
+ static char *vers[] = { "w2.60", "w2t.60", "20", "w2p.60" };
FILE *tmp_file;
int tmp_fd;
gchar *tmpname;
gchar *text, *pat, *beg;
GMappedFile *mf;
gsize len;
- gchar *gvers, *tvers, *kvers, *tmpvers;
+ gchar *gvers, *tvers, *kvers, *terrvers, *tmpvers;
static DownloadOptions dl_options = { "http://maps.google.com/", 0 };
static const char *gvers_pat = "http://mt0.google.com/mt?n\\x3d404\\x26v\\x3d";
static const char *kvers_pat = "http://kh0.google.com/kh?n\\x3d404\\x26v\\x3d";
first = FALSE;
- gvers = tvers = kvers = NULL;
+ gvers = tvers = kvers = terrvers = NULL;
if ((tmp_fd = g_file_open_tmp ("vikgvers.XXXXXX", &tmpname, NULL)) == -1) {
g_critical("couldn't open temp file %s\n", tmpname);
exit(1);
}
pat = beg;
- while (!gvers || !tvers) {
+ while (!gvers || !tvers ||!terrvers) {
if ((pat = g_strstr_len(pat, &text[len] - pat, gvers_pat)) != NULL) {
pat += strlen(gvers_pat);
if ((tmpvers = parse_version_number(pat)) != NULL) {
if (strstr(tmpvers, "t."))
tvers = tmpvers;
+ else if (strstr(tmpvers, "p."))
+ terrvers = tmpvers;
else
gvers = tmpvers;
}
vers[TYPE_GOOGLE_MAPS] = gvers;
vers[TYPE_GOOGLE_TRANS] = tvers;
vers[TYPE_GOOGLE_SAT] = kvers;
+ vers[TYPE_GOOGLE_TERRAIN] = terrvers;
}
else
g_warning("Failed getting google version numbers");
fprintf(stderr, "DEBUG gvers=%s\n", gvers);
if (tvers)
fprintf(stderr, "DEBUG tvers=%s\n", tvers);
+ if (terrvers)
+ fprintf(stderr, "DEBUG terrvers=%s\n", terrvers);
if (kvers)
fprintf(stderr, "DEBUG kvers=%s\n", kvers);
return(real_google_download ( src, dest_fn, vers_str ));
}
+static int google_terrain_download ( MapCoord *src, const gchar *dest_fn )
+{
+ const gchar *vers_str = google_version_number(src, TYPE_GOOGLE_TERRAIN);
+ return(real_google_download ( src, dest_fn, vers_str ));
+}
+
static char *kh_encode(guint32 x, guint32 y, guint8 scale)
{
gchar *buf = g_malloc ( (20-scale)*sizeof(gchar) );