#include "osm.h"
#include "latlon.h"
-
+#include "gps.h"
#include "osm-db.h"
/* #define DEBUG_OSM */
return FALSE;
}
-#if 0
-/* Way helper */
-static GList *
-osm_find_nearest_way_nodes(gint lat, gint lon, guint range)
-{
-GList *ways=NULL;
-osm_way *w;
-gulong tms;
-gint wc=0;
-
-sqlite3_reset(sql.select_way);
-sqlite3_clear_bindings(sql.select_way);
-
-if (SQLITE_OK != sqlite3_bind_int(sql.select_way, 1, lat) ||
- SQLITE_OK != sqlite3_bind_int(sql.select_way, 2, lon) ||
- SQLITE_OK != sqlite3_bind_int(sql.select_way, 3, range) ||
- SQLITE_OK != sqlite3_bind_int(sql.select_way, 4, WAY_ROAD_START) ||
- SQLITE_OK != sqlite3_bind_int(sql.select_way, 5, WAY_ROAD_END)) {
- g_printerr("Failed to bind values for way\n");
- return NULL;
-}
-
-g_timer_start(dbt);
-
-while (SQLITE_ROW == sqlite3_step(sql.select_way)) {
- guint32 dist;
-
- wc++;
- w=g_slice_new0(osm_way);
- w->id=sqlite3_column_int(sql.select_way, 0);
- w->type=sqlite3_column_int(sql.select_way, 1);
- w->nodecnt=sqlite3_column_int(sql.select_way, 2);
- w->flags=sqlite3_column_int(sql.select_way, 3);
- dist=sqlite3_column_int(sql.select_way, 4);
- w->dist=sqrt((gdouble)dist);
- w->node_num=sqlite3_column_int(sql.select_way, 5);
- ways=g_list_prepend(ways, w);
-}
-
-g_timer_stop(dbt);
-g_printf("Query took: %f sec, found: %d ways\n", g_timer_elapsed(dbt, &tms), wc);
-
-return ways;
-}
-
-#else
-
/* Way helper */
static GList *
osm_find_nearest_way_nodes(gint lat, gint lon, guint range)
return ways;
}
-#endif
-
/*****************************************************************************/
static inline gdouble
/* 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) {
/* We are probably on the same way as last time */
- if (dist>(gdouble)way_dist_range) {
+ if ( (dist>(gdouble)way_dist_range) || (fabs(_gps.heading-map_loc->heading)>10.0)) {
/* We have moved a large amount, check way again */
g_printf("*** dist %f over range, checking again\n", dist);
osm_way_free(map_loc->street);
}
}
+if (map_loc->changed==TRUE) {
+ map_loc->heading=_gps.heading;
+ map_loc->speed=_gps.speed;
+}
+
g_printf("D: %ld %ld\n", d,(gulong)way_dist_range);
if (check_place==TRUE && d>way_dist_range*4) {
void osm_set_way_range(guint sr);
void osm_progress_set_widget(sqlite3 *db, GtkProgressBar *w);
+gboolean osm_db_prepare(sqlite3 *db);
gboolean osm_way_get_nodes(osm_way *w);
gboolean osm_way_get_name(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_place_get(guint32 id, gint lat, gint lon, osm_place **nr);
+
gboolean osm_get_location_data(gint lat, gint lon, osm_location *map_loc);
+osm_way_node *osm_way_node_new(guint id, gint lat, gint lon, gint flags);
+
+void osm_way_node_free(osm_way_node *n);
+void osm_way_free(osm_way *w);
+
#endif