--- /dev/null
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <strings.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <math.h>
+#include <glib.h>
+#include <sqlite3.h>
+#include <expat.h>
+
+#include "osm.h"
+
+struct sql_select_stmt {
+ sqlite3_stmt *select_way;
+ sqlite3_stmt *select_way_nodes;
+ sqlite3_stmt *select_way_name;
+ sqlite3_stmt *select_way_ref;
+ sqlite3_stmt *select_place;
+};
+static struct sql_select_stmt sql;
+
+gboolean
+osm_init_sql_selects(void)
+{
+/* Place */
+/* Select nearest place inside lat,lon+-range */
+sqlite3_prepare(db, "select name from place where type=? "
+ " and lat between $LAT-$RANGE and $LAT+$RANGE"
+ " and lon between $LON-$RANGE and $LON+$RANGE",
+ -1, &sql.select_place, NULL);
+
+/* Ways */
+/* Select neareset ways inside lat,lon+-range */
+sqlite3_prepare(db, "select wid from way,way_seg,nodes where wid=wsid and way_seg.node=nodes.nid "
+ " and nodes.lat between $LAT-$RANGE and $LAT+$RANGE "
+ " and nodes.lon between $LON-$RANGE and $LON+$RANGE "
+ " order by (($LAT-lat)*($LAT-lan))+(($LON-lon)*($LON-lon))",
+ -1, &sql.select_way_name, NULL);
+
+/* Select way nodes */
+sqlite3_prepare(db, "select wsid,lat,lon from way_seg,nodes where wsid=? and way_seg.node=nodes.nid",
+ -1, &sql.select_way_nodes, NULL);
+
+/* Way name and ref */
+sqlite3_prepare(db, "select name from way_names where wid=?",
+ -1, &sql.select_way_name, NULL);
+sqlite3_prepare(db, "select ref,int_ref from way_ref where rid=?",
+ -1, &sql.select_way_ref, NULL);
+
+return TRUE;
+}
+
+gboolean
+osm_init()
+{
+return TRUE;
+}
+
+/**
+ * Search for the nearest place, type
+ */
+osm_place *
+osm_find_nearest_place(gint type, gint lat, gint lon)
+{
+
+}
+
+/**
+ * Search for the nearest way (road)
+ */
+osm_way *
+osm_find_nearest_way(gint lat, gint lon)
+{
+
+}