gps-conn.c \
cb.c \
iap.c \
+ path.c \
route.c \
track.c \
maemo-osso.c \
latlon2unit(_home.lat, _home.lon, unitx, unity);
map_center_unit(unitx, unity);
map_set_autozoom(FALSE);
+ map_update_location_from_center();
vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
return TRUE;
(_menu_ac_none_item), TRUE);
map_center_unit(_pos.unitx, _pos.unity);
+ map_update_location_from_center();
vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
return TRUE;
gboolean menu_cb_goto_nearpoi(GtkAction * action)
{
gdouble lat, lon;
-PoiInfo *p;
+poi_info *p;
printf("%s()\n", __PRETTY_FUNCTION__);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_ac_none_item), TRUE);
map_center_unit(unitx, unity);
+ map_update_location_from_center();
} else {
MACRO_BANNER_SHOW_INFO(_window, _("No POIs found."));
}
gboolean cmenu_cb_poi_route_to(GtkAction * action)
{
- PoiInfo poi;
+ poi_info poi;
printf("%s()\n", __PRETTY_FUNCTION__);
if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
gboolean cmenu_cb_poi_distance_to(GtkAction * action)
{
- PoiInfo poi;
+ poi_info poi;
printf("%s()\n", __PRETTY_FUNCTION__);
if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
gboolean cmenu_cb_poi_add_route(GtkAction * action)
{
- PoiInfo poi;
+ poi_info poi;
printf("%s()\n", __PRETTY_FUNCTION__);
if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
gboolean cmenu_cb_poi_add_way(GtkAction * action)
{
- PoiInfo poi;
+ poi_info poi;
printf("%s()\n", __PRETTY_FUNCTION__);
if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
#include "utils.h"
#include "gps.h"
#include "mapper-types.h"
+#include "gpx.h"
#define XML_DATE_FORMAT "%FT%T"
gchar XML_TZONE[7];
-void gpx_init(void)
+void
+gpx_init(void)
{
time_t time1;
struct tm time2;
(time2.tm_gmtoff / 60 / 60), (time2.tm_gmtoff / 60) % 60);
}
-gboolean write_gpx(Path * path, GnomeVFSHandle * handle)
+gboolean
+write_gpx(Path * path, GnomeVFSHandle * handle)
{
Point *curr = NULL;
WayPoint *wcurr = NULL;
data->unknown_depth = 1; \
}
-void
+static void
gpx_start_element(SaxData * data, const xmlChar * name, const xmlChar ** attrs)
{
vprintf("%s(%s)\n", __PRETTY_FUNCTION__, name);
/**
* Handle an end tag in the parsing of a GPX file.
*/
-void gpx_end_element(SaxData * data, const xmlChar * name)
+static void
+gpx_end_element(SaxData * data, const xmlChar * name)
{
vprintf("%s(%s)\n", __PRETTY_FUNCTION__, name);
/**
* Handle char data in the parsing of a GPX file.
*/
-void gpx_chars(SaxData * data, const xmlChar * ch, int len)
+static void
+gpx_chars(SaxData * data, const xmlChar * ch, int len)
{
guint i;
vprintf("%s()\n", __PRETTY_FUNCTION__);
* Handle an entity in the parsing of a GPX file. We don't do anything
* special here.
*/
-xmlEntityPtr gpx_get_entity(SaxData * data, const xmlChar * name)
+xmlEntityPtr
+gpx_get_entity(SaxData * data, const xmlChar * name)
{
vprintf("%s()\n", __PRETTY_FUNCTION__);
vprintf("%s(): return\n", __PRETTY_FUNCTION__);
/**
* Handle an error in the parsing of a GPX file.
*/
-void gpx_error(SaxData * data, const gchar * msg, ...)
+void
+gpx_error(SaxData * data, const gchar * msg, ...)
{
vprintf("%s()\n", __PRETTY_FUNCTION__);
vprintf("%s(): return\n", __PRETTY_FUNCTION__);
void hildon_banner_set_fraction(GtkWidget * widget, gdouble fraction)
{
gtk_progress_bar_set_fraction(_progress_item, fraction);
-if (fraction==1.0)
+if (fraction==1.0) {
gtk_widget_hide(_progress_item);
-else
+ gtk_progress_bar_set_text(_progress_item, "");
+} else
gtk_widget_show(_progress_item);
}
return lrint(lon/180*LATLON_MAX);
}
+gdouble
+mp_int2lon(gint lon)
+{
+return (gdouble)lon/LATLON_MAX*180;
+}
+
+gdouble
+mp_int2lat(gint lat)
+{
+
+}
+
gint
calculate_idistance(gint lat1, gint lon1, gint lat2, gint lon2)
{
}
/**
- * Calculate the distance between two lat/lon pairs. The distance is returned
- * in kilometer.
+ * Quick distance for comparing, skips the final square root
+ */
+gint
+calculate_idistance_cmp(gint lat1, gint lon1, gint lat2, gint lon2)
+{
+return ((lat1-lat2)*(lat1-lat2)+(lon1-lon2)*(lon1-lon2));
+}
+
+/**
+ * Calculate the distance between two lat/lon pairs.
+ * The distance is returned in kilometers.
+ *
*/
gdouble
calculate_distance(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2)
gdouble dlat, dlon, slat, slon, a;
/* Convert to radians. */
-lat1 *= (M_PI_4l / 180.f);
-lon1 *= (M_PI_4l / 180.f);
-lat2 *= (M_PI_4l / 180.f);
-lon2 *= (M_PI_4l / 180.f);
+lat1*=(M_PI_4l / 180.f);
+lon1*=(M_PI_4l / 180.f);
+lat2*=(M_PI_4l / 180.f);
+lon2*=(M_PI_4l / 180.f);
+
+dlat=lat2 - lat1;
+dlon=lon2 - lon1;
-dlat = lat2 - lat1;
-dlon = lon2 - lon1;
+slat=sinf(dlat / 2.f);
+slon=sinf(dlon / 2.f);
-slat = sinf(dlat / 2.f);
-slon = sinf(dlon / 2.f);
-a = (slat * slat) + (cosf(lat1) * cosf(lat2) * slon * slon);
+a=(slat * slat) + (cosf(lat1) * cosf(lat2) * slon * slon);
return ((2.f * atan2f(sqrtf(a), sqrtf(1.f - a))) * EARTH_RADIUS);
}
gint32 lon2mp_int(gdouble lon);
gint32 lat2mp_int(gdouble lat);
-gfloat calculate_distance(gfloat lat1, gfloat lon1, gfloat lat2, gfloat lon2);
+gdouble calculate_distance(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2);
gint calculate_idistance(gint lat1, gint lon1, gint lat2, gint lon2);
#endif
#include "mapper-types.h"
#include "ui-common.h"
#include "settings.h"
+#include "latlon.h"
Point _min_center = { -1, -1 };
Point _max_center = { -1, -1 };
guint _num_downloads=0;
guint _curr_download=0;
-static osm_location map_loc = {NULL, NULL, NULL};
+static osm_location map_loc = {NULL, NULL, NULL, FALSE, 0, 0};
static GHashTable *map_tile_hash = NULL;
typedef struct _map_tile_rdata map_tile_rdata;
map_update_location(gint x, gint y)
{
gint ilat, ilon;
-gdouble lat,lon, dist;
-gboolean fs, check_place=FALSE;
+gdouble lat,lon;
static gboolean inp=FALSE;
/* We run the gtk mainloop in progress callback so we can be called again, we don't like that */
ilat=lat2mp_int(lat);
ilon=lon2mp_int(lon);
-osm_progress_set_widget(_db, _progress_item);
-
-/* Check if we are still near the same way as last time */
-if (map_loc.street && osm_way_distance(ilat, ilon, map_loc.street->node_f, map_loc.street->node_t, &dist)==TRUE) {
- if (dist>15000.0) {
- osm_way_free(map_loc.street);
- map_loc.street=osm_find_nearest_way(ilat, ilon);
- check_place=FALSE;
- } else {
- check_place=FALSE;
- }
-} else {
- osm_way_free(map_loc.street);
- map_loc.street=osm_find_nearest_way(ilat, ilon);
- check_place=TRUE;
-}
+if (_gps.fix>1)
+ osm_set_way_range_from_speed(_gps.speed);
+else
+ osm_set_way_range(OSM_RANGE_WAY);
-_map_location_known=map_loc.street ? TRUE : FALSE;
+osm_progress_set_widget(_db, _progress_item);
+_map_location_known=osm_get_location_data(ilat, ilon, &map_loc);
_map_location_dist=map_loc.street ? map_loc.street->dist : 900000.0;
-
-if (check_place==TRUE) {
-
-fs=osm_find_nearest_place(NODE_PLACE_SUBURB, ilat, ilon, &map_loc.secondary);
-if (fs==TRUE && map_loc.secondary && map_loc.secondary->isin!=0) {
- if (osm_place_get(map_loc.secondary->isin, ilat, ilon, &map_loc.primary)==FALSE) {
- if (osm_find_nearest_place(NODE_PLACE_CITY, ilat, ilon, &map_loc.primary)==TRUE)
- g_printf("Near city: %s\n", map_loc.primary->name);
- else if (osm_find_nearest_place(NODE_PLACE_TOWN, ilat, ilon, &map_loc.primary)==TRUE)
- g_printf("Near town: %s\n", map_loc.primary->name);
- else
- g_printf("Unknown\n");
- } else {
- g_printf("In: %s\n", map_loc.primary ? map_loc.primary->name : "?");
- }
-} else if (map_loc.street && map_loc.street->isin!=0) {
- if (osm_place_get(map_loc.street->isin, ilat, ilon, &map_loc.primary)==FALSE) {
- g_printf("Street location not know.\n");
- } else {
- g_printf("Street is in: %s\n", map_loc.primary ? map_loc.primary->name : "?");
- }
-} else {
- if (osm_find_nearest_place(NODE_PLACE_CITY, ilat, ilon, &map_loc.primary)==TRUE)
- g_printf("Near city: %s\n", map_loc.primary->name);
- else if (osm_find_nearest_place(NODE_PLACE_TOWN, ilat, ilon, &map_loc.primary)==TRUE)
- g_printf("Near town: %s\n", map_loc.primary->name);
- else
- g_printf("Unknown\n");
-
-}
-}
-
map_set_place_information(map_loc.street, map_loc.primary, map_loc.secondary);
osm_progress_set_widget(_db, NULL);
inp=FALSE;
#include "hildon-mapper.h"
#include "utils.h"
-#include "poi.h"
-#include "route.h"
#include "mapper-types.h"
#include "settings.h"
#include "gps.h"
#include "map.h"
+#include "route.h"
+#include "track.h"
#include "bt.h"
#include "ui-common.h"
#include "db.h"
+#include "osm-db.h"
#include "cb.h"
#include "speak.h"
#include "osm-db.h"
/* #define DEBUG_OSM */
-#define OSM_PLACE_CACHE_MAX_ITEMS (40)
-#define OSM_DB_PROGRESS_NUM (3000)
-#define OSM_START_RANGE (8192)
+#define OSM_PLACE_CACHE_MAX_ITEMS (64)
+#define OSM_DB_PROGRESS_NUM (5000)
+#define OSM_RANGE_START (8192)
+#define OSM_RANGE_STEP (8192)
+#define OSM_RANGE_STOP (49152)
struct sql_select_stmt {
sqlite3_stmt *select_way;
/* Cache hash tables */
static GHashTable *_place_cache;
+static gint way_dist_range=OSM_RANGE_WAY;
+
osm_way_node *osm_way_get_prev_node(osm_way *w);
osm_way_node *osm_way_get_next_node(osm_way *w);
/*****************************************************************************/
+void
+osm_set_way_range(gint sr)
+{
+way_dist_range=sr;
+}
+
+void
+osm_set_way_range_from_speed(gfloat speed)
+{
+if (speed>54)
+ way_dist_range=9000;
+else
+ way_dist_range=OSM_RANGE_WAY-lrint((speed/3)*1000);
+}
+
static int
osm_progress(void *ud)
{
* Get place with given id and distance to current location
*/
gboolean
-osm_place_get(guint32 id, gint lat, gint lon, osm_place *n)
+osm_place_get(guint32 id, gint lat, gint lon, osm_place **nr)
{
+osm_place *n;
+
+n=*nr;
n=osm_place_cache_lookup(id);
if (n) {
osm_place_update_distance(n, lat, lon);
{
GList *iter;
GList *w=NULL;
-guint range=OSM_START_RANGE;
+guint range=OSM_RANGE_START;
osm_way *cw=NULL;
gdouble pdist=START_DIST, dist_n, dist_p;
-while ((w=osm_find_nearest_way_nodes(lat, lon, range))==NULL && range<=65536) {
- range=range<<1;
+while ((w=osm_find_nearest_way_nodes(lat, lon, range))==NULL && range<=OSM_RANGE_STOP) {
+ range+=OSM_RANGE_STEP;
g_printf("Trying with range: %d\n", range);
}
return FALSE;
}
+/******************************************************************************/
+
+gboolean
+osm_get_location_data(gint lat, gint lon, osm_location *map_loc)
+{
+gdouble dist;
+gboolean fs, check_place=FALSE;
+static gboolean inp=FALSE;
+
+/* Check if we are still near the same way as last time */
+if (map_loc->street && osm_way_distance(lat, lon, map_loc->street->node_f, map_loc->street->node_t, &dist)==TRUE) {
+ if (dist>way_dist_range) {
+ osm_way_free(map_loc->street);
+ map_loc->street=osm_find_nearest_way(lat, lon);
+ check_place=FALSE;
+ } else {
+ check_place=FALSE;
+ }
+} else {
+ osm_way_free(map_loc->street);
+ map_loc->street=osm_find_nearest_way(lat, lon);
+ check_place=TRUE;
+}
+
+if (check_place==TRUE) {
+fs=osm_find_nearest_place(NODE_PLACE_SUBURB, lat, lon, &map_loc->secondary);
+if (fs==TRUE && map_loc->secondary && map_loc->secondary->isin!=0) {
+ if (osm_place_get(map_loc->secondary->isin, lat, lon, &(map_loc->primary))==FALSE) {
+ if (osm_find_nearest_place(NODE_PLACE_CITY, lat, lon, &map_loc->primary)==TRUE)
+ g_printf("Near city: %s\n", map_loc->primary->name);
+ else if (osm_find_nearest_place(NODE_PLACE_TOWN, lat, lon, &map_loc->primary)==TRUE)
+ g_printf("Near town: %s\n", map_loc->primary->name);
+ else
+ g_printf("Unknown\n");
+ } else {
+ g_printf("In: %s\n", map_loc->primary ? map_loc->primary->name : "?");
+ }
+} else if (map_loc->street && map_loc->street->isin!=0) {
+ if (osm_place_get(map_loc->street->isin, lat, lon, &map_loc->primary)==FALSE) {
+ g_printf("Street location not know.\n");
+ } else {
+ g_printf("Street is in: %s\n", map_loc->primary ? map_loc->primary->name : "?");
+ }
+} else {
+ if (osm_find_nearest_place(NODE_PLACE_CITY, lat, lon, &map_loc->primary)==TRUE)
+ g_printf("Near city: %s\n", map_loc->primary->name);
+ else if (osm_find_nearest_place(NODE_PLACE_TOWN, lat, lon, &map_loc->primary)==TRUE)
+ g_printf("Near town: %s\n", map_loc->primary->name);
+ else
+ g_printf("Unknown\n");
+
+}
+}
+
+return map_loc->street ? TRUE : FALSE;
+}
+
+
#include <glib.h>
#include "osm.h"
+#define OSM_RANGE_WAY (20000)
+
gboolean osm_init(void);
void osm_deinit(void);
+void osm_set_way_range_from_speed(gfloat speed);
+
void osm_progress_set_widget(sqlite3 *db, GtkProgressBar *w);
gboolean osm_way_get_nodes(osm_way *w);
osm_way *osm_find_nearest_way(gint lat, gint lon);
gboolean osm_way_distance(gint lat, gint lon, osm_way_node *f, osm_way_node *t, gdouble *d);
+gboolean osm_get_location_data(gint lat, gint lon, osm_location *map_loc);
+
#endif
osm_way *street;
osm_place *primary;
osm_place *secondary;
+ gdouble valid;
+ gint lat;
+ gint lon;
};
#endif
-void path_resize(Path * path, guint size)
+#include <config.h>
+
+#include "utils.h"
+#include "map.h"
+#include "route.h"
+#include "mapper-types.h"
+
+#include "track.h"
+
+void
+path_resize(Path * path, guint size)
{
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- if (path->head + size != path->cap) {
- Point *old_head = path->head;
- WayPoint *curr;
- path->head = g_renew(Point, old_head, size);
- path->cap = path->head + size;
- if (path->head != old_head) {
- path->tail = path->head + (path->tail - old_head);
-
- /* Adjust all of the waypoints. */
- for (curr = path->whead - 1; curr++ != path->wtail;)
- curr->point =
- path->head + (curr->point - old_head);
- }
- }
+printf("%s()\n", __PRETTY_FUNCTION__);
+
+if (path->head + size != path->cap) {
+ Point *old_head = path->head;
+ WayPoint *curr;
+ path->head = g_renew(Point, old_head, size);
+ path->cap = path->head + size;
+ if (path->head != old_head) {
+ path->tail = path->head + (path->tail - old_head);
- vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+ /* Adjust all of the waypoints. */
+ for (curr = path->whead - 1; curr++ != path->wtail;)
+ curr->point =
+ path->head + (curr->point - old_head);
+ }
+}
+vprintf("%s(): return\n", __PRETTY_FUNCTION__);
}
-void path_wresize(Path * path, guint wsize)
+void
+path_wresize(Path * path, guint wsize)
{
- printf("%s()\n", __PRETTY_FUNCTION__);
+printf("%s()\n", __PRETTY_FUNCTION__);
- if (path->whead + wsize != path->wcap) {
- WayPoint *old_whead = path->whead;
- path->whead = g_renew(WayPoint, old_whead, wsize);
- path->wtail = path->whead + (path->wtail - old_whead);
- path->wcap = path->whead + wsize;
- }
+if (path->whead + wsize != path->wcap) {
+ WayPoint *old_whead = path->whead;
+ path->whead = g_renew(WayPoint, old_whead, wsize);
+ path->wtail = path->whead + (path->wtail - old_whead);
+ path->wcap = path->whead + wsize;
+}
- vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+vprintf("%s(): return\n", __PRETTY_FUNCTION__);
}
--- /dev/null
+#ifndef _PATH_H
+#define _PATH_H
+
+void path_resize(Path * path, guint size);
+void path_wresize(Path * path, guint wsize);
+
+#endif
guint _poi_zoom = 6;
-gboolean select_poi(guint unitx, guint unity, PoiInfo *poi);
+gboolean select_poi(guint unitx, guint unity, poi_info *poi);
-gboolean category_delete(GtkWidget * widget, DeletePOI *dpoi)
+gboolean category_delete(GtkWidget * widget, delete_poi *dpoi)
{
GtkWidget *dialog;
guint i;
GtkTextBuffer *desc_txt;
GtkTextIter begin, end;
gboolean results = TRUE;
- DeletePOI dpoi = { NULL, NULL, 0 };
+ delete_poi dpoi = { NULL, NULL, 0 };
poi_category *c;
printf("%s()\n", __PRETTY_FUNCTION__);
}
gboolean
-poi_delete_confirm(GtkWidget * widget, DeletePOI * dpoi)
+poi_delete_confirm(GtkWidget * widget, delete_poi * dpoi)
{
GtkWidget *dialog;
guint i;
}
gboolean
-select_poi(guint unitx, guint unity, PoiInfo *poi)
+select_poi(guint unitx, guint unity, poi_info *poi)
{
GtkWidget *dialog;
GtkWidget *list;
gboolean poi_dialog(POIAction action, guint unitx, guint unity)
{
- PoiInfo poi;
+ poi_info poi;
gchar slat1[10], slon1[10];
gchar *p_latlon;
GtkWidget *dialog;
GtkWidget *txt_scroll;
GtkTextBuffer *desc_txt;
GtkTextIter begin, end;
- DeletePOI dpoi = { NULL, NULL, 0 };
+ delete_poi dpoi = { NULL, NULL, 0 };
PoiCategoryEditInfo pcedit;
printf("%s()\n", __PRETTY_FUNCTION__);
struct _poi_categories {
node_type_t type;
- gchar *name, *desc;
+ const gchar *name, *desc;
};
static struct _poi_categories default_poi_categories[] = {
return FALSE;
}
-PoiInfo *
+poi_info *
poi_new(void)
{
-return g_slice_new0(PoiInfo);
+return g_slice_new0(poi_info);
}
void
-poi_free(PoiInfo *p)
+poi_free(poi_info *p)
{
-g_slice_free(PoiInfo, p);
+g_slice_free(poi_info, p);
}
poi_category *
}
gboolean
-poi_category_delete(DeletePOI *dpoi)
+poi_category_delete(delete_poi *dpoi)
{
if (!_db)
return FALSE;
gboolean
-poi_delete(DeletePOI *dpoi)
+poi_delete(delete_poi *dpoi)
{
if (!_db)
return FALSE;
return TRUE;
}
-PoiInfo *
+poi_info *
poi_find_nearest(gdouble lat, gdouble lon)
{
-PoiInfo *p;
+poi_info *p;
if (!_db)
return FALSE;
POI_TYPE_LANDMARK=1,
} poi_types_e;
-typedef struct _PoiDb PoiDb;
-struct _PoiDb {
+typedef struct _poi_db poi_db;
+struct _poi_db {
sqlite3 *db;
gchar *file;
guint zoom;
};
-typedef struct _PoiData PoiData;
-struct _PoiData {
+typedef struct _poi_data poi_data;
+struct _poi_data {
gdouble lat;
gdouble lon;
gchar *name;
};
/** Data to describe a POI. */
-typedef struct _PoiInfo PoiInfo;
-struct _PoiInfo {
+typedef struct _poi_info poi_info;
+struct _poi_info {
guint poi_id;
guint cat_id;
gdouble lat;
};
/** Data used during action: add or edit category/poi **/
-typedef struct _DeletePOI DeletePOI;
-struct _DeletePOI {
+typedef struct _delete_poi delete_poi;
+struct _delete_poi {
GtkWidget *dialog;
gchar *txt_label;
guint id;
gboolean poi_db_create(sqlite3 *db);
gboolean poi_db_prepare(sqlite3 *db);
-PoiInfo *poi_new(void);
-void poi_free(PoiInfo *p);
+poi_info *poi_new(void);
+void poi_free(poi_info *p);
gboolean poi_get_list(guint unitx, guint unity, GtkListStore **store, guint *num_cats);
gboolean poi_update(gint poi_id, gint cat_id, gchar *poi_label, gchar *poi_desc);
gboolean poi_add(gdouble lat, gdouble lon, gint cat_id, gchar *poi_label, gchar *poi_desc);
-gboolean poi_delete(DeletePOI * dpoi);
+gboolean poi_delete(delete_poi * dpoi);
poi_category *poi_category_new(void);
void poi_category_free(poi_category *c);
gboolean poi_category_get(gint cat_id, poi_category **c);
-gboolean poi_category_delete(DeletePOI * dpoi);
+gboolean poi_category_delete(delete_poi * dpoi);
gboolean poi_category_update(gint cat_id, poi_category *c);
-PoiInfo *poi_find_nearest(gdouble lat, gdouble lon);
+poi_info *poi_find_nearest(gdouble lat, gdouble lon);
gboolean poi_category_toggle(gint cat_id, gboolean cat_enabled);
GtkListStore *poi_category_generate_store();
#include "file.h"
#include "track.h"
-
-void path_resize(Path * path, guint size)
-{
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- if (path->head + size != path->cap) {
- Point *old_head = path->head;
- WayPoint *curr;
- path->head = g_renew(Point, old_head, size);
- path->cap = path->head + size;
- if (path->head != old_head) {
- path->tail = path->head + (path->tail - old_head);
-
- /* Adjust all of the waypoints. */
- for (curr = path->whead - 1; curr++ != path->wtail;)
- curr->point =
- path->head + (curr->point - old_head);
- }
- }
-
- vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-}
-
-void path_wresize(Path * path, guint wsize)
-{
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- if (path->whead + wsize != path->wcap) {
- WayPoint *old_whead = path->whead;
- path->whead = g_renew(WayPoint, old_whead, wsize);
- path->wtail = path->whead + (path->wtail - old_whead);
- path->wcap = path->whead + wsize;
- }
-
- vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-}
-
-void track_clear()
+#include "path.h"
+
+struct sql_select_stmt {
+ sqlite3_stmt *select_track;
+ sqlite3_stmt *select_track_nodes;
+ sqlite3_stmt *insert_track;
+ sqlite3_stmt *insert_track_node;
+ sqlite3_stmt *delete_track_nodes;
+ sqlite3_stmt *delete_track;
+};
+static struct sql_select_stmt sql;
+
+void
+track_clear(void)
{
GtkWidget *confirm;
gtk_widget_destroy(confirm);
}
-gfloat track_calculate_distance_from(Point * point)
+gfloat
+track_calculate_distance_from(Point * point)
{
gfloat lat1, lon1, lat2, lon2;
gfloat sum = 0.0;
return sum;
}
-void track_show_distance_from(Point * point)
+void
+track_show_distance_from(Point * point)
{
gchar buffer[80];
gfloat sum;
MACRO_BANNER_SHOW_INFO(_window, buffer);
}
-void track_show_distance_from_last()
+void
+track_show_distance_from_last()
{
printf("%s()\n", __PRETTY_FUNCTION__);
printf("%s(): return\n", __PRETTY_FUNCTION__);
}
-void track_show_distance_from_first()
+void
+track_show_distance_from_first()
{
printf("%s()\n", __PRETTY_FUNCTION__);
* then _point_null is appended to _track with time zero (this produces a "break"
* in the track).
*/
-void track_add(time_t time, gboolean newly_fixed)
+void
+track_add(time_t time, gboolean newly_fixed)
{
gboolean show_directions = TRUE;
gint announce_thres_unsquared;
vprintf("%s(): return\n", __PRETTY_FUNCTION__);
}
-void track_insert_break(void)
+void
+track_insert_break(void)
{
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- if (_track.tail->unity) {
- guint x1, y1;
+printf("%s()\n", __PRETTY_FUNCTION__);
- /* To mark a "waypoint" in a track, we'll add a (0, 0) point and then
- * another instance of the most recent track point. */
- MACRO_PATH_INCREMENT_TAIL(_track);
- *_track.tail = _point_null;
- MACRO_PATH_INCREMENT_TAIL(_track);
- *_track.tail = _track.tail[-2];
-
- /** Instead of calling map_render_paths(), we'll just add the waypoint
- * ourselves. */
- x1 = unit2bufx(_track.tail->unitx);
- y1 = unit2bufy(_track.tail->unity);
- /* Make sure this circle will be visible. */
- if ((x1 < BUF_WIDTH_PIXELS) && ((unsigned)y1 < BUF_HEIGHT_PIXELS))
- gdk_draw_arc(_map_pixmap, _gc[COLORABLE_TRACK_BREAK], FALSE, /* FALSE: not filled. */
- x1 - _draw_width, y1 - _draw_width, 2 * _draw_width, 2 * _draw_width, 0, /* start at 0 degrees. */
- 360 * 64);
- } else {
- MACRO_BANNER_SHOW_INFO(_window, _("Break already inserted."));
- }
+if (_track.tail->unity) {
+ guint x1, y1;
+
+/* To mark a "waypoint" in a track, we'll add a (0, 0) point and then
+ * another instance of the most recent track point. */
+MACRO_PATH_INCREMENT_TAIL(_track);
+*_track.tail = _point_null;
+MACRO_PATH_INCREMENT_TAIL(_track);
+*_track.tail = _track.tail[-2];
+
+/** Instead of calling map_render_paths(), we'll just add the waypoint
+ * ourselves. */
+x1 = unit2bufx(_track.tail->unitx);
+y1 = unit2bufy(_track.tail->unity);
+/* Make sure this circle will be visible. */
+if ((x1 < BUF_WIDTH_PIXELS) && ((unsigned)y1 < BUF_HEIGHT_PIXELS))
+ gdk_draw_arc(_map_pixmap, _gc[COLORABLE_TRACK_BREAK], FALSE, /* FALSE: not filled. */
+ x1 - _draw_width, y1 - _draw_width, 2 * _draw_width, 2 * _draw_width, 0, /* start at 0 degrees. */
+ 360 * 64);
+} else {
+ MACRO_BANNER_SHOW_INFO(_window, _("Break already inserted."));
+}
- vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+vprintf("%s(): return\n", __PRETTY_FUNCTION__);
}
-gboolean track_open(void)
+gboolean
+track_open(void)
{
- gchar *buffer;
- gint size;
- gboolean r = FALSE;
-
- if (open_file(&buffer, NULL, &size, NULL, &_track_file_uri, GTK_FILE_CHOOSER_ACTION_OPEN)) {
- if (parse_gpx(&_track, buffer, size, -1)) {
- map_force_redraw();
- MACRO_BANNER_SHOW_INFO(_window, _("Track Opened"));
- r = TRUE;
- } else {
- popup_error(_window, _("Error parsing GPX file."));
- }
- g_free(buffer);
+gchar *buffer;
+gint size;
+gboolean r = FALSE;
+
+if (open_file(&buffer, NULL, &size, NULL, &_track_file_uri, GTK_FILE_CHOOSER_ACTION_OPEN)) {
+ if (parse_gpx(&_track, buffer, size, -1)) {
+ map_force_redraw();
+ MACRO_BANNER_SHOW_INFO(_window, _("Track Opened"));
+ r = TRUE;
+ } else {
+ popup_error(_window, _("Error parsing GPX file."));
}
- return r;
+ g_free(buffer);
+}
+return r;
}
-gboolean track_save(void)
+gboolean
+track_save(void)
{
- GnomeVFSHandle *handle;
- gboolean r = FALSE;
-
- if (file_save(&_track_file_uri, &_track_file_uri, &handle)) {
- if (write_gpx(&_track, handle)) {
- MACRO_BANNER_SHOW_INFO(_window, _("Track Saved"));
- r = TRUE;
- } else {
- popup_error(_window, _("Error writing GPX file."));
- }
- gnome_vfs_close(handle);
+GnomeVFSHandle *handle;
+gboolean r = FALSE;
+
+if (file_save(&_track_file_uri, &_track_file_uri, &handle)) {
+ if (write_gpx(&_track, handle)) {
+ MACRO_BANNER_SHOW_INFO(_window, _("Track Saved"));
+ r = TRUE;
+ } else {
+ popup_error(_window, _("Error writing GPX file."));
}
- return r;
+ gnome_vfs_close(handle);
+}
+return r;
}
/**
* Add a text description at current point
*
*/
-void track_insert_mark_text(gchar *text)
+void
+track_insert_mark_text(gchar *text)
{
MACRO_PATH_INCREMENT_WTAIL(_track);
_track.wtail->point = _track.tail;
* Ask for a text description for the current point
*
*/
-
-gboolean track_insert_mark(void)
+gboolean
+track_insert_mark(void)
{
gfloat lat, lon;
gchar tmp1[16], tmp2[16], *p_latlon;
#include <glib.h>
#include <sqlite3.h>
-void track_add(time_t time, gboolean newly_fixed);
-void track_insert_break(void);
-gboolean track_insert_mark(void);
-gboolean track_save(void);
-gboolean track_open(void);
-
-void track_show_distance_from_first();
-void track_show_distance_from_last();
-void track_show_distance_from(Point * point);
-void path_wresize(Path * path, guint wsize);
-void path_resize(Path * path, guint size);
-
#define TRACK_SQL_SELECT_TRACKS "select id,name,sloc,eloc,sdate,edate from tracks order by sdate"
#define TRACK_SQL_INSERT_TRACK "insert into tracks (id,name,sloc,sdate) values (?,?,?,?);
#define TRACK_SQL_INSERT_TRACK_POINT "insert into trackpoints (tid,dt,lat,lon,alt,hdop,vdop,pdop,sat,fix) values (?,?,?,?,?,?,?,?,?,?)"
sqlite3_stmt *_select_track_points;
} track_sql;
+void track_add(time_t time, gboolean newly_fixed);
+void track_insert_break(void);
+gboolean track_insert_mark(void);
+gboolean track_save(void);
+gboolean track_open(void);
+void track_clear(void);
+
+void track_show_distance_from_first();
+void track_show_distance_from_last();
+void track_show_distance_from(Point * point);
+
#endif
} \
}
-gint download_comparefunc(const ProgressUpdateInfo * a,
- const ProgressUpdateInfo * b, gpointer user_data);
-gdouble calculate_distance(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2);
+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();