#include "hildon-mapper.h"
#include "utils.h"
-#include "map.h"
#include "osm.h"
#include "db.h"
#include "osm-db.h"
#include "ui-common.h"
#include "settings.h"
#include "latlon.h"
-#include "gpx.h"
#include "map-download.h"
#include "iap.h"
#include "map-repo.h"
+#include "gtkmap.h"
static guint _num_downloads=0;
static guint _curr_download=0;
if (msg->easy_handle == _autoroute_data.curl_easy) {
/* This is the autoroute download. */
/* Now, parse the autoroute and update the display. */
- if (_autoroute_data.enabled && gpx_parse(&_route, _autoroute_data.rdl_data.bytes, _autoroute_data.rdl_data.bytes_read, 0)) {
+ if (_autoroute_data.enabled && path_gpx_parse(_route, _autoroute_data.rdl_data.bytes, _autoroute_data.rdl_data.bytes_read, 0)) {
/* Find the nearest route point, if we're connected. */
- route_find_nearest_point();
- map_force_redraw();
+ path_find_nearest_point(_route, _gps->data.lat, _gps->data.lon);
}
- route_cancel_autoroute(TRUE); /* We're done. Clean up. */
+ route_cancel_autoroute(_route, TRUE); /* We're done. Clean up. */
} else {
ProgressUpdateInfo *pui = g_hash_table_lookup(pui_by_easy, msg->easy_handle);
g_queue_push_head(curl_easy_queue, msg->easy_handle);
return TRUE;
}
+#ifdef MAP_DOWNLOAD_WMS
/**
* Given a wms uri pattern, compute the coordinate transformation and
* trimming.
* 'proj' is used for the conversion
*/
+
+#define WMS_TILE_SIZE_PIXELS (256)
+
static gchar *
map_convert_wms_to_wms(gint tilex, gint tiley, gint zoomlevel, gchar * uri)
{
srs[srsstre - srsstr - 4] = 0;
/* convert to lower, as WMC is EPSG and cs2cs is epsg */
-gint dwidth = widthstr ? atoi(widthstr + 6) - TILE_SIZE_PIXELS : 0;
-gint dheight = heightstr ? atoi(heightstr + 7) - TILE_SIZE_PIXELS : 0;
+gint dwidth = widthstr ? atoi(widthstr + 6) - WMS_TILE_SIZE_PIXELS : 0;
+gint dheight = heightstr ? atoi(heightstr + 7) - WMS_TILE_SIZE_PIXELS : 0;
unit2latlon(tile2zunit(tilex, zoomlevel) - pixel2zunit(dwidth / 2, zoomlevel),
- tile2zunit(tiley + 1, zoomlevel) + pixel2zunit((dheight + 1) / 2, zoomlevel), lat1, lon1);
+ tile2zunit(tiley + 1, zoomlevel) + pixel2zunit((dheight + 1) / 2, zoomlevel), &lat1, &lon1);
unit2latlon(tile2zunit(tilex + 1, zoomlevel) + pixel2zunit((dwidth + 1) / 2, zoomlevel),
- tile2zunit(tiley, zoomlevel) - pixel2zunit(dheight / 2, zoomlevel), lat2, lon2);
+ tile2zunit(tiley, zoomlevel) - pixel2zunit(dheight / 2, zoomlevel), &lat2, &lon2);
setlocale(LC_NUMERIC, "C");
return ret;
}
-
+#endif
/**
* Given the xyz coordinates of our map coordinate system, write the qrst
switch (_curr_repo->type) {
case REPOTYPE_XYZ:
return g_strdup_printf(_curr_repo->url, tilex, tiley, zoom);
-
case REPOTYPE_XYZ_INV:
return g_strdup_printf(_curr_repo->url, 17 - zoom, tilex, tiley);
-
-case REPOTYPE_QUAD_QRST:
- {
- gchar location[MAX_ZOOM + 2];
+case REPOTYPE_QUAD_QRST: {
+ gchar location[32];
map_convert_coords_to_quadtree_string(tilex, tiley, zoom, location, 't', "qrts");
return g_strdup_printf(_curr_repo->url, location);
}
-
-case REPOTYPE_QUAD_ZERO:
- {
+case REPOTYPE_QUAD_ZERO: {
/* This is a zero-based quadtree URI. */
- gchar location[MAX_ZOOM + 2];
+ gchar location[32];
map_convert_coords_to_quadtree_string(tilex, tiley, zoom, location, '\0', "0123");
return g_strdup_printf(_curr_repo->url, location);
}
-
+#ifdef MAP_DOWNLOAD_WMD
case REPOTYPE_WMS:
return map_convert_wms_to_wms(tilex, tiley, zoom, _curr_repo->url);
-
+#endif
default:
return NULL;
}
guint tmp=0;
/* Test if download succeeded (only if retries != 0). */
if (!pui->retries || g_file_test(pui->dest_str, G_FILE_TEST_EXISTS)) {
- gint zoom_diff = pui->zoom - _zoom;
+ gint zoom_diff = pui->zoom - gtk_map_get_zoom(_map);
+#if 0
/* Only refresh at same or "lower" (more detailed) zoom level. */
if (zoom_diff >= 0) {
guint tilex, tiley, tilex_end, tiley_end;
}
g_debug("*** MDIR LOOP: %u", tmp);
}
+#else
+ g_debug("XXX: Add cb or signal or something to inform map widget about fresh tile");
+#endif
}
/* Else the download failed. Update retries and maybe try again. */
else {
pui->tilex = tilex;
pui->tiley = tiley;
pui->zoom = zoom;
-pui->priority = (abs((gint) tilex - unit2tile(_center.unitx)) + abs((gint) tiley - unit2tile(_center.unity)));
+pui->priority = 1;
if (!retries)
pui->priority = -pui->priority; /* "Negative" makes them lowest pri. */
pui->retries = retries;
ProgressUpdateInfo *pui = g_hash_table_lookup(pui_by_easy, msg->easy_handle);
g_queue_push_head(curl_easy_queue, msg->easy_handle);
g_hash_table_remove(pui_by_easy, msg->easy_handle);
- fclose(pui->file);
+ if (pui->file)
+ fclose(pui->file);
curl_multi_remove_handle(_curl_multi, msg->easy_handle);
}
}