X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/cdcaf41c6bb6275fb40f59ad1b32a4485525c489..355fba114cb61cc3b9828c85f1341c46caf4a335:/src/expedia.c diff --git a/src/expedia.c b/src/expedia.c index 55397632..6fc0d1fc 100644 --- a/src/expedia.c +++ b/src/expedia.c @@ -21,21 +21,36 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include #include +#ifdef HAVE_MATH_H #include +#endif + #include "globals.h" #include "coords.h" #include "vikcoord.h" #include "mapcoord.h" -#include "http.h" +#include "download.h" #include "vikmapslayer.h" #include "expedia.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 int expedia_download ( MapCoord *src, const gchar *dest_fn, void *handle ); +static void * expedia_handle_init ( ); +static void expedia_handle_cleanup ( void *handle ); + +static DownloadMapOptions expedia_options = { FALSE, FALSE, NULL, 2, a_check_map_file }; + 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 }; - maps_layer_register_type("Expedia Street Maps", 5, &map_type); + 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); } #define EXPEDIA_SITE "expedia.com" @@ -63,7 +78,7 @@ gdouble expedia_altis_freq ( gint alti ) if ( expedia_altis[i] == alti ) return expedia_altis_degree_freq [ i ]; - g_error ( "Invalid expedia altitude" ); + g_error ( _("Invalid expedia altitude") ); return 0; } @@ -94,7 +109,7 @@ void expedia_snip ( const gchar *file ) old = gdk_pixbuf_new_from_file ( file, &gx ); if (gx) { - g_warning ( "Couldn't open EXPEDIA image file (right after successful download! Please report and delete image file!): %s", gx->message ); + g_warning ( _("Couldn't open EXPEDIA image file (right after successful download! Please report and delete image file!): %s"), gx->message ); g_error_free ( gx ); return; } @@ -105,9 +120,9 @@ void expedia_snip ( const gchar *file ) cropped = gdk_pixbuf_new_subpixbuf ( old, WIDTH_BUFFER, HEIGHT_BUFFER, width - 2*WIDTH_BUFFER, height - 2*HEIGHT_BUFFER ); - gdk_pixbuf_save ( cropped, file, "png", NULL, NULL, &gx ); + gdk_pixbuf_save ( cropped, file, "png", &gx, NULL ); if ( gx ) { - g_warning ( "Couldn't save EXPEDIA image file (right after successful download! Please report and delete image file!): %s", gx->message ); + g_warning ( _("Couldn't save EXPEDIA image file (right after successful download! Please report and delete image file!): %s"), gx->message ); g_error_free ( gx ); } @@ -117,7 +132,7 @@ void expedia_snip ( const gchar *file ) /* if degree_freeq = 60 -> nearest minute (in middle) */ /* everything starts at -90,-180 -> 0,0. then increments by (1/degree_freq) */ -gboolean expedia_coord_to_mapcoord ( const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest ) +static gboolean expedia_coord_to_mapcoord ( const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest ) { gint alti; @@ -147,18 +162,19 @@ void expedia_xy_to_latlon_middle ( gint alti, gint x, gint y, struct LatLon *ll ll->lat = (((gdouble)y) / expedia_altis_freq(alti)) - 90; } -void expedia_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest ) +static void expedia_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest ) { dest->mode = VIK_COORD_LATLON; dest->east_west = (((gdouble)src->x) / expedia_altis_freq(src->scale)) - 180; dest->north_south = (((gdouble)src->y) / expedia_altis_freq(src->scale)) - 90; } -void expedia_download ( MapCoord *src, const gchar *dest_fn ) +static int expedia_download ( MapCoord *src, const gchar *dest_fn, void *handle ) { gint height, width; struct LatLon ll; gchar *uri; + int res = -1; expedia_xy_to_latlon_middle ( src->scale, src->x, src->y, &ll ); @@ -171,9 +187,19 @@ void 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 ); - a_http_download_get_url_nohostname ( "expedia.com", uri, dest_fn ); - - expedia_snip ( dest_fn ); + if ((res = a_http_download_get_url ( EXPEDIA_SITE, uri, dest_fn, &expedia_options, NULL )) == 0) /* All OK */ + 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! +}