From: Kaj-Michael Lang Date: Tue, 2 Oct 2007 13:28:22 +0000 (+0300) Subject: Misc X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=929bfb8d3cd368acfa2426928bbf71dc9dddaaa5;p=mapper Misc --- diff --git a/src/gps-nmea-parse.c b/src/gps-nmea-parse.c index 337563d..2f6ded3 100644 --- a/src/gps-nmea-parse.c +++ b/src/gps-nmea-parse.c @@ -167,7 +167,7 @@ channel_parse_rmc(gchar * sentence) if ((_conn_state == RCVR_FIXED) && (_track_store==TRUE)) { if ((_gps_filter==TRUE) && (track_drop_cnt_filter_angle || _filter_angle==0.0 ) && @@ -187,7 +187,7 @@ channel_parse_rmc(gchar * sentence) map_refresh_mark(); } else { track_drop_cnt=0; - integerize_data(_vel_offsetx, _vel_offsety, _pos, _gps); + integerize_data(&_gps, &_pos); track_add(_pos.time, newly_fixed); _gps.lheading=_gps.heading; map_refresh_mark(); diff --git a/src/gps.c b/src/gps.c index a2bd94b..22d254b 100644 --- a/src/gps.c +++ b/src/gps.c @@ -6,15 +6,15 @@ gps_init(void) { _gps.lat = 0; _gps.lon = 0; -_pos.unitx = 0; -_pos.unity = 0; _gps.heading = 0; _gps.lheading = 0; _gps.fix = 1; _gps.satinuse = 0; _gps.satinview = 0; _gps.speed = 0.f; +_pos.unitx = 0; +_pos.unity = 0; -integerize_data(_vel_offsetx, _vel_offsety, _pos, _gps); +integerize_data(&_gps, &_pos); } diff --git a/src/gps.h b/src/gps.h index 97ecb44..607f740 100644 --- a/src/gps.h +++ b/src/gps.h @@ -50,12 +50,9 @@ guint _curl_sid; gint _gmtoffset; /** GPS data. */ -Point _pos; -gint _vel_offsetx; -gint _vel_offsety; - GpsData _gps; GpsSatelliteData _gps_sat[12]; +Point _pos; void gps_init(void); diff --git a/src/gpsdata.h b/src/gpsdata.h index 6ec9c26..12e206e 100644 --- a/src/gpsdata.h +++ b/src/gpsdata.h @@ -29,6 +29,8 @@ struct _GpsData { gfloat hdop; gfloat vdop; gfloat pdop; + gint vel_offsetx; + gint vel_offsety; guint satinview; guint satinuse; guint satforfix[GPS_SAT_MAX]; diff --git a/src/map.c b/src/map.c index 34e7d0f..3bb8c86 100644 --- a/src/map.c +++ b/src/map.c @@ -137,8 +137,8 @@ map_set_mark(void) { _mark_x1 = unit2x(_pos.unitx); _mark_y1 = unit2y(_pos.unity); -_mark_x2 = _mark_x1 + (_show_velvec ? _vel_offsetx : 0); -_mark_y2 = _mark_y1 + (_show_velvec ? _vel_offsety : 0); +_mark_x2 = _mark_x1 + (_show_velvec ? _gps.vel_offsetx : 0); +_mark_y2 = _mark_y1 + (_show_velvec ? _gps.vel_offsety : 0); _mark_minx = MIN(_mark_x1, _mark_x2) - (2 * _draw_width); _mark_miny = MIN(_mark_y1, _mark_y2) - (2 * _draw_width); _mark_width = abs(_mark_x1 - _mark_x2) + (4 * _draw_width); @@ -969,7 +969,7 @@ _pos.unitx = x2unit((gint) (x + 0.5)); _pos.unity = y2unit((gint) (y + 0.5)); unit2latlon(_pos.unitx, _pos.unity, _gps.lat, _gps.lon); _gps.speed = 20.f; -integerize_data(); +integerize_data(&_gps, &_pos); track_add(time(NULL), FALSE); map_refresh_mark(); } diff --git a/src/utils.c b/src/utils.c index 0c3f263..b16e859 100644 --- a/src/utils.c +++ b/src/utils.c @@ -21,10 +21,12 @@ #include "utils.h" #include "gps.h" +#include "gpsdata.h" #include "mapper-types.h" #include "bt.h" -void sound_noise(void) +void +sound_noise(void) { #ifdef WITH_HILDON hildon_play_system_sound("/usr/share/sounds/ui-information_note.wav"); @@ -34,14 +36,12 @@ gdk_beep(); } void -deg_format(DegFormat degformat, gdouble coor, gchar * scoor, gchar neg_char, - gchar pos_char) +deg_format(DegFormat degformat, gdouble coor, gchar * scoor, gchar neg_char, gchar pos_char) { - gdouble min; - gdouble acoor = fabs(coor); - printf("%s()\n", __PRETTY_FUNCTION__); +gdouble min; +gdouble acoor=fabs(coor); - switch (degformat) { +switch (degformat) { case DDPDDDDD: sprintf(scoor, "%.5f°", coor); break; @@ -72,51 +72,47 @@ deg_format(DegFormat degformat, gdouble coor, gchar * scoor, gchar neg_char, coor < 0.f ? neg_char : pos_char); break; default:; - } - vprintf("%s(): return\n", __PRETTY_FUNCTION__); +} } /** * Convert the float lat/lon/speed/heading data into integer units. */ -void integerize_data() +void +integerize_data(GpsData *gps, Point *pos) { - gdouble tmp; - printf("%s()\n", __PRETTY_FUNCTION__); - - latlon2unit(_gps.lat, _gps.lon, _pos.unitx, _pos.unity); +gdouble tmp; - tmp = (_gps.heading * (1.f / 180.f)) * PI; - _vel_offsetx = (gint) (floorf(_gps.speed * sinf(tmp) + 0.5f)); - _vel_offsety = -(gint) (floorf(_gps.speed * cosf(tmp) + 0.5f)); +latlon2unit(gps->lat, gps->lon, pos->unitx, pos->unity); - vprintf("%s(): return\n", __PRETTY_FUNCTION__); +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)); } gint -download_comparefunc(const ProgressUpdateInfo * a, - const ProgressUpdateInfo * b, gpointer user_data) +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); +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); } diff --git a/src/utils.h b/src/utils.h index c357935..d1a0939 100644 --- a/src/utils.h +++ b/src/utils.h @@ -42,6 +42,7 @@ #include #include "mapper-types.h" +#include "gpsdata.h" /**************************************************************************** * BELOW: DEFINES *********************************************************** @@ -126,8 +127,8 @@ #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(_vel_offsetx)) -#define leady2unit() (_pos.unity + (0.6f*_lead_ratio)*pixel2unit(_vel_offsety)) +#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)) @@ -339,6 +340,6 @@ if (_http_proxy_host) { \ void sound_noise(void); gint download_comparefunc(const ProgressUpdateInfo * a, const ProgressUpdateInfo * b, gpointer user_data); void deg_format(DegFormat degformat, gdouble coor, gchar *scoor, gchar neg_char, gchar pos_char); -void integerize_data(); +void integerize_data(GpsData *gps, Point *pos); #endif