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++)
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;
} 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;
}
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;
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);
+}
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
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 {
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);
+ }
}