gint x,
gint y,
gchar *filename_buf,
- gint buf_len )
+ gint buf_len,
+ const gchar* file_extension )
{
switch ( cl ) {
case VIK_MAPS_CACHE_LAYOUT_OSM:
if ( name ) {
if ( g_strcmp0 ( cache_dir, MAPS_CACHE_DIR ) )
// Cache dir not the default - assume it's been directed somewhere specific
- g_snprintf ( filename_buf, buf_len, DIRECTDIRACCESS, cache_dir, (17 - scale), x, y, ".png" );
+ g_snprintf ( filename_buf, buf_len, DIRECTDIRACCESS, cache_dir, (17 - scale), x, y, file_extension );
else
// Using default cache - so use the map name in the directory path
- g_snprintf ( filename_buf, buf_len, DIRECTDIRACCESS_WITH_NAME, cache_dir, name, (17 - scale), x, y, ".png" );
+ g_snprintf ( filename_buf, buf_len, DIRECTDIRACCESS_WITH_NAME, cache_dir, name, (17 - scale), x, y, file_extension );
}
else
- g_snprintf ( filename_buf, buf_len, DIRECTDIRACCESS, cache_dir, (17 - scale), x, y, ".png" );
+ g_snprintf ( filename_buf, buf_len, DIRECTDIRACCESS, cache_dir, (17 - scale), x, y, file_extension );
break;
default:
g_snprintf ( filename_buf, buf_len, DIRSTRUCTURE, cache_dir, id, scale, z, x, y );
id, mapcoord->scale, vml->alpha, xshrinkfactor, yshrinkfactor, vml->filename );
if ( ! pixbuf ) {
- if ( vik_map_source_is_direct_file_access (MAPS_LAYER_NTH_TYPE(vml->maptype)) ) {
+ VikMapSource *map = MAPS_LAYER_NTH_TYPE(vml->maptype);
+ if ( vik_map_source_is_direct_file_access(map) ) {
// ATM MBTiles must be 'a direct access type'
- if ( vik_map_source_is_mbtiles (MAPS_LAYER_NTH_TYPE(vml->maptype)) ) {
+ if ( vik_map_source_is_mbtiles(map) ) {
pixbuf = get_mbtiles_pixbuf ( vml, mapcoord->x, mapcoord->y, (17 - mapcoord->scale) );
pixbuf = pixbuf_apply_settings ( pixbuf, vml, mapcoord, xshrinkfactor, yshrinkfactor );
// return now to avoid file tests that aren't appropriate for this map type
}
else
get_filename ( vml->cache_dir, VIK_MAPS_CACHE_LAYOUT_OSM, id, NULL,
- mapcoord->scale, mapcoord->z, mapcoord->x, mapcoord->y, filename_buf, buf_len );
+ mapcoord->scale, mapcoord->z, mapcoord->x, mapcoord->y, filename_buf, buf_len,
+ vik_map_source_get_file_extension(map) );
}
else
get_filename ( vml->cache_dir, vml->cache_layout, id, mapname,
- mapcoord->scale, mapcoord->z, mapcoord->x, mapcoord->y, filename_buf, buf_len );
+ mapcoord->scale, mapcoord->z, mapcoord->x, mapcoord->y, filename_buf, buf_len,
+ vik_map_source_get_file_extension(map) );
if ( g_file_test ( filename_buf, G_FILE_TEST_EXISTS ) == TRUE)
{
if ( existence_only ) {
if ( vik_map_source_is_direct_file_access (MAPS_LAYER_NTH_TYPE(vml->maptype)) )
get_filename ( vml->cache_dir, VIK_MAPS_CACHE_LAYOUT_OSM, id, vik_map_source_get_name(map),
- ulm.scale, ulm.z, ulm.x, ulm.y, path_buf, max_path_len );
+ ulm.scale, ulm.z, ulm.x, ulm.y, path_buf, max_path_len, vik_map_source_get_file_extension(map) );
else
get_filename ( vml->cache_dir, vml->cache_layout, id, vik_map_source_get_name(map),
- ulm.scale, ulm.z, ulm.x, ulm.y, path_buf, max_path_len );
+ ulm.scale, ulm.z, ulm.x, ulm.y, path_buf, max_path_len, vik_map_source_get_file_extension(map) );
if ( g_file_test ( path_buf, G_FILE_TEST_EXISTS ) == TRUE ) {
GdkGC *black_gc = gtk_widget_get_style(GTK_WIDGET(vvp))->black_gc;
get_filename ( mdi->cache_dir, mdi->cache_layout,
vik_map_source_get_uniq_id(MAPS_LAYER_NTH_TYPE(mdi->maptype)),
vik_map_source_get_name(MAPS_LAYER_NTH_TYPE(mdi->maptype)),
- mdi->mapcoord.scale, mdi->mapcoord.z, x, y, mdi->filename_buf, mdi->maxlen );
+ mdi->mapcoord.scale, mdi->mapcoord.z, x, y, mdi->filename_buf, mdi->maxlen,
+ vik_map_source_get_file_extension(MAPS_LAYER_NTH_TYPE(mdi->maptype)) );
donemaps++;
int res = a_background_thread_progress ( threaddata, ((gdouble)donemaps) / mdi->mapstoget ); /* this also calls testcancel */
get_filename ( mdi->cache_dir, mdi->cache_layout,
vik_map_source_get_uniq_id(MAPS_LAYER_NTH_TYPE(mdi->maptype)),
vik_map_source_get_name(MAPS_LAYER_NTH_TYPE(mdi->maptype)),
- mdi->mapcoord.scale, mdi->mapcoord.z, mdi->mapcoord.x, mdi->mapcoord.y, mdi->filename_buf, mdi->maxlen );
+ mdi->mapcoord.scale, mdi->mapcoord.z, mdi->mapcoord.x, mdi->mapcoord.y, mdi->filename_buf, mdi->maxlen,
+ vik_map_source_get_file_extension(MAPS_LAYER_NTH_TYPE(mdi->maptype)) );
if ( g_file_test ( mdi->filename_buf, G_FILE_TEST_EXISTS ) == TRUE)
{
g_remove ( mdi->filename_buf );
get_filename ( mdi->cache_dir, mdi->cache_layout,
vik_map_source_get_uniq_id(map),
vik_map_source_get_name(map),
- ulm.scale, ulm.z, a, b, mdi->filename_buf, mdi->maxlen );
+ ulm.scale, ulm.z, a, b, mdi->filename_buf, mdi->maxlen,
+ vik_map_source_get_file_extension(map) );
if ( g_file_test ( mdi->filename_buf, G_FILE_TEST_EXISTS ) == FALSE )
mdi->mapstoget++;
}
get_filename ( mdi->cache_dir, mdi->cache_layout,
vik_map_source_get_uniq_id(map),
vik_map_source_get_name(map),
- ulm.scale, ulm.z, i, j, mdi->filename_buf, mdi->maxlen );
+ ulm.scale, ulm.z, i, j, mdi->filename_buf, mdi->maxlen,
+ vik_map_source_get_file_extension(map) );
if ( g_file_test ( mdi->filename_buf, G_FILE_TEST_EXISTS ) == FALSE )
mdi->mapstoget++;
}
get_filename ( vml->cache_dir, VIK_MAPS_CACHE_LAYOUT_OSM,
vik_map_source_get_uniq_id(map),
NULL,
- ulm.scale, ulm.z, ulm.x, ulm.y, filename, max_path_len );
+ ulm.scale, ulm.z, ulm.x, ulm.y, filename, max_path_len,
+ vik_map_source_get_file_extension(map) );
source = g_strconcat ( "file://", filename, NULL );
}
}
get_filename ( vml->cache_dir, vml->cache_layout,
vik_map_source_get_uniq_id(map),
vik_map_source_get_name(map),
- ulm.scale, ulm.z, ulm.x, ulm.y, filename, max_path_len );
+ ulm.scale, ulm.z, ulm.x, ulm.y, filename, max_path_len,
+ vik_map_source_get_file_extension(map) );
source = g_strdup_printf ( "http://%s%s",
vik_map_source_default_get_hostname ( VIK_MAP_SOURCE_DEFAULT(map) ),
vik_map_source_default_get_uri ( VIK_MAP_SOURCE_DEFAULT(map), &ulm ) );
get_filename ( mdi->cache_dir, mdi->cache_layout,
vik_map_source_get_uniq_id(map),
vik_map_source_get_name(map),
- ulm.scale, ulm.z, i, j, mdi->filename_buf, mdi->maxlen );
+ ulm.scale, ulm.z, i, j, mdi->filename_buf, mdi->maxlen,
+ vik_map_source_get_file_extension(map) );
if ( mdi->redownload == REDOWNLOAD_NEW ) {
// Assume the worst - always a new file
// Absolute value would requires server lookup - but that is too slow
static guint16 map_source_get_tilesize_x (VikMapSource *self);
static guint16 map_source_get_tilesize_y (VikMapSource *self);
static VikViewportDrawMode map_source_get_drawmode (VikMapSource *self);
+static const gchar *map_source_get_file_extension (VikMapSource *self);
static DownloadResult_t _download ( VikMapSource *self, MapCoord *src, const gchar *dest_fn, void *handle );
static void * _download_handle_init ( VikMapSource *self );
guint16 tilesize_x;
guint16 tilesize_y;
VikViewportDrawMode drawmode;
+ gchar *file_extension;
};
#define VIK_MAP_SOURCE_DEFAULT_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VIK_TYPE_MAP_SOURCE_DEFAULT, VikMapSourceDefaultPrivate))
PROP_COPYRIGHT,
PROP_LICENSE,
PROP_LICENSE_URL,
+ PROP_FILE_EXTENSION,
};
G_DEFINE_ABSTRACT_TYPE (VikMapSourceDefault, vik_map_source_default, VIK_TYPE_MAP_SOURCE);
priv->license_url = NULL;
priv->logo = NULL;
priv->name = NULL;
+ priv->file_extension = NULL;
}
static void
priv->license_url = NULL;
g_free (priv->name);
priv->name = NULL;
+ g_free (priv->file_extension);
+ priv->file_extension = NULL;
G_OBJECT_CLASS (vik_map_source_default_parent_class)->finalize (object);
}
priv->license_url = g_strdup(g_value_get_string (value));
break;
+ case PROP_FILE_EXTENSION:
+ g_free (priv->file_extension);
+ priv->file_extension = g_strdup(g_value_get_string(value));
+ break;
+
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
g_value_set_string (value, priv->license_url);
break;
+ case PROP_FILE_EXTENSION:
+ g_value_set_string (value, priv->file_extension);
+ break;
+
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
parent_class->get_tilesize_x = map_source_get_tilesize_x;
parent_class->get_tilesize_y = map_source_get_tilesize_y;
parent_class->get_drawmode = map_source_get_drawmode;
+ parent_class->get_file_extension = map_source_get_file_extension;
parent_class->download = _download;
parent_class->download_handle_init = _download_handle_init;
parent_class->download_handle_cleanup = _download_handle_cleanup;
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_LICENSE_URL, pspec);
+ pspec = g_param_spec_string ("file-extension",
+ "File Extension",
+ "The file extension of tile files on disk",
+ ".png" /* default value */,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+ g_object_class_install_property (object_class, PROP_FILE_EXTENSION, pspec);
+
g_type_class_add_private (klass, sizeof (VikMapSourceDefaultPrivate));
object_class->finalize = vik_map_source_default_finalize;
return res;
}
+static const gchar *
+map_source_get_file_extension (VikMapSource *self)
+{
+ g_return_val_if_fail (VIK_IS_MAP_SOURCE_DEFAULT(self), NULL);
+ VikMapSourceDefaultPrivate *priv = VIK_MAP_SOURCE_DEFAULT_PRIVATE(self);
+ return priv->file_extension;
+}
+
static void *
_download_handle_init ( VikMapSource *self )
{