]> err.no Git - mapper/commitdiff
Merge branch 'master' of git+ssh://tal.org/home/git/mapper
authorKaj-Michael Lang <milang@angel.tal.org>
Thu, 9 Aug 2007 13:10:25 +0000 (16:10 +0300)
committerKaj-Michael Lang <milang@angel.tal.org>
Thu, 9 Aug 2007 13:10:25 +0000 (16:10 +0300)
Conflicts:

src/mapper.c
src/utils.c

19 files changed:
src/Makefile.am
src/cb.c
src/gpx.c
src/hildon-wrappers.c
src/latlon.c
src/latlon.h
src/map.c
src/mapper.c
src/osm-db.c
src/osm-db.h
src/osm.h
src/path.c
src/path.h [new file with mode: 0644]
src/poi-gui.c
src/poi.c
src/poi.h
src/track.c
src/track.h
src/utils.h

index f97e8e318ff2fc07cc03cd080d47346fcfea0fa2..01f5ca51dbed9a8ab751da7accf7ba4219c6d429 100644 (file)
@@ -41,6 +41,7 @@ mapper_SOURCES = utils.c \
        gps-conn.c \
        cb.c \
        iap.c \
+       path.c \
        route.c \
        track.c \
        maemo-osso.c \
index ab40f3258843407824a2213743d05a43e3c83896..e5d12b74c9bbc0187988a94414a8609ff355d2df 100644 (file)
--- a/src/cb.c
+++ b/src/cb.c
@@ -445,6 +445,7 @@ gboolean menu_cb_goto_home(GtkAction * action)
        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;
@@ -473,6 +474,7 @@ gboolean menu_cb_goto_gps(GtkAction * action)
                                               (_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;
@@ -501,7 +503,7 @@ gboolean menu_cb_goto_nextway(GtkAction * action)
 gboolean menu_cb_goto_nearpoi(GtkAction * action)
 {
 gdouble lat, lon;
-PoiInfo *p;
+poi_info *p;
 
 printf("%s()\n", __PRETTY_FUNCTION__);
 
@@ -530,6 +532,7 @@ if (p) {
                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."));
 }
@@ -1448,7 +1451,7 @@ gboolean cmenu_cb_way_add_poi(GtkAction * action)
 
 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)) {
@@ -1463,7 +1466,7 @@ gboolean cmenu_cb_poi_route_to(GtkAction * action)
 
 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)) {
@@ -1478,7 +1481,7 @@ gboolean cmenu_cb_poi_distance_to(GtkAction * action)
 
 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)) {
@@ -1493,7 +1496,7 @@ gboolean cmenu_cb_poi_add_route(GtkAction * action)
 
 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)) {
index 117a65c522be4d8a074d61ef7df72284c3c9e046..3971be7f865f42bc2f8f8af8dc32713c67f9a7ba 100644 (file)
--- a/src/gpx.c
+++ b/src/gpx.c
 #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;
@@ -68,7 +70,8 @@ snprintf(XML_TZONE, sizeof(XML_TZONE), "%+03ld:%02ld",
         (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;
@@ -174,7 +177,7 @@ gboolean write_gpx(Path * path, GnomeVFSHandle * handle)
     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);
@@ -257,7 +260,8 @@ gpx_start_element(SaxData * data, const xmlChar * name, const xmlChar ** attrs)
 /**
  * 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);
 
@@ -405,7 +409,8 @@ void gpx_end_element(SaxData * data, const xmlChar * 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__);
@@ -432,7 +437,8 @@ void gpx_chars(SaxData * data, const xmlChar * ch, int len)
  * 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__);
@@ -442,7 +448,8 @@ xmlEntityPtr gpx_get_entity(SaxData * data, const xmlChar * name)
 /**
  * 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__);
index a73d9b1ce79f195a60730fba6b566ccd0489ff45..e60138efc614075b549349095f3df33ac7f6a1da 100644 (file)
@@ -75,9 +75,10 @@ return gtk_message_dialog_new(widget,
 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);
 }
 
index 5b1431136baddc89fb745c058ecf6ff4c34d1074..025246f7fac642f32a25ead73039c9b709da2fb6 100644 (file)
@@ -29,6 +29,18 @@ lon2mp_int(gdouble lon)
 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)
 {
@@ -36,8 +48,18 @@ return lrint(sqrt((double)((lat1-lat2)*(lat1-lat2)+(lon1-lon2)*(lon1-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)
@@ -45,17 +67,18 @@ 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);
 }
index ec07c1daa9029a75fae4af680d0d6d23ad7611e8..52f39ca2fd93c305743b4305865f8be5230af014 100644 (file)
@@ -10,7 +10,7 @@
 
 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
index 047bde09c81f45d7b65ed7a49437078891789859..ebef065fce8c3e502681a9d821224cb026fc3440 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -36,6 +36,7 @@
 #include "mapper-types.h"
 #include "ui-common.h"
 #include "settings.h"
+#include "latlon.h"
 
 Point _min_center = { -1, -1 };
 Point _max_center = { -1, -1 };
@@ -59,7 +60,7 @@ static gint _map_mode=0;
 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;
@@ -1402,8 +1403,7 @@ static void
 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 */
@@ -1415,57 +1415,14 @@ unit2latlon(x, y, lat, lon);
 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;
index 47fc90e0cc4e0a31a30c6f9fa05d77d4642b9e63..72f6c66871f933cc9db6c5dee82bc5f8926ad8de 100644 (file)
 #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"
 
index c09592e3323d5c80be3e4637cae6d0aac6dd00af..bfc0e2c1b7eaaae7d5136b85ba67833eae327324 100644 (file)
 #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;
@@ -39,11 +41,28 @@ static GtkProgressBar *dbpw=NULL;
 /* 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)
 {
@@ -268,8 +287,11 @@ p->dist=sqrt(lam+lom);
  * 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);
@@ -539,12 +561,12 @@ osm_find_nearest_way(gint lat, gint 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);
 }
 
@@ -751,3 +773,61 @@ if (SQLITE_ROW == sqlite3_step(sql.select_way_ref)) {
 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;
+}
+
+
index 2eea3e64a67ba6df34298ab464af24f81da2f0f5..6403e0eb33190e7b333fad94cd414efcc9141b74 100644 (file)
@@ -4,9 +4,13 @@
 #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);
@@ -17,4 +21,6 @@ gboolean osm_find_nearest_place(node_type_t type, gint lat, gint lon, osm_place
 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
index bc33227dacdc4c24dcb976fde4fceac7b6d5950e..d475d87ba07a1c38a703578ff358449eeec0e59f 100644 (file)
--- a/src/osm.h
+++ b/src/osm.h
@@ -173,6 +173,9 @@ struct _osm_location {
        osm_way *street;
        osm_place *primary;
        osm_place *secondary;
+       gdouble valid;
+       gint lat;
+       gint lon;
 };
 
 #endif
index 68d636faab474763dcd27f422f1812495f6d8210..f4ee62d52b48c0eb048682b9875ef0afec1f56e1 100644 (file)
@@ -1,35 +1,45 @@
-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__);
 }
diff --git a/src/path.h b/src/path.h
new file mode 100644 (file)
index 0000000..4a41b5d
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef _PATH_H
+#define _PATH_H
+
+void path_resize(Path * path, guint size);
+void path_wresize(Path * path, guint wsize);
+
+#endif
index 1b3f1eade638467134b9d40f16c9dcf1d52ac529..2104cb3a44af4d59128799508d291681b6112587 100644 (file)
@@ -29,9 +29,9 @@
 
 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;
@@ -71,7 +71,7 @@ gboolean category_dialog(guint cat_id)
        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__);
@@ -367,7 +367,7 @@ gboolean menu_cb_category(GtkAction * action)
 }
 
 gboolean 
-poi_delete_confirm(GtkWidget * widget, DeletePOI * dpoi)
+poi_delete_confirm(GtkWidget * widget, delete_poi * dpoi)
 {
        GtkWidget *dialog;
        guint i;
@@ -394,7 +394,7 @@ poi_delete_confirm(GtkWidget * widget, DeletePOI * dpoi)
 }
 
 gboolean 
-select_poi(guint unitx, guint unity, PoiInfo *poi)
+select_poi(guint unitx, guint unity, poi_info *poi)
 {
        GtkWidget *dialog;
        GtkWidget *list;
@@ -550,7 +550,7 @@ gboolean poi_edit_cat(GtkWidget * widget, PoiCategoryEditInfo * data)
 
 gboolean poi_dialog(POIAction action, guint unitx, guint unity)
 {
-       PoiInfo poi;
+       poi_info poi;
        gchar slat1[10], slon1[10];
        gchar *p_latlon;
        GtkWidget *dialog;
@@ -565,7 +565,7 @@ gboolean poi_dialog(POIAction action, guint unitx, guint unity)
        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__);
 
index 7cc0ad9b6886ca4b35016eba6dc45fa81ca44efb..1429c59fec7e4360c3628743e221ddfcce549b3a 100644 (file)
--- a/src/poi.c
+++ b/src/poi.c
@@ -30,7 +30,7 @@
 
 struct _poi_categories {
        node_type_t type;
-       gchar *name, *desc;
+       const gchar *name, *desc;
 };
 
 static struct _poi_categories default_poi_categories[] = {
@@ -260,16 +260,16 @@ if (db_connect(db, data_db)) {
 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 *
@@ -359,7 +359,7 @@ return results;
 }
 
 gboolean 
-poi_category_delete(DeletePOI *dpoi)
+poi_category_delete(delete_poi *dpoi)
 {
 if (!_db)
        return FALSE;
@@ -384,7 +384,7 @@ return TRUE;
 
 
 gboolean 
-poi_delete(DeletePOI *dpoi)
+poi_delete(delete_poi *dpoi)
 {
 if (!_db)
        return FALSE;
@@ -499,10 +499,10 @@ sqlite3_clear_bindings(poisql.insert_poi);
 return TRUE;
 }
 
-PoiInfo *
+poi_info *
 poi_find_nearest(gdouble lat, gdouble lon) 
 {
-PoiInfo *p;
+poi_info *p;
 
 if (!_db)
        return FALSE;
index e08e0105178fe5fa0785066d37e8ef515162c6da..febf84ac71892e9d84ac16e34ca138124b6d7196 100644 (file)
--- a/src/poi.h
+++ b/src/poi.h
@@ -14,15 +14,15 @@ typedef enum {
        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;
@@ -30,8 +30,8 @@ struct _PoiData {
 };
 
 /** 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;
@@ -43,8 +43,8 @@ struct _PoiInfo {
 };
 
 /** 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;
@@ -81,19 +81,19 @@ guint _poi_zoom;
 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();
 
index 8c85d871863ecaafe4ddfcb90412ca01b9bca7bf..776c551b22f67e7e91b2cc8eef7bb2eea4a1d5ac 100644 (file)
 #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;
 
@@ -62,7 +38,8 @@ void track_clear()
        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;
@@ -83,7 +60,8 @@ gfloat track_calculate_distance_from(Point * point)
        return sum;
 }
 
-void track_show_distance_from(Point * point)
+void 
+track_show_distance_from(Point * point)
 {
        gchar buffer[80];
        gfloat sum;
@@ -95,7 +73,8 @@ void track_show_distance_from(Point * point)
        MACRO_BANNER_SHOW_INFO(_window, buffer);
 }
 
-void track_show_distance_from_last()
+void 
+track_show_distance_from_last()
 {
        printf("%s()\n", __PRETTY_FUNCTION__);
 
@@ -113,7 +92,8 @@ void track_show_distance_from_last()
        printf("%s(): return\n", __PRETTY_FUNCTION__);
 }
 
-void track_show_distance_from_first()
+void 
+track_show_distance_from_first()
 {
        printf("%s()\n", __PRETTY_FUNCTION__);
 
@@ -138,7 +118,8 @@ void track_show_distance_from_first()
  * 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;
@@ -213,77 +194,81 @@ void track_add(time_t time, gboolean newly_fixed)
        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;
@@ -294,8 +279,8 @@ _track.wtail->desc = text;
  * 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;
index 91a5b80bacb92f41f2e6745a185edd8f57f4cfb8..a7dfadba61b84f8bf59623b76be6640fa895de4b 100644 (file)
@@ -4,18 +4,6 @@
 #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 (?,?,?,?,?,?,?,?,?,?)"
@@ -28,4 +16,15 @@ struct {
        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
index efd0b580f4aee487c1e62e5571f13e35f1144c8a..49b6a6d0f7564eb6cd40a498deba058111e800db 100644 (file)
@@ -337,9 +337,8 @@ if (_http_proxy_host) { \
     } \
 }
 
-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();