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 * @brief Create new instance of search_list to run a search.
88 * @param ms mapset that is to be searched
89 * @returns new search_list
92 search_list_new(struct mapset *ms)
94 struct search_list *ret;
96 ret=g_new0(struct search_list, 1);
102 static void search_list_search_free(struct search_list *sl, int level);
105 * @brief Determine search list level for given attr_type.
106 * @param attr_type attribute value
107 * @return corresponding search list level (country=0, town=1, ...)
110 search_list_level(enum attr_type attr_type)
113 case attr_country_all:
114 case attr_country_id:
115 case attr_country_iso2:
116 case attr_country_iso3:
117 case attr_country_car:
118 case attr_country_name:
120 case attr_town_postal:
123 case attr_district_name:
124 case attr_town_or_district_name:
126 case attr_street_name:
128 case attr_house_number:
133 dbg(0,"unknown search '%s'\n",attr_to_name(attr_type));
139 interpolation_clear(struct interpolation *inter)
141 inter->mode=inter->side=0;
142 g_free(inter->first);
145 inter->first=inter->last=inter->curr=NULL;
149 * @brief Start a search.
151 * @param this search_list to use for the search
152 * @param search_attr attributes to use for the search
153 * @param partial do partial search? (1=yes,0=no)
156 search_list_search(struct search_list *this_, struct attr *search_attr, int partial)
158 struct search_list_level *le;
159 int level=search_list_level(search_attr->type);
161 interpolation_clear(&this_->inter);
162 //dbg(0,"level=%d\n", level);
166 le=&this_->levels[level];
167 search_list_search_free(this_, level);
168 le->attr=attr_dup(search_attr);
171 le=&this_->levels[level-1];
174 //dbg(0,"le=%p partial=%d\n", le, partial);
175 } else if (search_attr->type == attr_postal) {
176 g_free(this_->postal);
177 this_->postal=g_strdup(search_attr->u.str);
181 struct search_list_common *
182 search_list_select(struct search_list *this_, enum attr_type attr_type, int id, int mode)
184 int level=search_list_level(attr_type);
186 struct search_list_level *le;
187 struct search_list_common *slc;
189 le=&this_->levels[level];
193 //dbg(0,"enter level=%d %d %d %p\n", level, id, mode, curr);
196 if (! id || num == id) {
205 curr=g_list_next(curr);
207 //dbg(0,"not found\n");
212 search_list_common_new(struct item *item, struct search_list_common *common)
215 if (item_attr_get(item, attr_town_name, &attr))
216 common->town_name=map_convert_string(item->map, attr.u.str);
218 common->town_name=NULL;
219 if (item_attr_get(item, attr_county_name, &attr))
220 common->county_name=map_convert_string(item->map, attr.u.str);
222 common->county_name=NULL;
223 if (item_attr_get(item, attr_district_name, &attr))
224 common->district_name=map_convert_string(item->map, attr.u.str);
226 common->district_name=NULL;
227 if (item_attr_get(item, attr_postal, &attr))
228 common->postal=map_convert_string(item->map, attr.u.str);
229 else if (item_attr_get(item, attr_town_postal, &attr))
230 common->postal=map_convert_string(item->map, attr.u.str);
233 if (item_attr_get(item, attr_postal_mask, &attr))
234 common->postal_mask=map_convert_string(item->map, attr.u.str);
236 common->postal_mask=NULL;
240 search_list_common_destroy(struct search_list_common *common)
242 map_convert_free(common->town_name);
243 map_convert_free(common->district_name);
244 map_convert_free(common->county_name);
245 map_convert_free(common->postal);
246 map_convert_free(common->postal_mask);
249 static struct search_list_country *
250 search_list_country_new(struct item *item)
252 struct search_list_country *ret=g_new0(struct search_list_country, 1);
255 ret->common.item=ret->common.unique=*item;
256 if (item_attr_get(item, attr_country_car, &attr))
257 ret->car=g_strdup(attr.u.str);
258 if (item_attr_get(item, attr_country_iso2, &attr)) {
260 ret->iso2=g_malloc(strlen(attr.u.str)+1);
261 strtolower(ret->iso2, attr.u.str);
263 ret->iso2=g_strdup(attr.u.str);
265 ret->flag=g_strdup_printf("country_%s", ret->iso2);
267 if (item_attr_get(item, attr_country_iso3, &attr))
268 ret->iso3=g_strdup(attr.u.str);
269 if (item_attr_get(item, attr_country_name, &attr))
270 ret->name=g_strdup(attr.u.str);
275 search_list_country_destroy(struct search_list_country *this_)
285 static struct search_list_town *
286 search_list_town_new(struct item *item)
288 struct search_list_town *ret=g_new0(struct search_list_town, 1);
293 ret->common.item=ret->common.unique=*item;
294 if (item_attr_get(item, attr_town_streets_item, &attr)) {
295 dbg(1,"town_assoc 0x%x 0x%x\n", attr.u.item->id_hi, attr.u.item->id_lo);
296 ret->common.unique=*attr.u.item;
298 search_list_common_new(item, &ret->common);
299 if (item_attr_get(item, attr_county_name, &attr))
300 ret->county=map_convert_string(item->map,attr.u.str);
303 if (item_coord_get(item, &c, 1)) {
304 ret->common.c=g_new(struct pcoord, 1);
305 ret->common.c->x=c.x;
306 ret->common.c->y=c.y;
307 ret->common.c->pro = map_projection(item->map);
313 search_list_town_destroy(struct search_list_town *this_)
315 map_convert_free(this_->county);
316 search_list_common_destroy(&this_->common);
318 g_free(this_->common.c);
323 static struct search_list_street *
324 search_list_street_new(struct item *item)
326 struct search_list_street *ret=g_new0(struct search_list_street, 1);
330 ret->common.item=ret->common.unique=*item;
331 if (item_attr_get(item, attr_street_name, &attr))
332 ret->name=map_convert_string(item->map, attr.u.str);
335 search_list_common_new(item, &ret->common);
336 if (item_coord_get(item, &c, 1)) {
337 ret->common.c=g_new(struct pcoord, 1);
338 ret->common.c->x=c.x;
339 ret->common.c->y=c.y;
340 ret->common.c->pro = map_projection(item->map);
347 search_list_street_destroy(struct search_list_street *this_)
349 map_convert_free(this_->name);
350 search_list_common_destroy(&this_->common);
353 g_free(this_->common.c);
359 search_interpolate(struct interpolation *inter)
361 dbg(1,"interpolate %s-%s %s\n",inter->first,inter->last,inter->curr);
362 if (!inter->first || !inter->last)
365 inter->curr=g_strdup(inter->first);
367 if (strcmp(inter->curr, inter->last)) {
368 int next=atoi(inter->curr)+(inter->mode?2:1);
370 if (next == atoi(inter->last))
371 inter->curr=g_strdup(inter->last);
373 inter->curr=g_strdup_printf("%d",next);
379 dbg(1,"interpolate result %s\n",inter->curr);
384 search_interpolation_split(char *str, struct interpolation *inter)
386 char *pos=strchr(str,'-');
390 inter->first=g_strdup(str);
391 inter->last=g_strdup(str);
396 first=g_malloc(len+1);
397 strncpy(first, str, len);
399 last=g_strdup(pos+1);
400 dbg(1,"%s = %s - %s\n",str, first, last);
401 if (atoi(first) > atoi(last)) {
413 search_setup_interpolation(struct item *item, enum attr_type i0, enum attr_type i1, enum attr_type i2, struct interpolation *inter)
416 g_free(inter->first);
419 inter->first=inter->last=inter->curr=NULL;
420 dbg(1,"setup %s\n",attr_to_name(i0));
421 if (item_attr_get(item, i0, &attr)) {
422 search_interpolation_split(attr.u.str, inter);
424 } else if (item_attr_get(item, i1, &attr)) {
425 search_interpolation_split(attr.u.str, inter);
427 } else if (item_attr_get(item, i2, &attr)) {
428 search_interpolation_split(attr.u.str, inter);
436 search_match(char *str, char *search, int partial)
439 return (!g_strcasecmp(str, search));
441 return (!g_strncasecmp(str, search, strlen(search)));
444 static struct pcoord *
445 search_house_number_coordinate(struct item *item, struct interpolation *inter)
447 struct pcoord *ret=g_new(struct pcoord, 1);
448 ret->pro = map_projection(item->map);
449 dbg(0,"%s\n",item_to_name(item->type));
450 if (item->type<type_house_number_interpolation_even || item->type>type_house_number_interpolation_alphabetic) {
452 if (item_coord_get(item, &c, 1)) {
461 int hn_pos,hn_length;
462 struct coord *c=g_alloca(sizeof(struct coord)*max);
463 item_coord_rewind(item);
464 count=item_coord_get(item, c, max);
465 hn_length=atoi(inter->last)-atoi(inter->first);
467 hn_pos=atoi(inter->last)-atoi(inter->curr);
469 hn_pos=atoi(inter->curr)-atoi(inter->first);
471 int i,distance_sum=0,hn_distance;
472 int *distances=g_alloca(sizeof(int)*(count-1));
473 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);
479 dbg(0,"coordinate overflow\n");
480 for (i = 0 ; i < count-1 ; i++) {
481 distances[i]=navit_sqrt(transform_distance_sq(&c[i],&c[i+1]));
482 distance_sum+=distances[i];
483 dbg(1,"distance[%d]=%d\n",i,distances[i]);
485 dbg(1,"sum=%d\n",distance_sum);
486 hn_distance=distance_sum*hn_pos/hn_length;
487 dbg(1,"hn_distance=%d\n",hn_distance);
489 while (i < count-1 && hn_distance > distances[i])
490 hn_distance-=distances[i++];
491 dbg(1,"remaining distance=%d from %d\n",hn_distance,distances[i]);
492 ret->x=(c[i+1].x-c[i].x)*hn_distance/distances[i]+c[i].x;
493 ret->y=(c[i+1].y-c[i].y)*hn_distance/distances[i]+c[i].y;
501 static struct search_list_house_number *
502 search_list_house_number_new(struct item *item, struct interpolation *inter, char *inter_match, int inter_partial)
504 struct search_list_house_number *ret=g_new0(struct search_list_house_number, 1);
508 ret->common.item=ret->common.unique=*item;
509 //if (item_attr_get(item, attr_street_name, &attr))
510 // dbg(0,"xx1 %s\n",attr.u.str);
511 if (item_attr_get(item, attr_house_number, &attr))
512 ret->house_number=map_convert_string(item->map, attr.u.str);
514 //if (item_attr_get(item, attr_street_name, &attr))
515 // dbg(0,"xx2 %s\n",attr.u.str);
517 //dbg(0,"interpolate 11");
518 ret->interpolation=1;
519 switch(inter->side) {
521 //dbg(0,"interpolate 11 0");
523 search_setup_interpolation(item, attr_house_number_left, attr_house_number_left_odd, attr_house_number_left_even, inter);
525 //dbg(0,"interpolate 11 -1");
526 if ((hn=search_interpolate(inter)))
529 search_setup_interpolation(item, attr_house_number_right, attr_house_number_right_odd, attr_house_number_right_even, inter);
531 //dbg(0,"interpolate 11 1");
532 if ((hn=search_interpolate(inter)))
535 //dbg(0,"interpolate 11 default");
539 if (search_match(hn, inter_match, inter_partial))
541 //dbg(0,"interpolate 22");
542 //dbg(0,"match %s %s-%s\n",hn, inter->first, inter->last);
543 ret->house_number=map_convert_string(item->map, hn);
548 //dbg(0,"interpolate 33");
549 search_list_common_new(item, &ret->common);
550 ret->common.c=search_house_number_coordinate(item, ret->interpolation?inter:NULL);
551 //dbg(0,"interpolate 44");
556 search_list_house_number_destroy(struct search_list_house_number *this_)
558 map_convert_free(this_->house_number);
559 search_list_common_destroy(&this_->common);
561 g_free(this_->common.c);
566 search_list_result_destroy(int level, void *p)
570 search_list_country_destroy(p);
573 search_list_town_destroy(p);
576 search_list_street_destroy(p);
579 search_list_house_number_destroy(p);
585 search_list_search_free(struct search_list *sl, int level)
587 struct search_list_level *le=&sl->levels[level];
591 mapset_search_destroy(le->search);
596 g_hash_table_destroy(le->hash);
603 search_list_result_destroy(level, curr->data);
604 next=g_list_next(curr);
608 g_list_free(le->list);
615 search_postal_merge(char *mask, char *new)
619 dbg(1,"enter %s %s\n", mask, new);
623 return g_strdup(new);
625 while (mask[i] && new[i]) {
626 if (mask[i] != '.' && mask[i] != new[i])
636 dbg(1,"merged %s with %s as %s\n", mask, new, ret);
641 search_postal_merge_replace(char *mask, char *new)
643 char *ret=search_postal_merge(mask, new);
652 postal_match(char *postal, char *mask)
655 if ((*postal != *mask) && (*mask != '.'))
669 search_add_result(struct search_list_level *le, struct search_list_common *slc)
671 struct search_list_common *slo;
673 slo=g_hash_table_lookup(le->hash, &slc->unique);
675 g_hash_table_insert(le->hash, &slc->unique, slc);
676 if (slc->postal && !slc->postal_mask) {
677 slc->postal_mask=g_strdup(slc->postal);
679 le->list=g_list_append(le->list, slc);
682 merged=search_postal_merge(slo->postal_mask, slc->postal);
684 g_free(slo->postal_mask);
685 slo->postal_mask=merged;
691 * @brief Get (next) result from a search.
693 * @param this_ search_list representing the search
694 * @return next result
696 struct search_list_result *
697 search_list_get_result(struct search_list *this_)
699 struct search_list_level *le,*leu;
700 int level=this_->level;
702 int has_street_name=0;
705 le=&this_->levels[level];
706 //dbg(0,"le=%p\n", le);
709 //dbg(0,"le->search=%p\n", le->search);
712 //dbg(0,"partial=%d level=%d\n", le->partial, level);
717 leu=&this_->levels[level-1];
718 //dbg(0,"leu->curr=%p\n", leu->curr);
721 //dbg(0,"*********########");
723 struct search_list_common *slc;
728 le->parent=leu->curr->data;
730 leu->curr=g_list_next(leu->curr);
731 slc=(struct search_list_common *)(le->parent);
734 if (slc->selected == leu->selected)
740 //dbg(0,"mapset_search_new with item(%d,%d)\n", le->parent->item.id_hi, le->parent->item.id_lo);
742 //dbg(0,"############## attr=%s\n", attr_to_name(le->attr->type));
743 le->search=mapset_search_new(this_->ms, &le->parent->item, le->attr, le->partial);
744 le->hash=g_hash_table_new(search_item_hash_hash, search_item_hash_equal);
746 //dbg(0,"le->search=%p\n", le->search);
750 this_->item=mapset_search_get_item(le->search);
751 //dbg(0,"sssss 1 %p\n",this_->item);
756 //dbg(0,"id_hi=%d id_lo=%d\n", this_->item->id_hi, this_->item->id_lo);
760 if (item_attr_get(this_->item, attr_postal_mask, &postal)) {
761 if (!postal_match(this_->postal, postal.u.str))
763 } else if (item_attr_get(this_->item, attr_postal, &postal)) {
764 if (strcmp(this_->postal, postal.u.str))
768 this_->result.country=NULL;
769 this_->result.town=NULL;
770 this_->result.street=NULL;
771 this_->result.c=NULL;
772 //dbg(0,"case x LEVEL start %d\n",level);
776 //dbg(0,"case 0 COUNTRY");
777 p=search_list_country_new(this_->item);
778 this_->result.country=p;
779 this_->result.country->common.parent=NULL;
783 //dbg(0,"case 1 TOWN");
784 p=search_list_town_new(this_->item);
785 this_->result.town=p;
786 this_->result.town->common.parent=this_->levels[0].last->data;
787 this_->result.country=this_->result.town->common.parent;
788 this_->result.c=this_->result.town->common.c;
792 //dbg(0,"case 2 STREET");
793 p=search_list_street_new(this_->item);
794 this_->result.street=p;
795 this_->result.street->common.parent=this_->levels[1].last->data;
796 this_->result.town=this_->result.street->common.parent;
797 this_->result.country=this_->result.town->common.parent;
798 this_->result.c=this_->result.street->common.c;
802 dbg(1,"case 3 HOUSENUMBER\n");
805 // if this housenumber has a streetname tag, set the name now
806 if (item_attr_get(this_->item, attr_street_name, &attr2))
808 dbg(1,"streetname: %s\n",attr2.u.str);
812 p=search_list_house_number_new(this_->item, &this_->inter, le->attr->u.str, le->partial);
815 interpolation_clear(&this_->inter);
820 this_->result.house_number=p;
821 if (!this_->result.house_number->interpolation)
825 dbg(0,"interpolation!\n");
828 if(le->parent && has_street_name) {
829 struct search_list_street *street=this_->levels[level-1].last->data;
832 s1=g_utf8_casefold(street->name,-1);
833 s2=g_utf8_casefold(attr2.u.str,-1);
834 cmpres=strcmp(s1,s2);
835 dbg(1,"Compared %s with %s, got %d\n",s1,s2,cmpres);
839 search_list_house_number_destroy(p);
846 this_->result.house_number->common.parent=this_->levels[2].last->data;
847 this_->result.street=this_->result.house_number->common.parent;
848 this_->result.town=this_->result.street->common.parent;
849 this_->result.country=this_->result.town->common.parent;
850 this_->result.c=this_->result.house_number->common.c;
852 if(!has_street_name) {
853 static struct search_list_street null_street;
854 this_->result.street=&null_street;
859 if (search_add_result(le, p))
862 return &this_->result;
866 search_list_result_destroy(level, p);
870 mapset_search_destroy(le->search);
872 g_hash_table_destroy(le->hash);
881 search_list_destroy(struct search_list *this_)
883 g_free(this_->postal);
894 search_fix_spaces(const char *str)
898 char c,*s,*d,*ret=g_strdup(str);
900 for (i = 0 ; i < len ; i++) {
901 if (ret[i] == ',' || ret[i] == ',' || ret[i] == '/')
909 if (c != ' ' || len != 0) {
913 while (c == ' ' && *s == ' ')
915 if (c == ' ' && *s == '\0') {
924 search_split_phrases(char *str)
932 ret=g_list_append(ret, g_strdup(s));
936 ret=g_list_append(ret, g_strdup(tmp));
947 } while (*s != '\0');
948 } while (*s != '\0');
953 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)
955 // here we search actually for the housenumber
956 struct search_list_result *slr;
960 dbg(1,"street:%s\n",street_name);
961 while ((slr=search_list_get_result(sl)))
963 // does the streetname of the housenumber match the street we want?
964 if (slr->street != NULL)
965 if ((street_name != NULL)&&(slr->street->name != NULL))
967 //dbg(0,"ffffff 1.1 %s %s",street_name,slr->street->name);
968 if (strcmp(slr->street->name, street_name)==0)
972 c.x=slr->house_number->common.c->x;
973 c.y=slr->house_number->common.c->y;
974 transform_to_geo(slr->house_number->common.c->pro, &c, &g);
975 //dbg(0,"g=%f %f\n",g.lat,g.lng);
976 //dbg(0,"###### Result with housenumber: streetname=%s\n",slr->street->name);
977 //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);
978 // SHN -> street with house number
979 // return a string like: "SHN:H111L5555:16.766:48.76:full address name is at the end"
980 // ca. 9 chars : ca. 9 chars : max. 100 max. 100 max. 100 max. 15 chars -> this sould be max. about 335 chars long
981 if (slr->town->common.postal == NULL)
983 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);
987 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);
989 // deactivated now * result_list=g_list_prepend(result_list,g_strdup(buffer));
990 #ifdef HAVE_API_ANDROID
991 // return results to android as they come in ...
992 android_return_search_result(jni,buffer);
1003 search_address_housenumber(GList *result_list, struct search_list *sl, GList *phrases, GList *exclude1, GList *exclude2, GList *exclude3, int partial, struct jni_object *jni)
1006 // this is actually "street search" and "housenumber search" is at the bottom of this function
1008 // housenumbers are not found as of now (2011-02-28)
1012 struct search_list_result *slr;
1019 attr.type=attr_street_name;
1020 while ((slr=search_list_get_result(sl)))
1023 //dbg(0,"%p %p\n",slr->country,slr->town);
1024 //dbg(0,"%p\n",slr->street);
1025 // 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);
1026 //dbg(0,"###### Result without housenumber: postal:%s\n",slr->town->common.postal);
1027 //dbg(0,"###### Result without housenumber: postal_mask:%s\n",slr->town->common.postal_mask);
1028 //dbg(0,"###### Result without housenumber: STR postal:%s\n",slr->street->common.postal);
1029 //dbg(0,"###### Result without housenumber: STR postal_mask:%s\n",slr->street->common.postal_mask);
1030 //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);
1033 c.x=slr->street->common.c->x;
1034 c.y=slr->street->common.c->y;
1035 transform_to_geo(slr->street->common.c->pro, &c, &g);
1036 //dbg(0,"g=%f %f\n",g.lat,g.lng);
1040 // return a string like: "STR:H1111L5555:16.766:-48.76:full address name is at the end"
1041 // ca. 9 chars : ca. 9 chars : max. 100 max. 100 max. 100 chars -> this sould be max. about 320 chars long
1042 if (slr->town->common.postal == NULL)
1044 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);
1048 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);
1050 // deactivated now * result_list=g_list_prepend(result_list,g_strdup(buffer));
1052 #ifdef HAVE_API_ANDROID
1053 // return results to android as they come in ...
1054 android_return_search_result(jni,buffer);
1060 if (tmp != exclude1 && tmp != exclude2 && tmp != exclude3 && slr->street)
1062 attr2.type=attr_house_number;
1063 attr2.u.str=tmp->data;
1064 search_list_search(sl, &attr2, partial);
1065 //dbg(0,"hn str=%s\n",attr2.u.str);
1066 result_list=search_address_housenumber_real(result_list, sl, slr->street->name, phrases, exclude1, exclude2, exclude3, partial, jni);
1068 tmp=g_list_next(tmp);
1080 search_address_street(GList *result_list, struct search_list *sl, GList *phrases, GList *exclude1, GList *exclude2, int partial, struct jni_object *jni)
1083 // this is actually "town search" !!
1086 struct search_list_result *slr;
1092 attr.type=attr_street_name;
1093 while ((slr=search_list_get_result(sl)))
1096 //dbg(0,"##### sss1");
1097 // dbg(0,"###### Result town: country=%s country_name=%s town=%s",slr->country->iso2,slr->country->name,slr->town->common.town_name);
1098 // dbg(0,"###### Result town: postal=%s postal_mask=%s",slr->town->common.postal,slr->town->common.postal_mask);
1101 c.x=slr->town->common.c->x;
1102 c.y=slr->town->common.c->y;
1103 transform_to_geo(slr->town->common.c->pro, &c, &g);
1106 if (slr->town->common.postal == NULL)
1108 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);
1112 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);
1114 // deactivated now * result_list=g_list_prepend(result_list,g_strdup(buffer));
1115 #ifdef HAVE_API_ANDROID
1116 // return results to android as they come in ...
1117 android_return_search_result(jni,buffer);
1122 dbg(0,"%s %s %s %s",slr->country->car,slr->town->name,slr->town->district,slr->street->name);
1125 dbg(0,"%s %s %s\n",slr->country->iso2,slr->town->county,slr->street->name);
1127 if (item_attr_get(&slr->town->itemt, attr_label, &attr77))
1129 dbg(0,"***search result T=%s",attr77.u.str);
1137 //dbg(0,"count %d\n",count);
1140 if (tmp != exclude1 && tmp != exclude2)
1142 attr.u.str=tmp->data;
1143 search_list_search(sl, &attr, partial);
1144 result_list=search_address_housenumber(result_list, sl, phrases, exclude1, exclude2, tmp, partial, jni);
1146 tmp=g_list_next(tmp);
1152 search_address_town(GList *result_list, struct search_list *sl, GList *phrases, GList *exclude, int partial, struct jni_object *jni)
1157 struct search_list_result *slr;
1159 attr.type=attr_town_or_district_name;
1160 while ((slr=search_list_get_result(sl)))
1166 //dbg(0,"count %d\n",count);
1171 attr.u.str=tmp->data;
1172 search_list_search(sl, &attr, partial);
1173 result_list=search_address_street(result_list, sl, phrases, exclude, tmp, partial, jni);
1175 tmp=g_list_next(tmp);
1182 search_by_address(struct search_list *sl, const char *addr, int partial, struct jni_object *jni)
1184 char *str=search_fix_spaces(addr);
1185 GList *phrases=search_split_phrases(str);
1187 dbg(0,"enter %s\n",addr);
1188 ret=search_address_town(ret, sl, phrases, NULL, partial, jni);
1191 dbg(0,"leave %p\n",ret);