#include <sqlite3.h>
#include "db.h"
+#include "osm-sql-tables.h"
sqlite3 *_db=NULL;
gchar *_mapper_db=NULL;
+void
+db_create_tables(sqlite3 *db)
+{
+sqlite3_exec(db, OSM_TABLE_NODES,NULL, NULL, NULL);
+sqlite3_exec(db, OSM_TABLE_NODE_TAGS,NULL, NULL, NULL);
+sqlite3_exec(db, OSM_TABLE_WAY,NULL, NULL, NULL);
+sqlite3_exec(db, OSM_TABLE_WAY_TAGS,NULL, NULL, NULL);
+sqlite3_exec(db, OSM_TABLE_WAY_UPDATES,NULL, NULL, NULL);
+sqlite3_exec(db, OSM_TABLE_WAY_N2N,NULL, NULL, NULL);
+sqlite3_exec(db, OSM_TABLE_WAY_NAMES,NULL, NULL, NULL);
+sqlite3_exec(db, OSM_TABLE_WAY_PC,NULL, NULL, NULL);
+sqlite3_exec(db, OSM_TABLE_WAY_NAMES_NLS,NULL, NULL, NULL);
+sqlite3_exec(db, OSM_TABLE_WAY_REF,NULL, NULL, NULL);
+sqlite3_exec(db, OSM_TABLE_PLACES,NULL, NULL, NULL);
+sqlite3_exec(db, OSM_TABLE_POI,NULL, NULL, NULL);
+sqlite3_exec(db, OSM_TABLE_POI_CATEGORY,NULL, NULL, NULL);
+}
+
+void
+db_create_indexes(sqlite3 *db)
+{
+sqlite3_exec(db, OSM_INDEX_1, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_2, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_3, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_4, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_5, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_6, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_7, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_8, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_9, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_10, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_11, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_12, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_13, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_14, NULL, NULL, NULL);
+sqlite3_exec(db, OSM_INDEX_15, NULL, NULL, NULL);
+}
+
/**
* A simple check to test if a table exists
*
return TRUE;
}
+
+
+
#include "osm.h"
#include "latlon.h"
#include "db.h"
-#include "osm-sql-tables.h"
+
#if 0
#define VERBOSE
sqlite3_finalize(sql.insert_way_names_nls);
}
-void
-db_create_tables(sqlite3 *db)
-{
-sqlite3_exec(db, OSM_TABLE_NODES,NULL, NULL, NULL);
-sqlite3_exec(db, OSM_TABLE_NODE_TAGS,NULL, NULL, NULL);
-sqlite3_exec(db, OSM_TABLE_WAY,NULL, NULL, NULL);
-sqlite3_exec(db, OSM_TABLE_WAY_TAGS,NULL, NULL, NULL);
-sqlite3_exec(db, OSM_TABLE_WAY_UPDATES,NULL, NULL, NULL);
-sqlite3_exec(db, OSM_TABLE_WAY_N2N,NULL, NULL, NULL);
-sqlite3_exec(db, OSM_TABLE_WAY_NAMES,NULL, NULL, NULL);
-sqlite3_exec(db, OSM_TABLE_WAY_PC,NULL, NULL, NULL);
-sqlite3_exec(db, OSM_TABLE_WAY_NAMES_NLS,NULL, NULL, NULL);
-sqlite3_exec(db, OSM_TABLE_WAY_REF,NULL, NULL, NULL);
-sqlite3_exec(db, OSM_TABLE_PLACES,NULL, NULL, NULL);
-sqlite3_exec(db, OSM_TABLE_POI,NULL, NULL, NULL);
-sqlite3_exec(db, OSM_TABLE_POI_CATEGORY,NULL, NULL, NULL);
-}
-void
-db_create_indexes(sqlite3 *db)
-{
-sqlite3_exec(db, OSM_INDEX_1, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_2, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_3, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_4, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_5, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_6, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_7, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_8, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_9, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_10, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_11, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_12, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_13, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_14, NULL, NULL, NULL);
-sqlite3_exec(db, OSM_INDEX_15, NULL, NULL, NULL);
-}
void
db_prepare(sqlite3 *db)
}
#endif
-static gboolean
+static inline gboolean
osm_node_check_box(gdouble nlat, gdouble nlon)
{
if (use_bbox==FALSE)
osm_find_node(guint32 nid)
{
node *n;
+
+g_assert(osm_nodes);
n=g_hash_table_lookup(osm_nodes, GINT_TO_POINTER(nid));
#if 0
if (!n)