if ((_conn_state == RCVR_FIXED) && (_track_store==TRUE)) {
if ((_gps_filter==TRUE) && (track_drop_cnt<_filter_maxdrop)) {
- integerize_data(&_gps, &_pos);
+ gps_integerize_data(&_gps, &_pos);
if ( (_gps.hdop<_filter_hdop || _filter_hdop==0.0) &&
(_gps.vdop<_filter_vdop || _filter_vdop==0.0) &&
(fabs(_gps.heading-_gps.lheading)>_filter_angle || _filter_angle==0.0 ) &&
map_refresh_mark();
} else {
track_drop_cnt=0;
- integerize_data(&_gps, &_pos);
+ gps_integerize_data(&_gps, &_pos);
track_add(_pos.time, newly_fixed);
_gps.lheading=_gps.heading;
map_refresh_mark();
#include "gps.h"
#include "latlon.h"
+#include "map.h"
void
gps_init(void)
_pos.unitx = 0;
_pos.unity = 0;
-integerize_data(&_gps, &_pos);
+gps_integerize_data(&_gps, &_pos);
}
/**
* Convert the float lat/lon/speed/heading data into integer units.
*/
void
-integerize_data(GpsData *gps, Point *pos)
+gps_integerize_data(GpsData *gps, Point *pos)
{
gdouble tmp;
latlon2unit(gps->lat, gps->lon, pos->unitx, pos->unity);
-
tmp=(gps->heading*(1.f/180.f))*G_PI;
gps->vel_offsetx=(gint)(floorf(gps->speed*sinf(tmp)+0.5f));
gps->vel_offsety=-(gint)(floorf(gps->speed*cosf(tmp)+0.5f));
Point _pos;
void gps_init(void);
+void gps_integerize_data(GpsData *gps, Point *pos);
gboolean channel_cb_error(GIOChannel * src, GIOCondition condition, gpointer data);
gboolean channel_cb_input(GIOChannel * src, GIOCondition condition, gpointer data);
-void integerize_data(GpsData *gps, Point *pos);
-
#endif
#include "gps.h"
#include "mapper-types.h"
#include "latlon.h"
+#include "map.h"
#include "gpx.h"
#define XML_DATE_FORMAT "%FT%T"
#define MERCATOR_TOP (3.14159188886811f)
#define latlon2unit(lat, lon, unitx, unity) { \
- gdouble tmp; \
- unitx = (lon + 180.f) * (WORLD_SIZE_UNITS / 360.f) + 0.5f; \
- tmp = sinf(lat * (PI / 180.f)); \
- unity = 0.5f + (WORLD_SIZE_UNITS / MERCATOR_SPAN) \
- * (logf((1.f + tmp) / (1.f - tmp)) * 0.5f - MERCATOR_TOP); \
+ gdouble tmp; \
+ unitx = (lon + 180.f) * (WORLD_SIZE_UNITS / 360.f) + 0.5f; \
+ tmp = sinf(lat * (PI / 180.f)); \
+ unity = 0.5f + (WORLD_SIZE_UNITS / MERCATOR_SPAN) \
+ * (logf((1.f + tmp) / (1.f - tmp)) * 0.5f - MERCATOR_TOP); \
}
#define unit2latlon(unitx, unity, lat, lon) { \
- (lon) = ((unitx) * (360.f / WORLD_SIZE_UNITS)) - 180.f; \
- (lat) = (360.f * (atanf(expf(((unity) \
- * (MERCATOR_SPAN / WORLD_SIZE_UNITS)) \
- + MERCATOR_TOP)))) * (1.f / PI) - 90.f; \
+ (lon) = ((unitx) * (360.f / WORLD_SIZE_UNITS)) - 180.f; \
+ (lat) = (360.f * (atanf(expf(((unity) * (MERCATOR_SPAN / WORLD_SIZE_UNITS)) \
+ + MERCATOR_TOP)))) * (1.f / PI) - 90.f; \
}
typedef enum {
return TRUE;
}
+static gint
+download_comparefunc(const ProgressUpdateInfo * a, const ProgressUpdateInfo * b, gpointer user_data)
+{
+gint diff = (a->priority - b->priority);
+if (diff)
+ return diff;
+diff = (a->tilex - b->tilex);
+if (diff)
+ return diff;
+diff = (a->tiley - b->tiley);
+if (diff)
+ return diff;
+diff = (a->zoom - b->zoom);
+if (diff)
+ return diff;
+diff = (a->repo - b->repo);
+if (diff)
+ return diff;
+/* Otherwise, deletes are "greatest" (least priority). */
+if (!a->retries)
+ return (b->retries ? -1 : 0);
+else if (!b->retries)
+ return (a->retries ? 1 : 0);
+/* Do updates after non-updates (because they'll both be done anyway). */
+return (a->retries - b->retries);
+}
+
/**
* Free a ProgressUpdateInfo data structure that was allocated during the
* auto-map-download process.
#include <glib.h>
#include "mapper-types.h"
+#define INITIAL_DOWNLOAD_RETRIES (3)
+
CURLM *_curl_multi;
GQueue *_curl_easy_queue;
GTree *_pui_tree;
#include "route.h"
#include "settings.h"
#include "mapper-types.h"
+#include "map-download.h"
#include "ui-common.h"
#include "help.h"
/* Populate combo box and pages in notebook. */
for (i = 0, curr = _repo_list; curr; curr = curr->next, i++) {
RepoData *rd = (RepoData *) curr->data;
- RepoEditInfo *rei =
- repoman_dialog_add_repo(&rmi, g_strdup(rd->name));
+ RepoEditInfo *rei = repoman_dialog_add_repo(&rmi, g_strdup(rd->name));
/* Initialize fields with data from the RepoData object. */
gtk_entry_set_text(GTK_ENTRY(rei->txt_url), rd->url);
- gtk_entry_set_text(GTK_ENTRY(rei->txt_cache_dir),
- rd->cache_dir);
+ gtk_entry_set_text(GTK_ENTRY(rei->txt_cache_dir), rd->cache_dir);
hildon_controlbar_set_value(HILDON_CONTROLBAR
(rei->num_dl_zoom_steps),
rd->dl_zoom_steps);
}
/* Connect signals. */
- g_signal_connect(G_OBJECT(btn_rename), "clicked",
- G_CALLBACK(repoman_dialog_rename), &rmi);
- g_signal_connect(G_OBJECT(btn_delete), "clicked",
- G_CALLBACK(repoman_dialog_delete), &rmi);
- g_signal_connect(G_OBJECT(btn_new), "clicked",
- G_CALLBACK(repoman_dialog_new), &rmi);
- g_signal_connect(G_OBJECT(rmi.cmb_repos), "changed",
- G_CALLBACK(repoman_dialog_select), &rmi);
+ g_signal_connect(G_OBJECT(btn_rename), "clicked", G_CALLBACK(repoman_dialog_rename), &rmi);
+ g_signal_connect(G_OBJECT(btn_delete), "clicked", G_CALLBACK(repoman_dialog_delete), &rmi);
+ g_signal_connect(G_OBJECT(btn_new), "clicked", G_CALLBACK(repoman_dialog_new), &rmi);
+ g_signal_connect(G_OBJECT(rmi.cmb_repos), "changed", G_CALLBACK(repoman_dialog_select), &rmi);
gtk_combo_box_set_active(GTK_COMBO_BOX(rmi.cmb_repos), curr_repo_index);
- gtk_notebook_set_current_page(GTK_NOTEBOOK(rmi.notebook),
- curr_repo_index);
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(rmi.notebook), curr_repo_index);
gtk_widget_show_all(rmi.dialog);
_pos.unity = y2unit((gint) (y + 0.5));
unit2latlon(_pos.unitx, _pos.unity, _gps.lat, _gps.lon);
_gps.speed = 20.f;
-integerize_data(&_gps, &_pos);
+gps_integerize_data(&_gps, &_pos);
track_add(time(NULL), FALSE);
map_refresh_mark();
}
#include "utils.h"
#include "mapper-types.h"
+/** MAX_ZOOM defines the largest map zoom level we will download.
+ * (MAX_ZOOM - 1) is the largest map zoom level that the user can zoom to.
+ */
+#define MAX_ZOOM 16
+
+#define TILE_SIZE_PIXELS (256)
+#define TILE_SIZE_P2 (8)
+
+#ifdef WITH_DEVICE_770
+#define BUF_WIDTH_TILES (4)
+#define BUF_HEIGHT_TILES (3)
+#define BUF_WIDTH_PIXELS (1024)
+#define BUF_HEIGHT_PIXELS (768)
+#else
+#define BUF_WIDTH_TILES (8)
+#define BUF_HEIGHT_TILES (8)
+#define BUF_WIDTH_PIXELS (2048)
+#define BUF_HEIGHT_PIXELS (2048)
+#endif
+
+#define WORLD_SIZE_UNITS (2 << (MAX_ZOOM + TILE_SIZE_P2))
+
+#define tile2grid(tile) ((tile) << 3)
+#define grid2tile(grid) ((grid) >> 3)
+#define tile2pixel(tile) ((tile) << 8)
+#define pixel2tile(pixel) ((pixel) >> 8)
+#define tile2unit(tile) ((tile) << (8 + _zoom))
+#define unit2tile(unit) ((unit) >> (8 + _zoom))
+#define tile2zunit(tile, zoom) ((tile) << (8 + zoom))
+#define unit2ztile(unit, zoom) ((unit) >> (8 + zoom))
+
+#define grid2pixel(grid) ((grid) << 5)
+#define pixel2grid(pixel) ((pixel) >> 5)
+#define grid2unit(grid) ((grid) << (5 + _zoom))
+#define unit2grid(unit) ((unit) >> (5 + _zoom))
+
+#define pixel2unit(pixel) ((pixel) << _zoom)
+#define unit2pixel(pixel) ((pixel) >> _zoom)
+#define pixel2zunit(pixel, zoom) ((pixel) << (zoom))
+
+#define unit2bufx(unit) (unit2pixel(unit) - tile2pixel(_base_tilex))
+#define bufx2unit(x) (pixel2unit(x) + tile2unit(_base_tilex))
+#define unit2bufy(unit) (unit2pixel(unit) - tile2pixel(_base_tiley))
+#define bufy2unit(y) (pixel2unit(y) + tile2unit(_base_tiley))
+
+#define unit2x(unit) (unit2pixel(unit) - tile2pixel(_base_tilex) - _offsetx)
+#define x2unit(x) (pixel2unit(x + _offsetx) + tile2unit(_base_tilex))
+#define unit2y(unit) (unit2pixel(unit) - tile2pixel(_base_tiley) - _offsety)
+#define y2unit(y) (pixel2unit(y + _offsety) + tile2unit(_base_tiley))
+
+#define leadx2unit() (_pos.unitx + (_lead_ratio) * pixel2unit(_gps.vel_offsetx))
+#define leady2unit() (_pos.unity + (0.6f*_lead_ratio)*pixel2unit(_gps.vel_offsety))
+
+/* Pans are done two "grids" at a time, or 64 pixels. */
+#define PAN_UNITS (grid2unit(2))
+
#define MACRO_RECALC_CENTER(center_unitx, center_unity) { \
switch(_center_mode) \
{ \
CAT_LABEL,
CAT_DESC,
CAT_POI_CNT,
+ CAT_ICON,
CAT_NUM_COLUMNS
} CategoryList;
#endif
}
-gint
-download_comparefunc(const ProgressUpdateInfo * a, const ProgressUpdateInfo * b, gpointer user_data)
-{
-gint diff = (a->priority - b->priority);
-if (diff)
- return diff;
-diff = (a->tilex - b->tilex);
-if (diff)
- return diff;
-diff = (a->tiley - b->tiley);
-if (diff)
- return diff;
-diff = (a->zoom - b->zoom);
-if (diff)
- return diff;
-diff = (a->repo - b->repo);
-if (diff)
- return diff;
-/* Otherwise, deletes are "greatest" (least priority). */
-if (!a->retries)
- return (b->retries ? -1 : 0);
-else if (!b->retries)
- return (a->retries ? 1 : 0);
-/* Do updates after non-updates (because they'll both be done anyway). */
-return (a->retries - b->retries);
-}
#define SQR(s) ((s)*(s))
-/** MAX_ZOOM defines the largest map zoom level we will download.
- * (MAX_ZOOM - 1) is the largest map zoom level that the user can zoom to.
- */
-#define MAX_ZOOM 16
-
-#define TILE_SIZE_PIXELS (256)
-#define TILE_SIZE_P2 (8)
-
-#ifdef WITH_DEVICE_770
-#define BUF_WIDTH_TILES (4)
-#define BUF_HEIGHT_TILES (3)
-#define BUF_WIDTH_PIXELS (1024)
-#define BUF_HEIGHT_PIXELS (768)
-#else
-#define BUF_WIDTH_TILES (8)
-#define BUF_HEIGHT_TILES (8)
-#define BUF_WIDTH_PIXELS (2048)
-#define BUF_HEIGHT_PIXELS (2048)
-#endif
-
#define ARRAY_CHUNK_SIZE (1024)
#define BUFFER_SIZE (2048)
-#define WORLD_SIZE_UNITS (2 << (MAX_ZOOM + TILE_SIZE_P2))
-
-#define tile2grid(tile) ((tile) << 3)
-#define grid2tile(grid) ((grid) >> 3)
-#define tile2pixel(tile) ((tile) << 8)
-#define pixel2tile(pixel) ((pixel) >> 8)
-#define tile2unit(tile) ((tile) << (8 + _zoom))
-#define unit2tile(unit) ((unit) >> (8 + _zoom))
-#define tile2zunit(tile, zoom) ((tile) << (8 + zoom))
-#define unit2ztile(unit, zoom) ((unit) >> (8 + zoom))
-
-#define grid2pixel(grid) ((grid) << 5)
-#define pixel2grid(pixel) ((pixel) >> 5)
-#define grid2unit(grid) ((grid) << (5 + _zoom))
-#define unit2grid(unit) ((unit) >> (5 + _zoom))
-
-#define pixel2unit(pixel) ((pixel) << _zoom)
-#define unit2pixel(pixel) ((pixel) >> _zoom)
-#define pixel2zunit(pixel, zoom) ((pixel) << (zoom))
-
-#define unit2bufx(unit) (unit2pixel(unit) - tile2pixel(_base_tilex))
-#define bufx2unit(x) (pixel2unit(x) + tile2unit(_base_tilex))
-#define unit2bufy(unit) (unit2pixel(unit) - tile2pixel(_base_tiley))
-#define bufy2unit(y) (pixel2unit(y) + tile2unit(_base_tiley))
-
-#define unit2x(unit) (unit2pixel(unit) - tile2pixel(_base_tilex) - _offsetx)
-#define x2unit(x) (pixel2unit(x + _offsetx) + tile2unit(_base_tilex))
-#define unit2y(unit) (unit2pixel(unit) - tile2pixel(_base_tiley) - _offsety)
-#define y2unit(y) (pixel2unit(y + _offsety) + tile2unit(_base_tiley))
-
-#define leadx2unit() (_pos.unitx + (_lead_ratio) * pixel2unit(_gps.vel_offsetx))
-#define leady2unit() (_pos.unity + (0.6f*_lead_ratio)*pixel2unit(_gps.vel_offsety))
-
-/* Pans are done two "grids" at a time, or 64 pixels. */
-#define PAN_UNITS (grid2unit(2))
-
-#define INITIAL_DOWNLOAD_RETRIES (3)
#define MACRO_PARSE_INT(tofill, str) { \
gchar *error_check; \
#endif
void sound_noise(void);
-gint download_comparefunc(const ProgressUpdateInfo * a, const ProgressUpdateInfo * b, gpointer user_data);
#endif