]> git.street.me.uk Git - andy/viking.git/commitdiff
Allow specifying an alternative URL base location for acquiring DEM SRTM files.
authorRob Norris <rw_norris@hotmail.com>
Sun, 15 Jan 2017 15:44:46 +0000 (15:44 +0000)
committerRob Norris <rw_norris@hotmail.com>
Sun, 22 Jan 2017 18:23:36 +0000 (18:23 +0000)
Advanced configuration setting only in viking.ini.
No GUI method provided ATM, as it's unlikely this setting needs changing.

help/C/viking.xml
src/vikdemlayer.c

index 4de9f4b9074e1b6404048644c2c94c39a7800102..159c19099548b9f2f663a8cec147a506bac1910d 100644 (file)
@@ -3457,6 +3457,11 @@ Accept: */*
          <listitem>
            <para>maps_scale_smaller_zoom_first=true</para>
          </listitem>
+         <listitem>
+           <para>srtm_http_base_url=https://dds.cr.usgs.gov/srtm/version2_1/SRTM3</para>
+           <para>Allows using an alternative service for acquiring DEM SRTM files.
+           Note that the layout on the server needs to be split into Continent directories.</para>
+         </listitem>
          <listitem>
            <para>mapnik_buffer_size=128 (in pixels)</para>
          </listitem>
index d554f673170ba6553fdf84b6d744bf3d6247328b..934a755964a5409c8e06a86a384cdcdb33be14bf 100644 (file)
 #include "icons/icons.h"
 
 #define MAPS_CACHE_DIR maps_layer_default_dir()
-
 #define SRTM_CACHE_TEMPLATE "%ssrtm3-%s%s%c%02d%c%03d.hgt.zip"
+
 #define SRTM_HTTP_BASE_URL "https://dds.cr.usgs.gov/srtm/version2_1/SRTM3"
+static gchar *base_url = NULL;
+#define VIK_SETTINGS_SRTM_HTTP_BASE_URL "srtm_http_base_url"
 
 #ifdef VIK_CONFIG_DEM24K
 #define DEM24K_DOWNLOAD_SCRIPT "dem24k.pl"
@@ -259,6 +261,16 @@ struct _VikDEMLayer {
   GtkMenu *right_click_menu;
 };
 
+// NB Only performed once per program run
+static void vik_dem_class_init ( VikDEMLayerClass *klass )
+{
+  // Note if suppling your own base URL - the site must still follow the Continent directory layout
+  if ( ! a_settings_get_string ( VIK_SETTINGS_SRTM_HTTP_BASE_URL, &base_url ) ) {
+    // Otherwise use the default
+    base_url = g_strdup ( SRTM_HTTP_BASE_URL );
+  }
+}
+
 GType vik_dem_layer_get_type ()
 {
   static GType vdl_type = 0;
@@ -270,7 +282,7 @@ GType vik_dem_layer_get_type ()
       sizeof (VikDEMLayerClass),
       NULL, /* base_init */
       NULL, /* base_finalize */
-      NULL, /* class init */
+      (GClassInitFunc) vik_dem_class_init, /* class init */
       NULL, /* class_finalize */
       NULL, /* class_data */
       sizeof (VikDEMLayer),
@@ -949,7 +961,7 @@ static void srtm_dem_download_thread ( DEMDownloadParams *p, gpointer threaddata
   }
 
   gchar *src_url = g_strdup_printf("%s/%s/%c%02d%c%03d.hgt.zip",
-                SRTM_HTTP_BASE_URL,
+                base_url,
                 continent_dir,
                (intlat >= 0) ? 'N' : 'S',
                ABS(intlat),
@@ -1209,7 +1221,7 @@ static void dem_layer_file_info ( GtkWidget *widget, struct LatLon *ll )
   gchar *source = NULL;
   if ( continent_dir )
     source = g_strdup_printf ( "%s/%s/%c%02d%c%03d.hgt.zip",
-                               SRTM_HTTP_BASE_URL,
+                               base_url,
                                continent_dir,
                                (intlat >= 0) ? 'N' : 'S',
                                ABS(intlat),