From 9e0796f5be17bd5e65c31865cac25d38c8b2a0fb Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 12 Feb 2015 20:04:31 +0100 Subject: [PATCH] Log statistics when a data source is loaded --- map.c | 3 +++ osm.c | 9 +++++++++ osm.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/map.c b/map.c index 8f50200..bbcd746 100644 --- 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 325b592..862f7fb 100644 --- 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 ba240c6..cb6b24e 100644 --- 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); -- 2.39.2