diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-12-03 10:22:51 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-12-03 10:22:51 +0000 |
commit | cfd520c75828f6a62ef90a1ee5c12abe7bb19ad9 (patch) | |
tree | 79a0b75ab0a12845fc3a3a01fc066e8e6b180995 /navit/maptool/itembin.c | |
parent | ebb57ea58a18ec040966432c0bce6e8c907b649e (diff) | |
download | navit-cfd520c75828f6a62ef90a1ee5c12abe7bb19ad9.tar.gz |
Fix:maptool:Some cleanups
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2822 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/maptool/itembin.c')
-rw-r--r-- | navit/maptool/itembin.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/navit/maptool/itembin.c b/navit/maptool/itembin.c index 9b42b91c2..47a0893ae 100644 --- a/navit/maptool/itembin.c +++ b/navit/maptool/itembin.c @@ -267,3 +267,81 @@ dump_itembin(struct item_bin *ib) item_bin_dump(ib, stdout); } +struct population_table { + enum item_type type; + int population; +}; + +static struct population_table town_population[] = { + {type_town_label_0e0,0}, + {type_town_label_1e0,1}, + {type_town_label_2e0,2}, + {type_town_label_5e0,5}, + {type_town_label_1e1,10}, + {type_town_label_2e1,20}, + {type_town_label_5e1,50}, + {type_town_label_1e2,100}, + {type_town_label_2e2,200}, + {type_town_label_5e2,500}, + {type_town_label_1e3,1000}, + {type_town_label_2e3,2000}, + {type_town_label_5e3,5000}, + {type_town_label_1e4,10000}, + {type_town_label_2e4,20000}, + {type_town_label_5e4,50000}, + {type_town_label_1e5,100000}, + {type_town_label_2e5,200000}, + {type_town_label_5e5,500000}, + {type_town_label_1e6,1000000}, + {type_town_label_2e6,2000000}, + {type_town_label_5e6,5000000}, + {type_town_label_1e7,1000000}, +}; + +static struct population_table district_population[] = { + {type_district_label_0e0,0}, + {type_district_label_1e0,1}, + {type_district_label_2e0,2}, + {type_district_label_5e0,5}, + {type_district_label_1e1,10}, + {type_district_label_2e1,20}, + {type_district_label_5e1,50}, + {type_district_label_1e2,100}, + {type_district_label_2e2,200}, + {type_district_label_5e2,500}, + {type_district_label_1e3,1000}, + {type_district_label_2e3,2000}, + {type_district_label_5e3,5000}, + {type_district_label_1e4,10000}, + {type_district_label_2e4,20000}, + {type_district_label_5e4,50000}, + {type_district_label_1e5,100000}, + {type_district_label_2e5,200000}, + {type_district_label_5e5,500000}, + {type_district_label_1e6,1000000}, + {type_district_label_2e6,2000000}, + {type_district_label_5e6,5000000}, + {type_district_label_1e7,1000000}, +}; + +void +item_bin_set_type_by_population(struct item_bin *ib, int population) +{ + struct population_table *table; + int i,count; + + if (population < 0) + population=0; + if (item_is_district(*item_bin)) { + table=district_population; + count=sizeof(district_population)/sizeof(district_population[0]); + } else { + table=town_population; + count=sizeof(town_population)/sizeof(town_population[0]); + } + for (i = 0 ; i < count ; i++) { + if (population < table[i].population) + break; + } + item_bin_set_type(ib, table[i-1].type); +} |