From f5cdad1d1f35c58f118d6383a051edfd3d849d40 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Thu, 9 Aug 2007 16:09:16 +0300 Subject: [PATCH] Misc cleanups. --- src/cb.c | 13 +++--- src/gpx.c | 21 ++++++---- src/hildon-wrappers.c | 5 ++- src/latlon.c | 45 ++++++++++++++++----- src/latlon.h | 2 +- src/map.c | 61 +++++----------------------- src/mapper.c | 6 +-- src/osm-db.c | 94 +++++++++++++++++++++++++++++++++++++++---- src/osm-db.h | 6 +++ src/osm.h | 3 ++ src/poi-gui.c | 14 +++---- src/poi.c | 18 ++++----- src/poi.h | 26 ++++++------ src/utils.c | 14 +++---- src/utils.h | 5 +-- 15 files changed, 206 insertions(+), 127 deletions(-) diff --git a/src/cb.c b/src/cb.c index d43a3c1..f975089 100644 --- 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; @@ -459,6 +460,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; @@ -487,7 +489,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__); @@ -516,6 +518,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.")); } @@ -1424,7 +1427,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)) { @@ -1439,7 +1442,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)) { @@ -1454,7 +1457,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)) { @@ -1469,7 +1472,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)) { diff --git a/src/gpx.c b/src/gpx.c index 117a65c..3971be7 100644 --- a/src/gpx.c +++ b/src/gpx.c @@ -53,12 +53,14 @@ #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__); diff --git a/src/hildon-wrappers.c b/src/hildon-wrappers.c index a73d9b1..e60138e 100644 --- a/src/hildon-wrappers.c +++ b/src/hildon-wrappers.c @@ -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); } diff --git a/src/latlon.c b/src/latlon.c index 5b14311..025246f 100644 --- a/src/latlon.c +++ b/src/latlon.c @@ -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); } diff --git a/src/latlon.h b/src/latlon.h index ec07c1d..52f39ca 100644 --- a/src/latlon.h +++ b/src/latlon.h @@ -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 diff --git a/src/map.c b/src/map.c index 047bde0..ebef065 100644 --- 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; diff --git a/src/mapper.c b/src/mapper.c index 77210ef..ca18db5 100644 --- a/src/mapper.c +++ b/src/mapper.c @@ -50,16 +50,16 @@ #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 "cb.h" +#include "osm-db.h" gfloat UNITS_CONVERT[] = {1.85200,1.15077945,1.f,}; diff --git a/src/osm-db.c b/src/osm-db.c index c09592e..bfc0e2c 100644 --- a/src/osm-db.c +++ b/src/osm-db.c @@ -16,9 +16,11 @@ #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; +} + + diff --git a/src/osm-db.h b/src/osm-db.h index 2eea3e6..6403e0e 100644 --- a/src/osm-db.h +++ b/src/osm-db.h @@ -4,9 +4,13 @@ #include #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 diff --git a/src/osm.h b/src/osm.h index bc33227..d475d87 100644 --- 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 diff --git a/src/poi-gui.c b/src/poi-gui.c index 5604451..f3abfdc 100644 --- a/src/poi-gui.c +++ b/src/poi-gui.c @@ -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__); diff --git a/src/poi.c b/src/poi.c index 7cc0ad9..1429c59 100644 --- 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; diff --git a/src/poi.h b/src/poi.h index e08e010..febf84a 100644 --- 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(); diff --git a/src/utils.c b/src/utils.c index 3f3ee3e..b096d13 100644 --- a/src/utils.c +++ b/src/utils.c @@ -55,15 +55,15 @@ if (!fork()) { #if 0 void latlon2unit(gdouble lat, gdouble lon, gint *unitx_, gint *unity_) { - gdouble tmp; +gdouble tmp; - gint unitx = &unitx_; - gint unity = &unity_; +gint unitx = &unitx_; +gint unity = &unity_; - unitx = (lon + 180.f) * (WORLD_SIZE_UNITS / 360.f) + 0.5f; - tmp = sinf(lat * (PI / 180.f)); - unity = 0.5f + (WORLD_SIZE_UNITS / MERCATOR_SPAN) - * (logf((1.f + tmp) / (1.f - tmp)) * 0.5f - MERCATOR_TOP); +unitx = (lon + 180.f) * (WORLD_SIZE_UNITS / 360.f) + 0.5f; +tmp = sinf(lat * (PI / 180.f)); +unity = 0.5f + (WORLD_SIZE_UNITS / MERCATOR_SPAN) + * (logf((1.f + tmp) / (1.f - tmp)) * 0.5f - MERCATOR_TOP); } void unit2latlon(gint unitx, gint unity, gdouble *lat, gdouble *lon) diff --git a/src/utils.h b/src/utils.h index efd0b58..49b6a6d 100644 --- a/src/utils.h +++ b/src/utils.h @@ -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(); -- 2.39.5