2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
25 #include "projection.h"
30 #include "transform.h"
39 struct search_list_level {
41 struct search_list_common *parent;
45 struct mapset_search *search;
47 GList *list,*curr,*last;
50 struct interpolation {
52 char *first, *last, *curr;
59 struct search_list_level levels[4];
60 struct search_list_result result;
61 struct search_list_result last_result;
62 int last_result_valid;
64 struct interpolation inter;
68 search_item_hash_hash(gconstpointer key)
70 const struct item *itm=key;
71 gconstpointer hashkey=(gconstpointer)GINT_TO_POINTER(itm->id_hi^itm->id_lo);
72 return g_direct_hash(hashkey);
76 search_item_hash_equal(gconstpointer a, gconstpointer b)
78 const struct item *itm_a=a;
79 const struct item *itm_b=b;
80 if (item_is_equal_id(*itm_a, *itm_b))
86 search_list_new(struct mapset *ms)
88 struct search_list *ret;
90 ret=g_new0(struct search_list, 1);
96 static void search_list_search_free(struct search_list *sl, int level);
99 search_list_level(enum attr_type attr_type)
102 case attr_country_all:
103 case attr_country_id:
104 case attr_country_iso2:
105 case attr_country_iso3:
106 case attr_country_car:
107 case attr_country_name:
109 case attr_town_postal:
112 case attr_district_name:
113 case attr_town_or_district_name:
115 case attr_street_name:
117 case attr_house_number:
122 dbg(0,"unknown search '%s'\n",attr_to_name(attr_type));
128 interpolation_clear(struct interpolation *inter)
130 inter->mode=inter->side=0;
131 g_free(inter->first);
134 inter->first=inter->last=inter->curr=NULL;
138 search_list_search(struct search_list *this_, struct attr *search_attr, int partial)
140 struct search_list_level *le;
141 int level=search_list_level(search_attr->type);
143 interpolation_clear(&this_->inter);
144 //dbg(0,"level=%d\n", level);
148 le=&this_->levels[level];
149 search_list_search_free(this_, level);
150 le->attr=attr_dup(search_attr);
153 le=&this_->levels[level-1];
156 //dbg(0,"le=%p partial=%d\n", le, partial);
157 } else if (search_attr->type == attr_postal) {
158 g_free(this_->postal);
159 this_->postal=g_strdup(search_attr->u.str);
163 struct search_list_common *
164 search_list_select(struct search_list *this_, enum attr_type attr_type, int id, int mode)
166 int level=search_list_level(attr_type);
168 struct search_list_level *le;
169 struct search_list_common *slc;
171 le=&this_->levels[level];
175 //dbg(0,"enter level=%d %d %d %p\n", level, id, mode, curr);
178 if (! id || num == id) {
187 curr=g_list_next(curr);
189 //dbg(0,"not found\n");
194 search_list_common_new(struct item *item, struct search_list_common *common)
197 if (item_attr_get(item, attr_town_name, &attr))
198 common->town_name=map_convert_string(item->map, attr.u.str);
200 common->town_name=NULL;
201 if (item_attr_get(item, attr_county_name, &attr))
202 common->county_name=map_convert_string(item->map, attr.u.str);
204 common->county_name=NULL;
205 if (item_attr_get(item, attr_district_name, &attr))
206 common->district_name=map_convert_string(item->map, attr.u.str);
208 common->district_name=NULL;
209 if (item_attr_get(item, attr_postal, &attr))
210 common->postal=map_convert_string(item->map, attr.u.str);
211 else if (item_attr_get(item, attr_town_postal, &attr))
212 common->postal=map_convert_string(item->map, attr.u.str);
215 if (item_attr_get(item, attr_postal_mask, &attr))
216 common->postal_mask=map_convert_string(item->map, attr.u.str);
218 common->postal_mask=NULL;
222 search_list_common_destroy(struct search_list_common *common)
224 map_convert_free(common->town_name);
225 map_convert_free(common->district_name);
226 map_convert_free(common->county_name);
227 map_convert_free(common->postal);
228 map_convert_free(common->postal_mask);
231 static struct search_list_country *
232 search_list_country_new(struct item *item)
234 struct search_list_country *ret=g_new0(struct search_list_country, 1);
237 ret->common.item=ret->common.unique=*item;
238 if (item_attr_get(item, attr_country_car, &attr))
239 ret->car=g_strdup(attr.u.str);
240 if (item_attr_get(item, attr_country_iso2, &attr)) {
242 ret->iso2=g_malloc(strlen(attr.u.str)+1);
243 strtolower(ret->iso2, attr.u.str);
245 ret->iso2=g_strdup(attr.u.str);
247 ret->flag=g_strdup_printf("country_%s", ret->iso2);
249 if (item_attr_get(item, attr_country_iso3, &attr))
250 ret->iso3=g_strdup(attr.u.str);
251 if (item_attr_get(item, attr_country_name, &attr))
252 ret->name=g_strdup(attr.u.str);
257 search_list_country_destroy(struct search_list_country *this_)
267 static struct search_list_town *
268 search_list_town_new(struct item *item)
270 struct search_list_town *ret=g_new0(struct search_list_town, 1);
275 ret->common.item=ret->common.unique=*item;
276 if (item_attr_get(item, attr_town_streets_item, &attr)) {
277 dbg(1,"town_assoc 0x%x 0x%x\n", attr.u.item->id_hi, attr.u.item->id_lo);
278 ret->common.unique=*attr.u.item;
280 search_list_common_new(item, &ret->common);
281 if (item_attr_get(item, attr_county_name, &attr))
282 ret->county=map_convert_string(item->map,attr.u.str);
285 if (item_coord_get(item, &c, 1)) {
286 ret->common.c=g_new(struct pcoord, 1);
287 ret->common.c->x=c.x;
288 ret->common.c->y=c.y;
289 ret->common.c->pro = map_projection(item->map);
295 search_list_town_destroy(struct search_list_town *this_)
297 map_convert_free(this_->county);
298 search_list_common_destroy(&this_->common);
300 g_free(this_->common.c);
305 static struct search_list_street *
306 search_list_street_new(struct item *item)
308 struct search_list_street *ret=g_new0(struct search_list_street, 1);
312 ret->common.item=ret->common.unique=*item;
313 if (item_attr_get(item, attr_street_name, &attr))
314 ret->name=map_convert_string(item->map, attr.u.str);
317 search_list_common_new(item, &ret->common);
318 if (item_coord_get(item, &c, 1)) {
319 ret->common.c=g_new(struct pcoord, 1);
320 ret->common.c->x=c.x;
321 ret->common.c->y=c.y;
322 ret->common.c->pro = map_projection(item->map);
329 search_list_street_destroy(struct search_list_street *this_)
331 map_convert_free(this_->name);
332 search_list_common_destroy(&this_->common);
335 g_free(this_->common.c);
341 search_interpolate(struct interpolation *inter)
343 dbg(1,"interpolate %s-%s %s\n",inter->first,inter->last,inter->curr);
344 if (!inter->first || !inter->last)
347 inter->curr=g_strdup(inter->first);
349 if (strcmp(inter->curr, inter->last)) {
350 int next=atoi(inter->curr)+(inter->mode?2:1);
352 if (next == atoi(inter->last))
353 inter->curr=g_strdup(inter->last);
355 inter->curr=g_strdup_printf("%d",next);
361 dbg(1,"interpolate result %s\n",inter->curr);
366 search_interpolation_split(char *str, struct interpolation *inter)
368 char *pos=strchr(str,'-');
372 inter->first=g_strdup(str);
373 inter->last=g_strdup(str);
378 first=g_malloc(len+1);
379 strncpy(first, str, len);
381 last=g_strdup(pos+1);
382 dbg(1,"%s = %s - %s\n",str, first, last);
383 if (atoi(first) > atoi(last)) {
395 search_setup_interpolation(struct item *item, enum attr_type i0, enum attr_type i1, enum attr_type i2, struct interpolation *inter)
398 g_free(inter->first);
401 inter->first=inter->last=inter->curr=NULL;
402 dbg(1,"setup %s\n",attr_to_name(i0));
403 if (item_attr_get(item, i0, &attr)) {
404 search_interpolation_split(attr.u.str, inter);
406 } else if (item_attr_get(item, i1, &attr)) {
407 search_interpolation_split(attr.u.str, inter);
409 } else if (item_attr_get(item, i2, &attr)) {
410 search_interpolation_split(attr.u.str, inter);
418 search_match(char *str, char *search, int partial)
421 return (!g_strcasecmp(str, search));
423 return (!g_strncasecmp(str, search, strlen(search)));
426 static struct pcoord *
427 search_house_number_coordinate(struct item *item, struct interpolation *inter)
429 struct pcoord *ret=g_new(struct pcoord, 1);
430 ret->pro = map_projection(item->map);
431 dbg(0,"%s\n",item_to_name(item->type));
432 if (item->type<type_house_number_interpolation_even || item->type>type_house_number_interpolation_alphabetic) {
434 if (item_coord_get(item, &c, 1)) {
443 int hn_pos,hn_length;
444 struct coord *c=g_alloca(sizeof(struct coord)*max);
445 item_coord_rewind(item);
446 count=item_coord_get(item, c, max);
447 hn_length=atoi(inter->last)-atoi(inter->first);
449 hn_pos=atoi(inter->last)-atoi(inter->curr);
451 hn_pos=atoi(inter->curr)-atoi(inter->first);
453 int i,distance_sum=0,hn_distance;
454 int *distances=g_alloca(sizeof(int)*(count-1));
455 dbg(1,"count=%d hn_length=%d hn_pos=%d (%s of %s-%s)\n",count,hn_length,hn_pos,inter->curr,inter->first,inter->last);
461 dbg(0,"coordinate overflow\n");
462 for (i = 0 ; i < count-1 ; i++) {
463 distances[i]=navit_sqrt(transform_distance_sq(&c[i],&c[i+1]));
464 distance_sum+=distances[i];
465 dbg(1,"distance[%d]=%d\n",i,distances[i]);
467 dbg(1,"sum=%d\n",distance_sum);
468 hn_distance=distance_sum*hn_pos/hn_length;
469 dbg(1,"hn_distance=%d\n",hn_distance);
471 while (i < count-1 && hn_distance > distances[i])
472 hn_distance-=distances[i++];
473 dbg(1,"remaining distance=%d from %d\n",hn_distance,distances[i]);
474 ret->x=(c[i+1].x-c[i].x)*hn_distance/distances[i]+c[i].x;
475 ret->y=(c[i+1].y-c[i].y)*hn_distance/distances[i]+c[i].y;
483 static struct search_list_house_number *
484 search_list_house_number_new(struct item *item, struct interpolation *inter, char *inter_match, int inter_partial)
486 struct search_list_house_number *ret=g_new0(struct search_list_house_number, 1);
490 ret->common.item=ret->common.unique=*item;
491 //if (item_attr_get(item, attr_street_name, &attr))
492 // dbg(0,"xx1 %s\n",attr.u.str);
493 if (item_attr_get(item, attr_house_number, &attr))
494 ret->house_number=map_convert_string(item->map, attr.u.str);
496 //if (item_attr_get(item, attr_street_name, &attr))
497 // dbg(0,"xx2 %s\n",attr.u.str);
499 //dbg(0,"interpolate 11");
500 ret->interpolation=1;
501 switch(inter->side) {
503 //dbg(0,"interpolate 11 0");
505 search_setup_interpolation(item, attr_house_number_left, attr_house_number_left_odd, attr_house_number_left_even, inter);
507 //dbg(0,"interpolate 11 -1");
508 if ((hn=search_interpolate(inter)))
511 search_setup_interpolation(item, attr_house_number_right, attr_house_number_right_odd, attr_house_number_right_even, inter);
513 //dbg(0,"interpolate 11 1");
514 if ((hn=search_interpolate(inter)))
517 //dbg(0,"interpolate 11 default");
521 if (search_match(hn, inter_match, inter_partial))
523 //dbg(0,"interpolate 22");
524 //dbg(0,"match %s %s-%s\n",hn, inter->first, inter->last);
525 ret->house_number=map_convert_string(item->map, hn);
530 //dbg(0,"interpolate 33");
531 search_list_common_new(item, &ret->common);
532 ret->common.c=search_house_number_coordinate(item, ret->interpolation?inter:NULL);
533 //dbg(0,"interpolate 44");
538 search_list_house_number_destroy(struct search_list_house_number *this_)
540 map_convert_free(this_->house_number);
541 search_list_common_destroy(&this_->common);
543 g_free(this_->common.c);
548 search_list_result_destroy(int level, void *p)
552 search_list_country_destroy(p);
555 search_list_town_destroy(p);
558 search_list_street_destroy(p);
561 search_list_house_number_destroy(p);
567 search_list_search_free(struct search_list *sl, int level)
569 struct search_list_level *le=&sl->levels[level];
573 mapset_search_destroy(le->search);
578 g_hash_table_destroy(le->hash);
585 search_list_result_destroy(level, curr->data);
586 next=g_list_next(curr);
590 g_list_free(le->list);
597 search_postal_merge(char *mask, char *new)
601 dbg(1,"enter %s %s\n", mask, new);
605 return g_strdup(new);
607 while (mask[i] && new[i]) {
608 if (mask[i] != '.' && mask[i] != new[i])
618 dbg(1,"merged %s with %s as %s\n", mask, new, ret);
623 search_postal_merge_replace(char *mask, char *new)
625 char *ret=search_postal_merge(mask, new);
634 postal_match(char *postal, char *mask)
637 if ((*postal != *mask) && (*mask != '.'))
651 search_add_result(struct search_list_level *le, struct search_list_common *slc)
653 struct search_list_common *slo;
655 slo=g_hash_table_lookup(le->hash, &slc->unique);
657 g_hash_table_insert(le->hash, &slc->unique, slc);
658 if (slc->postal && !slc->postal_mask) {
659 slc->postal_mask=g_strdup(slc->postal);
661 le->list=g_list_append(le->list, slc);
664 merged=search_postal_merge(slo->postal_mask, slc->postal);
666 g_free(slo->postal_mask);
667 slo->postal_mask=merged;
672 struct search_list_result *
673 search_list_get_result(struct search_list *this_)
675 struct search_list_level *le,*leu;
676 int level=this_->level;
678 int has_street_name=0;
681 le=&this_->levels[level];
682 //dbg(0,"le=%p\n", le);
685 //dbg(0,"le->search=%p\n", le->search);
688 //dbg(0,"partial=%d level=%d\n", le->partial, level);
693 leu=&this_->levels[level-1];
694 //dbg(0,"leu->curr=%p\n", leu->curr);
697 //dbg(0,"*********########");
699 struct search_list_common *slc;
704 le->parent=leu->curr->data;
706 leu->curr=g_list_next(leu->curr);
707 slc=(struct search_list_common *)(le->parent);
710 if (slc->selected == leu->selected)
716 //dbg(0,"mapset_search_new with item(%d,%d)\n", le->parent->item.id_hi, le->parent->item.id_lo);
718 //dbg(0,"############## attr=%s\n", attr_to_name(le->attr->type));
719 le->search=mapset_search_new(this_->ms, &le->parent->item, le->attr, le->partial);
720 le->hash=g_hash_table_new(search_item_hash_hash, search_item_hash_equal);
722 //dbg(0,"le->search=%p\n", le->search);
726 this_->item=mapset_search_get_item(le->search);
727 //dbg(0,"sssss 1 %p\n",this_->item);
732 //dbg(0,"id_hi=%d id_lo=%d\n", this_->item->id_hi, this_->item->id_lo);
736 if (item_attr_get(this_->item, attr_postal_mask, &postal)) {
737 if (!postal_match(this_->postal, postal.u.str))
739 } else if (item_attr_get(this_->item, attr_postal, &postal)) {
740 if (strcmp(this_->postal, postal.u.str))
744 this_->result.country=NULL;
745 this_->result.town=NULL;
746 this_->result.street=NULL;
747 this_->result.c=NULL;
748 //dbg(0,"case x LEVEL start %d\n",level);
752 //dbg(0,"case 0 COUNTRY");
753 p=search_list_country_new(this_->item);
754 this_->result.country=p;
755 this_->result.country->common.parent=NULL;
759 //dbg(0,"case 1 TOWN");
760 p=search_list_town_new(this_->item);
761 this_->result.town=p;
762 this_->result.town->common.parent=this_->levels[0].last->data;
763 this_->result.country=this_->result.town->common.parent;
764 this_->result.c=this_->result.town->common.c;
768 //dbg(0,"case 2 STREET");
769 p=search_list_street_new(this_->item);
770 this_->result.street=p;
771 this_->result.street->common.parent=this_->levels[1].last->data;
772 this_->result.town=this_->result.street->common.parent;
773 this_->result.country=this_->result.town->common.parent;
774 this_->result.c=this_->result.street->common.c;
778 dbg(1,"case 3 HOUSENUMBER\n");
781 // if this housenumber has a streetname tag, set the name now
782 if (item_attr_get(this_->item, attr_street_name, &attr2))
784 dbg(1,"streetname: %s\n",attr2.u.str);
788 p=search_list_house_number_new(this_->item, &this_->inter, le->attr->u.str, le->partial);
791 interpolation_clear(&this_->inter);
796 this_->result.house_number=p;
797 if (!this_->result.house_number->interpolation)
801 dbg(0,"interpolation!\n");
804 if(le->parent && has_street_name) {
805 struct search_list_street *street=this_->levels[level-1].last->data;
808 s1=g_utf8_casefold(street->name,-1);
809 s2=g_utf8_casefold(attr2.u.str,-1);
810 cmpres=strcmp(s1,s2);
811 dbg(1,"Compared %s with %s, got %d\n",s1,s2,cmpres);
815 search_list_house_number_destroy(p);
822 this_->result.house_number->common.parent=this_->levels[2].last->data;
823 this_->result.street=this_->result.house_number->common.parent;
824 this_->result.town=this_->result.street->common.parent;
825 this_->result.country=this_->result.town->common.parent;
826 this_->result.c=this_->result.house_number->common.c;
828 if(!has_street_name) {
829 static struct search_list_street null_street;
830 this_->result.street=&null_street;
835 if (search_add_result(le, p))
838 return &this_->result;
842 search_list_result_destroy(level, p);
846 mapset_search_destroy(le->search);
848 g_hash_table_destroy(le->hash);
857 search_list_destroy(struct search_list *this_)
859 g_free(this_->postal);
870 search_fix_spaces(const char *str)
874 char c,*s,*d,*ret=g_strdup(str);
876 for (i = 0 ; i < len ; i++) {
877 if (ret[i] == ',' || ret[i] == ',' || ret[i] == '/')
885 if (c != ' ' || len != 0) {
889 while (c == ' ' && *s == ' ')
891 if (c == ' ' && *s == '\0') {
900 search_split_phrases(char *str)
908 ret=g_list_append(ret, g_strdup(s));
912 ret=g_list_append(ret, g_strdup(tmp));
923 } while (*s != '\0');
924 } while (*s != '\0');
929 search_address_housenumber_real(GList *result_list, struct search_list *sl, char *street_name, GList *phrases, GList *exclude1, GList *exclude2, GList *exclude3, int partial, struct jni_object *jni)
931 // here we search actually for the housenumber
932 struct search_list_result *slr;
936 dbg(1,"street:%s\n",street_name);
937 while ((slr=search_list_get_result(sl)))
939 // does the streetname of the housenumber match the street we want?
940 if (slr->street != NULL)
941 if ((street_name != NULL)&&(slr->street->name != NULL))
943 //dbg(0,"ffffff 1.1 %s %s",street_name,slr->street->name);
944 if (strcmp(slr->street->name, street_name)==0)
948 c.x=slr->house_number->common.c->x;
949 c.y=slr->house_number->common.c->y;
950 transform_to_geo(slr->house_number->common.c->pro, &c, &g);
951 //dbg(0,"g=%f %f\n",g.lat,g.lng);
952 //dbg(0,"###### Result with housenumber: streetname=%s\n",slr->street->name);
953 //dbg(0,"###### Result with housenumber: %s %s(%s) %s %s\n",slr->house_number->common.postal,slr->house_number->common.town_name, slr->house_number->common.district_name,slr->street->name,slr->house_number->house_number);
954 // SHN -> street with house number
955 // return a string like: "SHN:H111L5555:16.766:48.76:full address name is at the end"
956 // ca. 9 chars : ca. 9 chars : max. 100 max. 100 max. 100 max. 15 chars -> this sould be max. about 335 chars long
957 if (slr->town->common.postal == NULL)
959 buffer=g_strdup_printf("SHN:H%dL%d:%f:%f:%.101s, %.101s, %.101s %.15s",slr->street->common.item.id_hi,slr->street->common.item.id_lo,g.lat,g.lng,slr->country->name,slr->town->common.town_name,slr->street->name,slr->house_number->house_number);
963 buffer=g_strdup_printf("SHN:H%dL%d:%f:%f:%.101s, %.7s %.101s, %.101s %.15s",slr->street->common.item.id_hi,slr->street->common.item.id_lo,g.lat,g.lng,slr->country->name,slr->town->common.postal,slr->town->common.town_name,slr->street->name,slr->house_number->house_number);
965 // deactivated now * result_list=g_list_prepend(result_list,g_strdup(buffer));
966 #ifdef HAVE_API_ANDROID
967 // return results to android as they come in ...
968 android_return_search_result(jni,buffer);
979 search_address_housenumber(GList *result_list, struct search_list *sl, GList *phrases, GList *exclude1, GList *exclude2, GList *exclude3, int partial, struct jni_object *jni)
982 // this is actually "street search" and "housenumber search" is at the bottom of this function
984 // housenumbers are not found as of now (2011-02-28)
988 struct search_list_result *slr;
995 attr.type=attr_street_name;
996 while ((slr=search_list_get_result(sl)))
999 //dbg(0,"%p %p\n",slr->country,slr->town);
1000 //dbg(0,"%p\n",slr->street);
1001 // dbg(0,"###### Result without housenumber: country=%s country_name=%s town=%s street=%s\n",slr->country->iso2,slr->country->name,slr->town->common.town_name,slr->street->name);
1002 //dbg(0,"###### Result without housenumber: postal:%s\n",slr->town->common.postal);
1003 //dbg(0,"###### Result without housenumber: postal_mask:%s\n",slr->town->common.postal_mask);
1004 //dbg(0,"###### Result without housenumber: STR postal:%s\n",slr->street->common.postal);
1005 //dbg(0,"###### Result without housenumber: STR postal_mask:%s\n",slr->street->common.postal_mask);
1006 //dbg(0,"###### Result without housenumber: item id_hi:%d id_lo:%d\n",slr->street->common.item.id_hi,slr->street->common.item.id_lo);
1009 c.x=slr->street->common.c->x;
1010 c.y=slr->street->common.c->y;
1011 transform_to_geo(slr->street->common.c->pro, &c, &g);
1012 //dbg(0,"g=%f %f\n",g.lat,g.lng);
1016 // return a string like: "STR:H1111L5555:16.766:-48.76:full address name is at the end"
1017 // ca. 9 chars : ca. 9 chars : max. 100 max. 100 max. 100 chars -> this sould be max. about 320 chars long
1018 if (slr->town->common.postal == NULL)
1020 buffer=g_strdup_printf("STR:H%dL%d:%f:%f:%.101s,%.101s, %.101s",slr->street->common.item.id_hi,slr->street->common.item.id_lo,g.lat,g.lng,slr->country->name,slr->town->common.town_name,slr->street->name);
1024 buffer=g_strdup_printf("STR:H%dL%d:%f:%f:%.101s,%.7s %.101s, %.101s",slr->street->common.item.id_hi,slr->street->common.item.id_lo,g.lat,g.lng,slr->country->name,slr->town->common.postal,slr->town->common.town_name,slr->street->name);
1026 // deactivated now * result_list=g_list_prepend(result_list,g_strdup(buffer));
1028 #ifdef HAVE_API_ANDROID
1029 // return results to android as they come in ...
1030 android_return_search_result(jni,buffer);
1036 if (tmp != exclude1 && tmp != exclude2 && tmp != exclude3 && slr->street)
1038 attr2.type=attr_house_number;
1039 attr2.u.str=tmp->data;
1040 search_list_search(sl, &attr2, partial);
1041 //dbg(0,"hn str=%s\n",attr2.u.str);
1042 result_list=search_address_housenumber_real(result_list, sl, slr->street->name, phrases, exclude1, exclude2, exclude3, partial, jni);
1044 tmp=g_list_next(tmp);
1056 search_address_street(GList *result_list, struct search_list *sl, GList *phrases, GList *exclude1, GList *exclude2, int partial, struct jni_object *jni)
1059 // this is actually "town search" !!
1062 struct search_list_result *slr;
1068 attr.type=attr_street_name;
1069 while ((slr=search_list_get_result(sl)))
1072 //dbg(0,"##### sss1");
1073 // dbg(0,"###### Result town: country=%s country_name=%s town=%s",slr->country->iso2,slr->country->name,slr->town->common.town_name);
1074 // dbg(0,"###### Result town: postal=%s postal_mask=%s",slr->town->common.postal,slr->town->common.postal_mask);
1077 c.x=slr->town->common.c->x;
1078 c.y=slr->town->common.c->y;
1079 transform_to_geo(slr->town->common.c->pro, &c, &g);
1082 if (slr->town->common.postal == NULL)
1084 buffer=g_strdup_printf("TWN:H%dL%d:%f:%f:%.101s, %.101s",slr->town->common.item.id_hi,slr->town->common.item.id_lo,g.lat,g.lng,slr->country->name,slr->town->common.town_name);
1088 buffer=g_strdup_printf("TWN:H%dL%d:%f:%f:%.101s, %.7s %.101s",slr->town->common.item.id_hi,slr->town->common.item.id_lo,g.lat,g.lng,slr->country->name,slr->town->common.postal,slr->town->common.town_name);
1090 // deactivated now * result_list=g_list_prepend(result_list,g_strdup(buffer));
1091 #ifdef HAVE_API_ANDROID
1092 // return results to android as they come in ...
1093 android_return_search_result(jni,buffer);
1098 dbg(0,"%s %s %s %s",slr->country->car,slr->town->name,slr->town->district,slr->street->name);
1101 dbg(0,"%s %s %s\n",slr->country->iso2,slr->town->county,slr->street->name);
1103 if (item_attr_get(&slr->town->itemt, attr_label, &attr77))
1105 dbg(0,"***search result T=%s",attr77.u.str);
1113 //dbg(0,"count %d\n",count);
1116 if (tmp != exclude1 && tmp != exclude2)
1118 attr.u.str=tmp->data;
1119 search_list_search(sl, &attr, partial);
1120 result_list=search_address_housenumber(result_list, sl, phrases, exclude1, exclude2, tmp, partial, jni);
1122 tmp=g_list_next(tmp);
1128 search_address_town(GList *result_list, struct search_list *sl, GList *phrases, GList *exclude, int partial, struct jni_object *jni)
1133 struct search_list_result *slr;
1135 attr.type=attr_town_or_district_name;
1136 while ((slr=search_list_get_result(sl)))
1142 //dbg(0,"count %d\n",count);
1147 attr.u.str=tmp->data;
1148 search_list_search(sl, &attr, partial);
1149 result_list=search_address_street(result_list, sl, phrases, exclude, tmp, partial, jni);
1151 tmp=g_list_next(tmp);
1158 search_by_address(struct search_list *sl, const char *addr, int partial, struct jni_object *jni)
1160 char *str=search_fix_spaces(addr);
1161 GList *phrases=search_split_phrases(str);
1163 dbg(0,"enter %s\n",addr);
1164 ret=search_address_town(ret, sl, phrases, NULL, partial, jni);
1167 dbg(0,"leave %p\n",ret);