/* #define VERBOSE */
/* #define VERBOSE_KEYS */
-/* Use small buffer if run on a tablet */
-#ifdef WITH_DEVICE_770
#define FILE_BUFFER 65535
-#else
-#define FILE_BUFFER 524280
-#endif
#define OSM_DB_FILE "osm-planet.db"
static GHashTable *osm_nodes;
static GHashTable *osm_node_tags;
+static GHashTable *osm_way_tags;
static GSList *osm_ways;
static GSList *osm_poi;
void db_prepare(void);
gboolean db_insert_node(node *n);
+guint32 osm_find_way_place(way *w);
/****************************************************/
/* Functions */
db_insert_way(way *w)
{
GSList *iter;
+guint32 isin=0;
if (!w)
return FALSE;
if (w->id==0)
return FALSE;
+/* isin=osm_find_way_place(w); */
+
sqlite3_bind_int(sql.insert_way_data, 1, w->id);
sqlite3_bind_int(sql.insert_way_data, 2, w->ncnt);
sqlite3_bind_int(sql.insert_way_data, 3, w->type);
sqlite3_bind_int(sql.insert_way_data, 4, w->flags);
if (w->data) {
sqlite3_bind_int(sql.insert_way_data, 5, w->data->speed);
- sqlite3_bind_int(sql.insert_way_data, 6, w->data->isin);
}
+sqlite3_bind_int(sql.insert_way_data, 6, isin);
sqlite3_step(sql.insert_way_data);
sqlite3_reset(sql.insert_way_data);
{
dbway_cnt++;
db_insert_way(value);
-if (dbway_cnt % 8192==0) {
+if (dbway_cnt % 8192==0 && dbway_cnt>0) {
g_printf("Ways: %f%%\n",(((float)dbway_cnt/(float)way_cnt)*100));
print_way(value);
}
way_cnt++;
id=atoi(get_attr_key_value(atts, "id"));
cway=osm_new_way(id);
+ osm_way_tags=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
break;
case IN_WNODE_TAG:
ndref=atoi(get_attr_key_value(atts, "ref"));
#endif
osm_new_way_data(cway);
+ g_hash_table_insert(osm_way_tags, g_strdup(k), g_strdup(v));
/* XXX: something faster than this should be used */
if (strcasecmp(k, "name")==0)
switch (t) {
case IN_NODE_TAG:
if (node_cnt % 262140==0) {
- g_printf("Nodes: %d, POIs: %d, Outside box: %d\n", node_cnt, noded_cnt, node_skip_cnt);
+ g_printf("Nodes: %d of %d, POIs: %d, Outside box: %d\n", node_cnt-node_skip_cnt, node_cnt, noded_cnt, node_skip_cnt);
}
if (!osm_node_tags)
print_way(cway);
+#if 0
+ v=g_hash_table_lookup(osm_node_tags, "is_in");
+ if (v) {
+ gchar **isin;
+ isin=g_strsplit(v, ",", 10);
+ g_hash_table_insert(osm_node_isin, GINT_TO_POINTER(cnode->id), isin);
+ }
+#endif
+
/* XXX */
if (cway->data && cway->data->name==NULL && cway->data->ref==NULL &&
cway->data->int_ref==NULL && cway->data->layer==0 && cway->data->speed==0)
}
cway=NULL;
+ g_hash_table_destroy(osm_way_tags);
break;
case IN_BOUND_TAG:
/* */
osm_place_village=g_hash_table_new(g_str_hash, g_str_equal);
osm_place_region=g_hash_table_new(g_str_hash, g_str_equal);
osm_node_isin=g_hash_table_new(g_direct_hash, g_direct_equal);
+osm_way_isin=g_hash_table_new(g_direct_hash, g_direct_equal);
}
static void