]> mj.ucw.cz Git - leo.git/commitdiff
Log statistics when a data source is loaded
authorMartin Mares <mj@ucw.cz>
Thu, 12 Feb 2015 19:04:31 +0000 (20:04 +0100)
committerMartin Mares <mj@ucw.cz>
Thu, 12 Feb 2015 19:04:31 +0000 (20:04 +0100)
map.c
osm.c
osm.h

diff --git a/map.c b/map.c
index 8f502006324660fe42329f89a797452652c040d3..bbcd7463b1f33de9864a3becb632b2b8c2c3f50e 100644 (file)
--- a/map.c
+++ b/map.c
@@ -236,6 +236,8 @@ static void map_load_source(struct data_source *ds)
       break;
     case DATA_SOURCE_FIXED:
       msg(L_INFO, "Adding fixed objects");
+      if (!ds->file)
+       ds->file = "fixed";
       fixed_add();
       break;
     case DATA_SOURCE_SHAPE:
@@ -249,6 +251,7 @@ static void map_load_source(struct data_source *ds)
       die("Invalid data source format");
     }
 
+  osm_stats();
   if (debug_dump_source)
     {
       puts("=== Source data ===");
diff --git a/osm.c b/osm.c
index 325b592322287858a064f46faa10bd538b5fac96..862f7fbb52012cdcf76221a15879cdc60beace04 100644 (file)
--- a/osm.c
+++ b/osm.c
@@ -74,6 +74,7 @@ static void *osm_obj_new(enum osm_object_type type, osm_id_t id, uns size)
 
   struct osm_object *o = mp_alloc_zero(osm_this->pool, size);
   clist_add_tail(&osm_this->obj_list[type], &o->n);
+  osm_this->obj_cnt[type]++;
   o->type = type;
   o->id = id;
   clist_init(&o->tags);
@@ -585,3 +586,11 @@ void osm_dump(void)
   osm_relation_dump_all();
   osm_multipolygon_dump_all();
 }
+
+void osm_stats(void)
+{
+  msg(L_INFO, "Loaded %u nodes, %u ways, %u relations",
+    osm_this->obj_cnt[OSM_TYPE_NODE],
+    osm_this->obj_cnt[OSM_TYPE_WAY],
+    osm_this->obj_cnt[OSM_TYPE_RELATION]);
+}
diff --git a/osm.h b/osm.h
index ba240c63078655ad49b84bd054e9c3c5bdd41b02..cb6b24e9eb7fb139c6a4302b8cd4f3de67f65f37 100644 (file)
--- a/osm.h
+++ b/osm.h
@@ -81,12 +81,14 @@ struct osm {
   struct mempool *pool;
   clist obj_list[OSM_TYPE_MAX];
   struct osm_id_hash_table *id_hash[OSM_TYPE_MAX];
+  uint obj_cnt[OSM_TYPE_MAX];
 };
 
 extern struct osm *osm_this;
 
 struct osm *osm_init(void);
 void osm_dump(void);
+void osm_stats(void);
 
 osm_id_t osm_parse_id(const char *str);
 struct osm_object *osm_obj_find_by_id(enum osm_object_type type, osm_id_t id);