DB_PREP(db, "delete from poi where cat_id=?", poisql.delete_poi_by_catid);
/* select from category */
-DB_PREP(db, "select c.label, c.desc, c.enabled"
- " from category c where c.cat_id = ?",
- poisql.select_cat);
+DB_PREP(db, "select c.label, c.desc, c.enabled from category c where c.cat_id = ?", poisql.select_cat);
/* insert into category */
-DB_PREP(db, "insert into category (label, desc, enabled)"
- " values (?, ?, ?)",
- poisql.insert_cat);
+DB_PREP(db, "insert into category (label, desc, enabled) values (?, ?, ?)", poisql.insert_cat);
/* update category */
-DB_PREP(db, "update category set label = ?, desc = ?,"
- " enabled = ? where poi_id = ?",
- poisql.update_cat);
+DB_PREP(db, "update category set label = ?, desc = ?, enabled = ? where cat_id = ?", poisql.update_cat);
/* delete from category */
-DB_PREP(db,"delete from category where cat_id = ?",
- poisql.delete_cat);
+DB_PREP(db,"delete from category where cat_id = ?", poisql.delete_cat);
/* enable category */
-DB_PREP(db, "update category set enabled = ?"
- " where cat_id = ?",
- poisql.toggle_cat);
+DB_PREP(db, "update category set enabled = ? where cat_id = ?", poisql.toggle_cat);
/* select all category */
DB_PREP(db, "select c.cat_id, c.label, c.desc, c.enabled, c.icon, c.color,"
" count(p.poi_id)"
g_slice_free(poi_info, p);
}
-static GtkListStore *
+GtkListStore *
poi_list_store_new(void) {
return gtk_list_store_new(ITEM_NUM_COLUMNS,
G_TYPE_INT, /* POI ID */
}
gboolean
-poi_search(poi_search_type pst, gdouble lat, gdouble lon, gchar *text, guint cat, GtkListStore **store)
+poi_search(poi_search_type pst, gdouble lat, gdouble lon, gchar *text, guint cat, GtkListStore *store)
{
GtkTreeIter iter;
sqlite3_stmt *sql=NULL;
return FALSE;
g_return_val_if_fail(poisql.select_poi, FALSE);
+g_return_val_if_fail(store, FALSE);
g_printf("POI Search: [%s] around %.6f %.6f (%d %d)\n", text, lat, lon, cat, pst);
return FALSE;
}
-if (*store==NULL)
- *store = poi_list_store_new();
-
while (SQLITE_ROW == sqlite3_step(sql)) {
gdouble rlat, rlon, dist;
lon_format(_degformat, rlon, tmp2);
dist=calculate_distance(lat, lon, rlat, rlon) * UNITS_CONVERT[_units];
- gtk_list_store_append(*store, &iter);
- gtk_list_store_set(*store, &iter,
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
ITEM_ID, sqlite3_column_int(sql, 2),
ITEM_CATID, sqlite3_column_int(sql, 5),
ITEM_LAT, rlat,
}
gboolean
-poi_get_list_inside(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2, GtkListStore **store, guint *num_poi)
+poi_get_list_inside(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2, GtkListStore *store, guint *num_poi)
{
static gboolean active=FALSE;
GtkTreeIter iter;
return FALSE;
g_return_val_if_fail(poisql.select_poi, FALSE);
+g_return_val_if_fail(store, FALSE);
if (active)
return FALSE;
active=TRUE;
if (SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 1, lat1) ||
- SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 2, lat2) ||
- SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 3, lon1) ||
- SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 4, lon2)) {
+ SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 2, lat2) ||
+ SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 3, lon1) ||
+ SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 4, lon2)) {
g_printerr("Failed to bind values for poisql.select_poi\n");
return FALSE;
}
-if (*store==NULL)
- *store = poi_list_store_new();
-
while (SQLITE_ROW == sqlite3_step(poisql.select_poi)) {
gdouble lat, lon, dist=0;
lat_format(_degformat, lat, tmp1);
lon_format(_degformat, lon, tmp2);
- gtk_list_store_append(*store, &iter);
- gtk_list_store_set(*store, &iter,
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
ITEM_ID, sqlite3_column_int(poisql.select_poi, 2),
ITEM_CATID, sqlite3_column_int(poisql.select_poi, 5),
ITEM_LAT, lat,
}
gboolean
-poi_get_list_near_unit(guint unitx, guint unity, guint range, GtkListStore **store, guint *num_poi)
+poi_get_list_near(gdouble lat, gdouble lon, gfloat range, GtkListStore *store, guint *num_poi)
{
gdouble lat1, lon1, lat2, lon2;
-guint x, y;
-
-x=unitx-pixel2unit(3*range);
-y=unity+pixel2unit(3*range);
-unit2latlon(x, y, lat1, lon1);
-x=unitx+pixel2unit(3*range);
-y=unity-pixel2unit(3*range);
-unit2latlon(x, y, lat2, lon2);
+lat1=lat-range;
+lon1=lon-range;
+lat2=lat+range;
+lon2=lon+range;
return poi_get_list_inside(lat1, lon1, lat2, lon2, store, num_poi);
}
poi_info *poi_new(void);
void poi_free(poi_info *p);
-gboolean poi_get_list_near_unit(guint unitx, guint unity, guint range, GtkListStore **store, guint *num_poi);
-gboolean poi_get_list_inside(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2, GtkListStore **store, guint *num_poi);
-
-poi_info *poi_get_by_id(guint id);
-
gboolean poi_update(poi_info *p);
gboolean poi_add(poi_info *p);
gboolean poi_delete(guint id);
+poi_info *poi_get_by_id(guint id);
-gboolean poi_search(poi_search_type pst, gdouble lat, gdouble lon, gchar *text, guint cat, GtkListStore **store);
-poi_info *poi_find_nearest(gdouble lat, gdouble lon);
+GtkListStore *poi_list_store_new(void);
-gboolean poi_get_list_near_unit(guint unitx, guint unity, guint range, GtkListStore **store, guint *num_poi);
+gboolean poi_get_list_near(gdouble lat, gdouble lon, gfloat range, GtkListStore *store, guint *num_poi);
+gboolean poi_get_list_inside(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2, GtkListStore *store, guint *num_poi);
+gboolean poi_search(poi_search_type pst, gdouble lat, gdouble lon, gchar *text, guint cat, GtkListStore *store);
+
+poi_info *poi_find_nearest(gdouble lat, gdouble lon);
poi_category *poi_category_new(void);
void poi_category_free(poi_category *c);
gboolean poi_category_delete(guint id);
gboolean poi_category_update(guint cat_id, poi_category *c);
gboolean poi_category_toggle(guint cat_id, gboolean cat_enabled);
+GtkListStore *poi_category_generate_store(void);
GdkPixbuf *poi_get_icon(const gchar *icon, gboolean big);
const gchar *poi_get_icon_from_type(node_type_t t);
void poi_icon_hash_clear(void);
-GtkListStore *poi_category_generate_store(void);
-
#endif