{
printf("%s()\n", __PRETTY_FUNCTION__);
- _show_velvec =
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM
- (_menu_show_velvec_item));
+ _show_velvec = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(_menu_show_velvec_item));
map_move_mark();
vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
{
printf("%s()\n", __PRETTY_FUNCTION__);
- _show_poi =
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM
- (_menu_show_poi_item));
+ _show_poi = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(_menu_show_poi_item));
map_force_redraw();
vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
{
printf("%s()\n", __PRETTY_FUNCTION__);
- _gps_info =
- gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM
- (_menu_gps_show_info_item));
+ _gps_info = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(_menu_gps_show_info_item));
gps_show_info();
latlon2unit(lat, lon, unitx, unity);
if (_center_mode > 0)
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
- (_menu_ac_none_item),
- TRUE);
+ (_menu_ac_none_item), TRUE);
map_center_unit(unitx, unity);
break;
}
gboolean menu_cb_goto_nearpoi(GtkAction * action)
{
- printf("%s()\n", __PRETTY_FUNCTION__);
+gdouble lat, lon;
+PoiInfo *p;
- if (_db) {
- gfloat lat, lon;
+printf("%s()\n", __PRETTY_FUNCTION__);
- if (_center_mode > 0) {
- /* Auto-Center is enabled - use the GPS position. */
- unit2latlon(_pos.unitx, _pos.unity, lat, lon);
- } else {
- /* Auto-Center is disabled - use the view center. */
- unit2latlon(_center.unitx, _center.unity, lat, lon);
- }
+if (_center_mode > 0) {
+ /* Auto-Center is enabled - use the GPS position. */
+ unit2latlon(_pos.unitx, _pos.unity, lat, lon);
+} else {
+ /* Auto-Center is disabled - use the view center. */
+ unit2latlon(_center.unitx, _center.unity, lat, lon);
+}
- if (SQLITE_OK == sqlite3_bind_double(_stmt_select_nearest_poi, 1, lat)
- && SQLITE_OK == sqlite3_bind_double(_stmt_select_nearest_poi, 2, lon)
- && SQLITE_ROW == sqlite3_step(_stmt_select_nearest_poi)) {
- guint unitx, unity;
- gchar *banner;
- const gchar *poi_label, *cat_label;
+p=poi_find_nearest(lat, lon);
- lat = sqlite3_column_double(_stmt_select_nearest_poi, 0);
- lon = sqlite3_column_double(_stmt_select_nearest_poi, 1);
- poi_label = sqlite3_column_text(_stmt_select_nearest_poi, 2);
- cat_label = sqlite3_column_text(_stmt_select_nearest_poi, 3);
+if (p) {
+ guint unitx, unity;
+ gchar *banner;
- latlon2unit(lat, lon, unitx, unity);
- banner = g_strdup_printf("%s (%s)", poi_label, cat_label);
- MACRO_BANNER_SHOW_INFO(_window, banner);
- g_free(banner);
+ latlon2unit(p->lat, p->lon, unitx, unity);
+ banner = g_strdup_printf("%s (%s)", p->label, p->cat_label);
+ g_printf("%s\n", banner);
+ MACRO_BANNER_SHOW_INFO(_window, banner);
+ g_free(banner);
+ poi_free(p);
- if (_center_mode > 0)
- gtk_check_menu_item_set_active
- (GTK_CHECK_MENU_ITEM(_menu_ac_none_item),
- TRUE);
+ if (_center_mode > 0)
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_ac_none_item), TRUE);
- map_center_unit(unitx, unity);
- } else {
- MACRO_BANNER_SHOW_INFO(_window, _("No POIs found."));
- }
- sqlite3_reset(_stmt_select_nearest_poi);
- }
+ map_center_unit(unitx, unity);
+} else {
+ MACRO_BANNER_SHOW_INFO(_window, _("No POIs found."));
+}
- vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
- return TRUE;
+vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
+return TRUE;
}
gboolean menu_cb_maps_repoman(GtkAction * action)
snprintf(buffer, sizeof(buffer), "%s:\n%s\n",
_("Confirm delete of waypoint"), way->desc);
- confirm =
- hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
+ confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
Point *pdel_min, *pdel_max, *pdel_start, *pdel_end;
return FALSE;
}
+PoiInfo *
+poi_new(void)
+{
+PoiInfo *p;
+
+return g_slice_new0(PoiInfo);
+}
+
+void
+poi_free(PoiInfo *p)
+{
+g_slice_free(PoiInfo, p);
+}
+
gboolean
-poi_category_update(gint cat_id, gchar * cat_label, gchar * cat_desc,
- gint cat_enabled)
+poi_category_update(gint cat_id, gchar *cat_label, gchar *cat_desc, gint cat_enabled)
{
gboolean results=TRUE;
+if (!_db)
+ return FALSE;
+
if (cat_id > 0) {
/* edit category */
if (SQLITE_OK !=
gboolean
poi_category_delete(DeletePOI *dpoi)
{
+if (!_db)
+ return FALSE;
+
if (SQLITE_OK != sqlite3_bind_int(_stmt_delete_poi_by_catid, 1, dpoi->id)
|| SQLITE_DONE != sqlite3_step(_stmt_delete_poi_by_catid)) {
sqlite3_reset(_stmt_delete_poi_by_catid);
gboolean
poi_delete(DeletePOI *dpoi)
{
+if (!_db)
+ return FALSE;
+
if (SQLITE_OK != sqlite3_bind_int(_stmt_delete_poi, 1, dpoi->id) ||
SQLITE_DONE != sqlite3_step(_stmt_delete_poi)) {
sqlite3_reset(_stmt_delete_poi);
gchar tmp1[16], tmp2[16];
gint num_cats=0;
+if (!_db)
+ return FALSE;
+
store = gtk_list_store_new(POI_NUM_COLUMNS, G_TYPE_INT, /* POI ID */
G_TYPE_INT, /* Category ID */
G_TYPE_FLOAT, /* Latitude */
gboolean
poi_update(gint poi_id, gint cat_id, gchar *poi_label, gchar *poi_desc)
{
+if (!_db)
+ return FALSE;
+
if (SQLITE_OK != sqlite3_bind_text(_stmt_update_poi, 1, poi_label, -1, SQLITE_STATIC)
|| SQLITE_OK != sqlite3_bind_text(_stmt_update_poi, 2, poi_desc, -1, g_free)
|| SQLITE_OK != sqlite3_bind_int(_stmt_update_poi, 3, cat_id)
gboolean
poi_add(gdouble lat, gdouble lon, gint cat_id, gchar *poi_label, gchar *poi_desc)
{
+if (!_db)
+ return FALSE;
+
if (SQLITE_OK != sqlite3_bind_double(_stmt_insert_poi, 1, lat)
|| SQLITE_OK != sqlite3_bind_double(_stmt_insert_poi, 2, lon)
|| SQLITE_OK != sqlite3_bind_text(_stmt_insert_poi, 3, poi_label, -1, g_free)
return TRUE;
}
+PoiInfo *
+poi_find_nearest(gdouble lat, gdouble lon)
+{
+const gchar *_poi_label, *_cat_label;
+PoiInfo *p;
+
+if (!_db)
+ return FALSE;
+
+sqlite3_reset(_stmt_select_nearest_poi);
+sqlite3_clear_bindings(_stmt_select_nearest_poi);
+
+if (SQLITE_OK == sqlite3_bind_double(_stmt_select_nearest_poi, 1, lat)
+ && SQLITE_OK == sqlite3_bind_double(_stmt_select_nearest_poi, 2, lon)
+ && SQLITE_ROW == sqlite3_step(_stmt_select_nearest_poi)) {
+
+ p=poi_new();
+
+ p->lat = sqlite3_column_double(_stmt_select_nearest_poi, 0);
+ p->lon = sqlite3_column_double(_stmt_select_nearest_poi, 1);
+ _poi_label = sqlite3_column_text(_stmt_select_nearest_poi, 2);
+ _cat_label = sqlite3_column_text(_stmt_select_nearest_poi, 3);
+ p->label=g_strdup(_poi_label);
+ p->cat_label=g_strdup(_cat_label);
+ g_printf("%f %f %s %s\n", p->lat, p->lon, p->label, p->cat_label);
+ return p;
+}
+return NULL;
+}
/*
-
-POI table definitions:
-
--- public POIs from different sources
--- (Fuel, pubs, museums, etc)
---
-create table poi (
- poi_id integer PRIMARY KEY,
- cat_id integer,
- source int,
- source_id int,
- type int,
- lat real,
- lon real,
- elev real,
- label text,
- desc text,
- wikipedia text,
- url text,
- phone varchar(64),
- email varchar(64),
-);
-
--- type:
--- 0=POI
--- 1=Landmark
-
--- Shared categories for POIs and landmarks
-create table category (
- cat_id integer PRIMARY KEY,
- pcat_id int,
- priority int,
- label text,
- desc text,
- color char(6),
- icon varchar(32),
- enabled integer
-);
-
-Categories:
-Fuel
- - Esso, Teboil, BP, Nest, etc
-Parking
-Residence
-Dining
- - Restaurant
-Fast food
-Shopping/Services
-Recreation
-Transportation
- - Bus
- - Train
- - Boat/Ferry
- - Plane
-Lodging
- - Hotell
- - Motell
-School
-Business
-Landmark
-Other
-
-*/
+ * POI definitions
+ *
+ * See docs for table definitions.
+ */
#ifndef _MAPPER_POI_H
#define _MAPPER_POI_H
gfloat lon;
gchar *label;
gchar *desc;
+ gchar *cat_label;
+ gchar *cat_desc;
};
/** Data used during action: add or edit category/poi **/
gboolean poi_delete(DeletePOI * dpoi);
gboolean poi_category_delete(DeletePOI * dpoi);
gboolean poi_category_update(gint cat_id, gchar * cat_label, gchar * cat_desc, gint cat_enabled);
+PoiInfo *poi_find_nearest(gdouble lat, gdouble lon);
#endif