From: Kaj-Michael Lang Date: Tue, 8 Apr 2008 14:03:03 +0000 (+0300) Subject: Add helper function to just check if location hasn't changed too much. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a764697ab08316ed97fd504e084968a6429e71b6;p=mapper Add helper function to just check if location hasn't changed too much. --- diff --git a/src/osm-db.c b/src/osm-db.c index 0550226..c1e4032 100644 --- a/src/osm-db.c +++ b/src/osm-db.c @@ -320,6 +320,7 @@ osmdb=NULL; osm_db_ok=FALSE; memset(&sql, 0, sizeof(sql)); g_hash_table_destroy(pcache.cache); +pcache.cache=NULL; pcache.hit=0; pcache.miss=0; g_timer_destroy(dbt); @@ -1004,6 +1005,19 @@ return FALSE; /******************************************************************************/ +/** + * Check if we have moved away from the last known street + */ +gboolean +osm_check_location(osm_location *map_loc, gint lat, gint lon) +{ +gdouble dist; +if (map_loc->street && osm_way_distance(lat, lon, map_loc->street->node_f, map_loc->street->node_t, &dist)==TRUE) { + return (dist>(gdouble)way_dist_range) ? FALSE : TRUE; +} else + return FALSE; +} + /** * Try to figure out where the given lat,lon is. Fills in the given struct, * with street, secondary (suburb) and primary (city,town,village) location.