" from poi p, category c "
" where p.lat between ? and ? "
" and p.lon between ? and ? "
- " and c.enabled = 1 and p.cat_id = c.cat_id and p.label like ?",
+ " and c.enabled = 1 and p.cat_id = c.cat_id and p.label like ? order by p.label",
-1, &poisql.select_poi_search, NULL);
/* Search POI label && category */
" from poi p, category c "
" where p.lat between ? and ? "
" and p.lon between ? and ? "
- " and c.enabled = 1 and p.cat_id = c.cat_id and p.label like ? and c.cat_id = ?",
+ " and c.enabled = 1 and p.cat_id = c.cat_id and p.label like ? and c.cat_id = ? order by p.label",
-1, &poisql.select_poi_search_cat, NULL);
/* insert poi */
}
gboolean
-poi_category_toggle(gint cat_id, gboolean cat_enabled)
+poi_category_toggle(guint cat_id, gboolean cat_enabled)
{
if (SQLITE_OK != sqlite3_bind_int(poisql.toggle_cat, 1, cat_enabled) ||
SQLITE_OK != sqlite3_bind_int(poisql.toggle_cat, 2, cat_id) ||
}
gboolean
-poi_category_get(gint cat_id, poi_category **c)
+poi_category_get(guint cat_id, poi_category **c)
{
poi_category *cc;
}
gboolean
-poi_category_update(gint cat_id, poi_category *c)
+poi_category_update(guint cat_id, poi_category *c)
{
gboolean results=TRUE;
}
gboolean
-poi_category_delete(delete_poi *dpoi)
+poi_category_delete(guint id)
{
if (!_db)
return FALSE;
-if (SQLITE_OK != sqlite3_bind_int(poisql.delete_poi_by_catid, 1, dpoi->id) || SQLITE_DONE != sqlite3_step(poisql.delete_poi_by_catid)) {
+if (SQLITE_OK != sqlite3_bind_int(poisql.delete_poi_by_catid, 1, id) || SQLITE_DONE != sqlite3_step(poisql.delete_poi_by_catid)) {
sqlite3_reset(poisql.delete_poi_by_catid);
return FALSE;
}
sqlite3_reset(poisql.delete_poi_by_catid);
sqlite3_clear_bindings(poisql.delete_poi_by_catid);
-if (SQLITE_OK != sqlite3_bind_int(poisql.delete_cat, 1, dpoi->id) || SQLITE_DONE != sqlite3_step(poisql.delete_cat)) {
+if (SQLITE_OK != sqlite3_bind_int(poisql.delete_cat, 1, id) || SQLITE_DONE != sqlite3_step(poisql.delete_cat)) {
sqlite3_reset(poisql.delete_cat);
return FALSE;
}
gboolean
-poi_delete(delete_poi *dpoi)
+poi_delete(guint id)
{
if (!_db)
return FALSE;
-if (SQLITE_OK != sqlite3_bind_int(poisql.delete_poi, 1, dpoi->id) || SQLITE_DONE != sqlite3_step(poisql.delete_poi)) {
+if (SQLITE_OK != sqlite3_bind_int(poisql.delete_poi, 1, id) || SQLITE_DONE != sqlite3_step(poisql.delete_poi)) {
sqlite3_reset(poisql.delete_poi);
return FALSE;
}
}
gboolean
-poi_get_list(guint unitx, guint unity, GtkListStore **store, guint *_num_cats)
+poi_get_list_near(guint unitx, guint unity, GtkListStore **store, guint *_num_cats)
{
guint x, y;
gdouble lat1, lon1, lat2, lon2;
if (!_db)
return FALSE;
-*store = gtk_list_store_new(POI_NUM_COLUMNS,
- G_TYPE_INT, /* POI ID */
- G_TYPE_INT, /* Category ID */
- G_TYPE_DOUBLE, /* Latitude */
- G_TYPE_DOUBLE, /* Longitude */
- G_TYPE_STRING, /* Lat/Lon */
- G_TYPE_STRING, /* POI Label */
- G_TYPE_STRING, /* POI Desc. */
- G_TYPE_STRING); /* Category Label */
-
x = unitx - pixel2unit(3 * _draw_width);
y = unity + pixel2unit(3 * _draw_width);
unit2latlon(x, y, lat1, lon1);
return FALSE;
}
+*store = gtk_list_store_new(POI_NUM_COLUMNS,
+ G_TYPE_INT, /* POI ID */
+ G_TYPE_INT, /* Category ID */
+ G_TYPE_DOUBLE, /* Latitude */
+ G_TYPE_DOUBLE, /* Longitude */
+ G_TYPE_STRING, /* Lat/Lon */
+ G_TYPE_STRING, /* POI Label */
+ G_TYPE_STRING, /* POI Desc. */
+ G_TYPE_STRING); /* Category Label */
+
while (SQLITE_ROW == sqlite3_step(poisql.select_poi)) {
gdouble lat, lon;
}
gboolean
-poi_update(gint poi_id, gint cat_id, gchar *poi_label, gchar *poi_desc)
+poi_update(guint poi_id, guint cat_id, gchar *poi_label, gchar *poi_desc)
{
if (!_db)
return FALSE;
}
gboolean
-poi_add(gdouble lat, gdouble lon, gint cat_id, gchar *poi_label, gchar *poi_desc)
+poi_add(gdouble lat, gdouble lon, guint cat_id, gchar *poi_label, gchar *poi_desc)
{
if (!_db)
return FALSE;
}
GtkListStore *
-poi_category_generate_store()
+poi_category_generate_store(void)
{
GtkTreeIter iter;
GtkListStore *store;
guint zoom;
};
-typedef struct _poi_data poi_data;
-struct _poi_data {
- gdouble lat;
- gdouble lon;
- gchar *name;
- gchar *desc;
-};
-
/** Data to describe a POI. */
typedef struct _poi_info poi_info;
struct _poi_info {
guint poi_id;
guint cat_id;
+ guint is_in;
gdouble lat;
gdouble lon;
gchar *label;
typedef struct _poi_category poi_category;
struct _poi_category {
- gint id;
- gint enabled;
+ guint id;
+ gboolean enabled;
+ gboolean warning;
gchar *label;
gchar *desc;
};
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(delete_poi * dpoi);
+
+gboolean poi_get_list_near(guint unitx, guint unity, GtkListStore **store, guint *num_cats);
+gboolean poi_update(guint poi_id, guint cat_id, gchar *poi_label, gchar *poi_desc);
+gboolean poi_add(gdouble lat, gdouble lon, guint cat_id, gchar *poi_label, gchar *poi_desc);
+gboolean poi_delete(guint id);
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(delete_poi * dpoi);
-gboolean poi_category_update(gint cat_id, poi_category *c);
+gboolean poi_category_get(guint cat_id, poi_category **c);
+gboolean poi_category_delete(guint id);
+gboolean poi_category_update(guint cat_id, poi_category *c);
poi_info *poi_find_nearest(gdouble lat, gdouble lon);
-gboolean poi_category_toggle(gint cat_id, gboolean cat_enabled);
-GtkListStore *poi_category_generate_store();
+gboolean poi_category_toggle(guint cat_id, gboolean cat_enabled);
+GtkListStore *poi_category_generate_store(void);
#endif