From a28a638afcedb365320a918d8586ba0da3f5d78f Mon Sep 17 00:00:00 2001 From: martin-s Date: Tue, 9 Nov 2010 17:19:19 +0000 Subject: [PATCH] Add:Core:Support for querying map release git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3667 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/attr_def.h | 1 + navit/navit/map.c | 7 ++++++- navit/navit/map/binfile/binfile.c | 29 +++++++++++++++++++++++++++-- navit/navit/maptool/maptool.h | 1 + navit/navit/maptool/tile.c | 11 ++++++++++- 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/navit/navit/attr_def.h b/navit/navit/attr_def.h index 05dfeb9..83925c6 100644 --- a/navit/navit/attr_def.h +++ b/navit/navit/attr_def.h @@ -314,6 +314,7 @@ ATTR(house_number_left_even) ATTR(house_number_right) ATTR(house_number_right_odd) ATTR(house_number_right_even) +ATTR(map_release) ATTR2(0x0003ffff,type_string_end) ATTR2(0x00040000,type_special_begin) ATTR(order) diff --git a/navit/navit/map.c b/navit/navit/map.c index 4a09820..bd404bd 100644 --- a/navit/navit/map.c +++ b/navit/navit/map.c @@ -129,7 +129,12 @@ map_new(struct attr *parent, struct attr **attrs) int map_get_attr(struct map *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter) { - return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter); + int ret=0; + if (this_->meth.map_get_attr) + ret=this_->meth.map_get_attr(this_->priv, type, attr); + if (!ret) + ret=attr_generic_get_attr(this_->attrs, NULL, type, attr, iter); + return ret; } /** diff --git a/navit/navit/map/binfile/binfile.c b/navit/navit/map/binfile/binfile.c index ef2c07d..5f20c67 100644 --- a/navit/navit/map/binfile/binfile.c +++ b/navit/navit/map/binfile/binfile.c @@ -71,6 +71,7 @@ struct map_priv { int map_version; GHashTable *changes; char *passwd; + char *map_release; }; struct map_rect_priv { @@ -1511,6 +1512,7 @@ binmap_search_get_item(struct map_search_priv *map_search) } } + static void binmap_search_destroy(struct map_search_priv *ms) { @@ -1523,6 +1525,23 @@ binmap_search_destroy(struct map_search_priv *ms) g_free(ms); } +static int +binmap_get_attr(struct map_priv *m, enum attr_type type, struct attr *attr) +{ + attr->type=type; + switch (type) { + case attr_map_release: + if (m->map_release) { + attr->u.str=m->map_release; + return 1; + } + break; + default: + break; + } + return 0; +} + static struct map_methods map_methods_binfile = { projection_mg, "utf-8", @@ -1533,7 +1552,9 @@ static struct map_methods map_methods_binfile = { map_rect_get_item_byid_binfile, binmap_search_new, binmap_search_destroy, - binmap_search_get_item + binmap_search_get_item, + NULL, + binmap_get_attr, }; static int @@ -1634,9 +1655,12 @@ map_binfile_open(struct map_priv *m) mr=map_rect_new_binfile(m, NULL); if (mr) { item=map_rect_get_item_binfile(mr); - if (item && item->type == type_map_information) + if (item && item->type == type_map_information) { if (binfile_attr_get(item->priv_data, attr_version, &attr)) m->map_version=attr.u.num; + if (binfile_attr_get(item->priv_data, attr_map_release, &attr)) + m->map_release=g_strdup(attr.u.str); + } map_rect_destroy_binfile(mr); if (m->map_version >= 16) { dbg(0,"Warning: This map is incompatible with your navit version. Please update navit.\n"); @@ -1653,6 +1677,7 @@ map_binfile_close(struct map_priv *m) file_data_free(m->fi, (unsigned char *)m->eoc); file_data_free(m->fi, (unsigned char *)m->eoc64); g_free(m->cachedir); + g_free(m->map_release); file_destroy(m->fi); } diff --git a/navit/navit/maptool/maptool.h b/navit/navit/maptool/maptool.h index 39ab797..bfe1923 100644 --- a/navit/navit/maptool/maptool.h +++ b/navit/navit/maptool/maptool.h @@ -273,6 +273,7 @@ int write_aux_tiles(struct zip_info *zip_info); int create_tile_hash(void); void write_tilesdir(struct tile_info *info, struct zip_info *zip_info, FILE *out); void merge_tiles(struct tile_info *info); +struct attr map_information_attrs[32]; void index_init(struct zip_info *info, int version); void index_submap_add(struct tile_info *info, struct tile_head *th); diff --git a/navit/navit/maptool/tile.c b/navit/navit/maptool/tile.c index 8101644..203f228 100644 --- a/navit/navit/maptool/tile.c +++ b/navit/navit/maptool/tile.c @@ -590,12 +590,21 @@ merge_tiles(struct tile_info *info) } while (work_done); } +struct attr map_information_attrs[32]; + void index_init(struct zip_info *info, int version) { struct item_bin *item_bin; + int i; + map_information_attrs[0].type=attr_version; + map_information_attrs[0].u.num=version; item_bin=init_item(type_map_information); - item_bin_add_attr_int(item_bin, attr_version, version); + for (i = 0 ; i < 32 ; i++) { + if (!map_information_attrs[i].type) + break; + item_bin_add_attr(item_bin, &map_information_attrs[i]); + } item_bin_write(item_bin, info->index); } -- 2.7.4