]> err.no Git - mapper/commitdiff
Go back to small read buffer. Start to rewrite way tag handling.
authorKaj-Michael Lang <milang@angel.tal.org>
Thu, 25 Oct 2007 12:08:46 +0000 (15:08 +0300)
committerKaj-Michael Lang <milang@angel.tal.org>
Thu, 25 Oct 2007 12:08:46 +0000 (15:08 +0300)
src/osm.c

index dd1b028376bfd4b265ea17715c2c49ab9ce9f89c..d91392dc11a03c165c296b0ceeab9df54ea10e5d 100644 (file)
--- a/src/osm.c
+++ b/src/osm.c
 /* #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"
 
@@ -257,6 +252,7 @@ tag_parent_t tag_parent=IS_NONE;
 
 static GHashTable *osm_nodes;
 static GHashTable *osm_node_tags;
+static GHashTable *osm_way_tags;
 static GSList *osm_ways;
 static GSList *osm_poi;
 
@@ -311,6 +307,7 @@ gboolean db_close(void);
 
 void db_prepare(void);
 gboolean db_insert_node(node *n);
+guint32 osm_find_way_place(way *w);
 
 /****************************************************/
 /* Functions */
@@ -600,6 +597,7 @@ static gboolean
 db_insert_way(way *w)
 {
 GSList *iter;
+guint32 isin=0;
 
 if (!w)
        return FALSE;
@@ -620,14 +618,16 @@ print_way(w);
 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);
@@ -999,7 +999,7 @@ osm_way_save(way *value, gpointer user_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);
 }
@@ -1081,6 +1081,7 @@ switch (t) {
                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"));
@@ -1137,6 +1138,7 @@ switch (t) {
 #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)
@@ -1210,7 +1212,7 @@ t=check_tag(name);
 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)
@@ -1278,6 +1280,15 @@ switch (t) {
 
                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)
@@ -1293,6 +1304,7 @@ switch (t) {
                }
 
                cway=NULL;
+               g_hash_table_destroy(osm_way_tags);
        break;
        case IN_BOUND_TAG:
                /* */
@@ -1317,6 +1329,7 @@ osm_place_suburb=g_hash_table_new(g_str_hash, g_str_equal);
 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