]> git.street.me.uk Git - andy/viking.git/blobdiff - src/expedia.c
[QA] Rename and correct some map cache variables usage for better understanding.
[andy/viking.git] / src / expedia.c
index c3363f17ddef69c1dfc57b4f908d74fccd1e7dac..abaec47024f2e683c8ec51a709ffba718ffa9e08 100644 (file)
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+#ifdef HAVE_MATH_H
 #include <math.h>
 #include <math.h>
+#endif
+
 #include "globals.h"
 #include "coords.h"
 #include "vikcoord.h"
 #include "globals.h"
 #include "coords.h"
 #include "vikcoord.h"
 
 static gboolean expedia_coord_to_mapcoord ( const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest );
 static void expedia_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest );
 
 static gboolean expedia_coord_to_mapcoord ( const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest );
 static void expedia_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest );
-static int expedia_download ( MapCoord *src, const gchar *dest_fn );
+static int expedia_download ( MapCoord *src, const gchar *dest_fn, void *handle );
+static void * expedia_handle_init ( );
+static void expedia_handle_cleanup ( void *handle );
 
 
-static DownloadOptions expedia_options = { NULL, 2, a_check_map_file };
+static DownloadMapOptions expedia_options = { FALSE, FALSE, NULL, 2, a_check_map_file, NULL };
 
 void expedia_init() {
 
 void expedia_init() {
-  VikMapsLayer_MapType map_type = { 5, 0, 0, VIK_VIEWPORT_DRAWMODE_EXPEDIA, expedia_coord_to_mapcoord, expedia_mapcoord_to_center_coord, expedia_download };
+  VikMapsLayer_MapType map_type = { 5, 0, 0, VIK_VIEWPORT_DRAWMODE_EXPEDIA, expedia_coord_to_mapcoord, expedia_mapcoord_to_center_coord, expedia_download, expedia_handle_init, expedia_handle_cleanup };
   maps_layer_register_type(_("Expedia Street Maps"), 5, &map_type);
 }
 
   maps_layer_register_type(_("Expedia Street Maps"), 5, &map_type);
 }
 
@@ -164,12 +169,11 @@ static void expedia_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest )
   dest->north_south = (((gdouble)src->y) / expedia_altis_freq(src->scale)) - 90;
 }
 
   dest->north_south = (((gdouble)src->y) / expedia_altis_freq(src->scale)) - 90;
 }
 
-static int expedia_download ( MapCoord *src, const gchar *dest_fn )
+static DownloadResult_t expedia_download ( MapCoord *src, const gchar *dest_fn, void *handle )
 {
   gint height, width;
   struct LatLon ll;
   gchar *uri;
 {
   gint height, width;
   struct LatLon ll;
   gchar *uri;
-  int res = -1;
 
   expedia_xy_to_latlon_middle ( src->scale, src->x, src->y, &ll );
 
 
   expedia_xy_to_latlon_middle ( src->scale, src->x, src->y, &ll );
 
@@ -182,9 +186,20 @@ static int expedia_download ( MapCoord *src, const gchar *dest_fn )
   uri = g_strdup_printf ( "/pub/agent.dll?qscr=mrdt&ID=3XNsF.&CenP=%lf,%lf&Lang=%s&Alti=%d&Size=%d,%d&Offs=0.000000,0.000000&BCheck&tpid=1",
                ll.lat, ll.lon, (ll.lon > -30) ? "EUR0809" : "USA0409", src->scale, width, height );
 
   uri = g_strdup_printf ( "/pub/agent.dll?qscr=mrdt&ID=3XNsF.&CenP=%lf,%lf&Lang=%s&Alti=%d&Size=%d,%d&Offs=0.000000,0.000000&BCheck&tpid=1",
                ll.lat, ll.lon, (ll.lon > -30) ? "EUR0809" : "USA0409", src->scale, width, height );
 
-  if ((res = a_http_download_get_url ( EXPEDIA_SITE, uri, dest_fn, &expedia_options )) == 0)   /* All OK */
+  DownloadResult_t res = a_http_download_get_url ( EXPEDIA_SITE, uri, dest_fn, &expedia_options, NULL );
+  if (res == DOWNLOAD_SUCCESS)
        expedia_snip ( dest_fn );
   g_free(uri);
   return(res);
 }
 
        expedia_snip ( dest_fn );
   g_free(uri);
   return(res);
 }
 
+static void * expedia_handle_init ( )
+{
+  // Not much going on here
+  return 0;
+}
+
+static void expedia_handle_cleanup ( void *handle )
+{
+  // Even less here!
+}