diff options
-rw-r--r-- | navit/data/binfile/binfile.c | 12 | ||||
-rw-r--r-- | navit/map.c | 31 | ||||
-rw-r--r-- | navit/map.h | 2 | ||||
-rw-r--r-- | navit/mapset.c | 10 |
4 files changed, 48 insertions, 7 deletions
diff --git a/navit/data/binfile/binfile.c b/navit/data/binfile/binfile.c index 51508cc65..96cb3a1f5 100644 --- a/navit/data/binfile/binfile.c +++ b/navit/data/binfile/binfile.c @@ -471,6 +471,10 @@ binmap_search_new(struct map_priv *map, struct item *item, struct attr *search, case attr_town_postal: break; case attr_street_name: + if (! item->map) + break; + if (!map_priv_is(item->map, map)) + break; ms = g_new(struct map_selection, 1); ms->next = NULL; for (i = 0; i < layer_end; i++) @@ -488,10 +492,10 @@ binmap_search_new(struct map_priv *map, struct item *item, struct attr *search, size = 10000; break; case type_town_label_2e4: - size = 2500; + size = 5000; break; case type_town_label_2e3: - size = 1000; + size = 2500; break; case type_town_label_2e2: size = 1000; @@ -547,9 +551,11 @@ binmap_search_get_item(struct map_search_priv *map_search) } else if (map_search->search->type == attr_street_name) { if ((it->type == type_street_3_city) || (it->type == type_street_2_city) || (it->type == type_street_1_city)) { struct attr at; - if (binfile_attr_get(it->priv_data, attr_label, &at)) { + if (map_selection_contains_item_rect(map_search->mr->sel, it) && binfile_attr_get(it->priv_data, attr_label, &at)) { if (!ascii_cmp(at.u.str, map_search->search->u.str, map_search->partial)) { if (!g_hash_table_lookup(map_search->search_results, at.u.str)) { + item_coord_rewind(it); + item_attr_rewind(it); g_hash_table_insert(map_search->search_results, g_strdup(at.u.str), ""); return it; } diff --git a/navit/map.c b/navit/map.c index a5198df3a..5c5813268 100644 --- a/navit/map.c +++ b/navit/map.c @@ -184,6 +184,10 @@ map_search_new(struct map *m, struct item *item, struct attr *search_attr, int p if (m->meth.charset) this_->search_attr.u.str=g_convert(this_->search_attr.u.str, -1,m->meth.charset,"utf-8",NULL,NULL,NULL); this_->priv=m->meth.map_search_new(m->priv, item, &this_->search_attr, partial); + if (! this_->priv) { + g_free(this_); + this_=NULL; + } } else { g_free(this_); this_=NULL; @@ -248,3 +252,30 @@ map_selection_destroy(struct map_selection *sel) sel = next; } } + +int +map_selection_contains_item_rect(struct map_selection *sel, struct item *item) +{ + struct coord c; + struct coord_rect r; + int count=0; + while (item_coord_get(item, &c, 1)) { + if (! count) { + r.lu=c; + r.rl=c; + } else + coord_rect_extend(&r, &c); + count++; + } + if (! count) + return 0; + return map_selection_contains_rect(sel, &r); + +} + + +int +map_priv_is(struct map *map, struct map_priv *priv) +{ + return (map->priv == priv); +} diff --git a/navit/map.h b/navit/map.h index 1dcc28b17..3cf5d6d1d 100644 --- a/navit/map.h +++ b/navit/map.h @@ -152,6 +152,8 @@ struct item *map_search_get_item(struct map_search *this_); void map_search_destroy(struct map_search *this_); struct map_selection *map_selection_dup(struct map_selection *sel); void map_selection_destroy(struct map_selection *sel); +int map_selection_contains_item_rect(struct map_selection *sel, struct item *item); +int map_priv_is(struct map *map, struct map_priv *priv); /* end of prototypes */ #endif diff --git a/navit/mapset.c b/navit/mapset.c index 5c805cbb4..1d610e0fd 100644 --- a/navit/mapset.c +++ b/navit/mapset.c @@ -97,8 +97,8 @@ mapset_search_new(struct mapset *ms, struct item *item, struct attr *search_attr struct item * mapset_search_get_item(struct mapset_search *this) { - struct item *ret; - while (!(ret=map_search_get_item(this->ms))) { + struct item *ret=NULL; + while (!this->ms || !(ret=map_search_get_item(this->ms))) { if (this->search_attr->type >= attr_country_all && this->search_attr->type <= attr_country_name) break; do { @@ -115,6 +115,8 @@ mapset_search_get_item(struct mapset_search *this) void mapset_search_destroy(struct mapset_search *this) { - map_search_destroy(this->ms); - g_free(this); + if (this) { + map_search_destroy(this->ms); + g_free(this); + } } |