- pixbuf = get_pixbuf ( vml, mode, &ulm, path_buf, max_path_len, xshrinkfactor, yshrinkfactor );
- if ( pixbuf )
- vik_viewport_draw_pixbuf ( vvp, pixbuf, 0, 0, xx, yy, tilesize_x_ceil, tilesize_y_ceil );
+
+ if ( existence_only ) {
+ g_snprintf ( path_buf, max_path_len, DIRSTRUCTURE,
+ vml->cache_dir, mode,
+ ulm.scale, ulm.z, ulm.x, ulm.y );
+ if ( g_file_test ( path_buf, G_FILE_TEST_EXISTS ) == TRUE ) {
+ vik_viewport_draw_line ( vvp, black_gc, xx+tilesize_x_ceil, yy, xx, yy+tilesize_y_ceil );
+ }
+ } else {
+ pixbuf = get_pixbuf ( vml, mode, &ulm, path_buf, max_path_len, xshrinkfactor, yshrinkfactor );
+ if ( pixbuf )
+ vik_viewport_draw_pixbuf ( vvp, pixbuf, 0, 0, xx, yy, tilesize_x_ceil, tilesize_y_ceil );
+ else {
+ /* retry with bigger shrinkfactor */
+ int scale_inc;
+ for (scale_inc = 1; scale_inc < 4; scale_inc ++) {
+ int scale_factor = 1 << scale_inc; /* 2^scale_inc */
+ MapCoord ulm2 = ulm;
+ ulm2.x = ulm.x / scale_factor;
+ ulm2.y = ulm.y / scale_factor;
+ ulm2.scale = ulm.scale + scale_inc;
+ pixbuf = get_pixbuf ( vml, mode, &ulm2, path_buf, max_path_len, xshrinkfactor * scale_factor, yshrinkfactor * scale_factor );
+ if ( pixbuf ) {
+ gint src_x = (ulm.x % scale_factor) * tilesize_x_ceil;
+ gint src_y = (ulm.y % scale_factor) * tilesize_y_ceil;
+ vik_viewport_draw_pixbuf ( vvp, pixbuf, src_x, src_y, xx, yy, tilesize_x_ceil, tilesize_y_ceil );
+ break;
+ }
+ }
+ }
+ }