]> git.street.me.uk Git - andy/viking.git/commitdiff
Google terrain maps.
authorEvan Battaglia <gtoevan@gmx.net>
Sat, 8 Dec 2007 03:54:33 +0000 (03:54 +0000)
committerEvan Battaglia <gtoevan@gmx.net>
Sat, 8 Dec 2007 03:54:33 +0000 (03:54 +0000)
ChangeLog
src/google.c

index 72e0cfee86c2f5ae5ef2b2b402b3e7f37e0ae88e..1f69710e612a585322740c33433629062c9f1a50 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-12-07
+Evan Battaglia <gtoevan@gmx.net>:
+       * BlueMarble tiles: http://mike.teczno.com/notes/blue-marble-tiles.html
+       * Google Terrain maps
+
 2007-11-27:
 Guilhem Bonnefille <guilhem.bonnefille@gmail.com>:
        * util.c: Use a list of possible browsers.
index e66ed12d2a5eba9f92c4d3406466a87489bee1e2..eac49bc4e4f34e9d705a340be4482af6278d8c6e 100644 (file)
@@ -36,6 +36,7 @@
 
 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 );
@@ -46,10 +47,12 @@ 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 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) */
@@ -74,6 +77,7 @@ typedef enum {
        TYPE_GOOGLE_MAPS = 0,
        TYPE_GOOGLE_TRANS,
        TYPE_GOOGLE_SAT,
+       TYPE_GOOGLE_TERRAIN,
 
        TYPE_GOOGLE_NUM
 } GoogleType;
@@ -96,7 +100,7 @@ static gchar *parse_version_number(gchar *text)
 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;
@@ -105,7 +109,7 @@ static const gchar *google_version_number(MapCoord *mapcoord, GoogleType google_
   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";
@@ -117,7 +121,7 @@ static const gchar *google_version_number(MapCoord *mapcoord, GoogleType google_
 
 
   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);
@@ -143,12 +147,14 @@ static const gchar *google_version_number(MapCoord *mapcoord, GoogleType google_
     }
 
     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;
         }
@@ -164,6 +170,7 @@ static const gchar *google_version_number(MapCoord *mapcoord, GoogleType google_
       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");
@@ -172,6 +179,8 @@ static const gchar *google_version_number(MapCoord *mapcoord, GoogleType google_
       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);
 
@@ -231,6 +240,12 @@ static int google_trans_download ( MapCoord *src, const gchar *dest_fn )
    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) );