X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/9f58c4b4841869d578c2047cd4774179a8919fa7..9b082b39e38d42b4a7ac775bbb50a75e9d352ff8:/src/bingmapsource.c?ds=sidebyside diff --git a/src/bingmapsource.c b/src/bingmapsource.c index c1f1da14..81ba1fd4 100644 --- a/src/bingmapsource.c +++ b/src/bingmapsource.c @@ -46,8 +46,8 @@ #include #include #include "globals.h" -#include "curl_download.h" #include "bingmapsource.h" +#include "maputils.h" #include "bbox.h" #include "background.h" #include "icons/icons.h" @@ -56,7 +56,7 @@ #define URL_ATTR_FMT "http://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial/0,0?zl=1&mapVersion=v1&key=%s&include=ImageryProviders&output=xml" static gchar *_get_uri ( VikMapSourceDefault *self, MapCoord *src ); -static void _get_copyright (VikMapSource * self, LatLonBBox bbox, gdouble zoom, void (*fct)(void*,const gchar*), void *data); +static void _get_copyright (VikMapSource * self, LatLonBBox bbox, gdouble zoom, void (*fct)(VikViewport*,const gchar*), void *data); static const GdkPixbuf *_get_logo ( VikMapSource *self ); static int _load_attributions ( BingMapSource *self ); static void _async_load_attributions ( BingMapSource *self ); @@ -232,14 +232,14 @@ _get_logo( VikMapSource *self ) } static void -_get_copyright(VikMapSource * self, LatLonBBox bbox, gdouble zoom, void (*fct)(void*,const gchar*), void *data) +_get_copyright(VikMapSource * self, LatLonBBox bbox, gdouble zoom, void (*fct)(VikViewport*,const gchar*), void *data) { g_return_if_fail (BING_IS_MAP_SOURCE(self)); g_debug("%s: looking for %g %g %g %g at %g", __FUNCTION__, bbox.south, bbox.north, bbox.east, bbox.west, zoom); BingMapSourcePrivate *priv = BING_MAP_SOURCE_GET_PRIVATE(self); - int level = vik_slippy_map_source_zoom_to_scale (zoom); + int level = map_utils_mpp_to_scale (zoom); /* Loop over all known attributions */ GList *attribution = priv->attributions; @@ -391,32 +391,12 @@ _parse_file_for_attributions(BingMapSource *self, gchar *filename) static int _load_attributions ( BingMapSource *self ) { - FILE *tmp_file; - int tmp_fd; - gchar *tmpname; - gchar *uri; int ret = 0; /* OK */ BingMapSourcePrivate *priv = BING_MAP_SOURCE_GET_PRIVATE (self); + gchar *uri = g_strdup_printf(URL_ATTR_FMT, priv->api_key); - if ((tmp_fd = g_file_open_tmp ("vik-bing.XXXXXX", &tmpname, NULL)) == -1) { - g_critical(_("couldn't open temp file")); - return -1; - } - - tmp_file = fdopen(tmp_fd, "r+"); - uri = g_strdup_printf(URL_ATTR_FMT, priv->api_key); - - /* TODO: curl may not be available */ - if (curl_download_uri(uri, tmp_file, vik_map_source_default_get_download_options(VIK_MAP_SOURCE_DEFAULT(self)), 0, NULL)) { /* error */ - fclose(tmp_file); - tmp_file = NULL; - ret = -1; - goto done; - } - - fclose(tmp_file); - tmp_file = NULL; + gchar *tmpname = a_download_uri_to_tmp_file ( uri, vik_map_source_default_get_download_options(VIK_MAP_SOURCE_DEFAULT(self)) ); g_debug("%s: %s", __FUNCTION__, tmpname); if (!_parse_file_for_attributions(self, tmpname)) { @@ -439,6 +419,7 @@ _emit_update ( gpointer data ) vik_layers_panel_emit_update ( VIK_LAYERS_PANEL (data) ); */ gdk_threads_leave(); + return 0; } static int