+void maps_layer_download_section_without_redraw( VikMapsLayer *vml, VikViewport *vvp, VikCoord *ul, VikCoord *br, gdouble zoom)
+{
+ MapCoord ulm, brm;
+ VikMapsLayer_MapType *map_type = MAPS_LAYER_NTH_TYPE(vml->maptype);
+
+ if (!map_type->coord_to_mapcoord(ul, zoom, zoom, &ulm)
+ || !map_type->coord_to_mapcoord(br, zoom, zoom, &brm)) {
+ fprintf(stderr, "%s() coord_to_mapcoord() failed\n", __PRETTY_FUNCTION__);
+ return;
+ }
+
+ MapDownloadInfo *mdi = g_malloc(sizeof(MapDownloadInfo));
+ gint i, j;
+
+ mdi->vml = vml;
+ mdi->vvp = vvp;
+ mdi->map_layer_alive = TRUE;
+ mdi->mutex = g_mutex_new();
+ mdi->refresh_display = FALSE;
+
+ mdi->cache_dir = g_strdup ( vml->cache_dir );
+ mdi->maxlen = strlen ( vml->cache_dir ) + 40;
+ mdi->filename_buf = g_malloc ( mdi->maxlen * sizeof(gchar) );
+ mdi->maptype = vml->maptype;
+
+ mdi->mapcoord = ulm;
+
+ mdi->redownload = REDOWNLOAD_NONE;
+
+ mdi->x0 = MIN(ulm.x, brm.x);
+ mdi->xf = MAX(ulm.x, brm.x);
+ mdi->y0 = MIN(ulm.y, brm.y);
+ mdi->yf = MAX(ulm.y, brm.y);
+
+ mdi->mapstoget = 0;
+
+ for (i = mdi->x0; i <= mdi->xf; i++) {
+ for (j = mdi->y0; j <= mdi->yf; j++) {
+ g_snprintf ( mdi->filename_buf, mdi->maxlen, DIRSTRUCTURE,
+ vml->cache_dir, map_type->uniq_id, ulm.scale,
+ ulm.z, i, j );
+ if ( access ( mdi->filename_buf, F_OK ) != 0)
+ mdi->mapstoget++;
+ }
+ }
+
+ mdi->mapcoord.x = mdi->mapcoord.y = 0; /* for cleanup -- no current map */
+
+ if (mdi->mapstoget) {
+ gchar *tmp = g_strdup_printf ( "%s %d %s %s...", "Downloading", mdi->mapstoget, MAPS_LAYER_NTH_LABEL(vml->maptype), (mdi->mapstoget == 1) ? "map" : "maps" );
+
+ g_object_weak_ref(G_OBJECT(mdi->vml), weak_ref_cb, mdi);
+ /* launch the thread */
+ a_background_thread ( VIK_GTK_WINDOW_FROM_LAYER(vml), /* parent window */
+ tmp, /* description string */
+ (vik_thr_func) map_download_thread, /* function to call within thread */
+ mdi, /* pass along data */
+ (vik_thr_free_func) mdi_free, /* function to free pass along data */
+ (vik_thr_free_func) mdi_cancel_cleanup,
+ mdi->mapstoget );
+ g_free ( tmp );
+ }
+ else
+ mdi_free ( mdi );
+}
+