navit  0.5.3-trunk
search.c File Reference
#include <stdlib.h>
#include <glib.h>
#include <string.h>
#include <math.h>
#include "debug.h"
#include "projection.h"
#include "item.h"
#include "xmlconfig.h"
#include "map.h"
#include "mapset.h"
#include "coord.h"
#include "transform.h"
#include "search.h"
#include "country.h"
#include "linguistics.h"
#include "geom.h"
#include "util.h"
#include "search_houseno_interpol.h"
#include "layout.h"

Data Structures

struct  search_list_level
 
struct  search_list
 
struct  phrase
 

Functions

static struct search_list_resultsearch_list_result_dup (struct search_list_result *slr)
 
static void search_list_country_destroy (struct search_list_country *this_)
 
static void search_list_town_destroy (struct search_list_town *this_)
 
static void search_list_street_destroy (struct search_list_street *this_)
 
static void search_list_house_number_destroy (struct search_list_house_number *this_)
 
static guint search_item_hash_hash (gconstpointer key)
 
static gboolean search_item_hash_equal (gconstpointer a, gconstpointer b)
 
struct search_listsearch_list_new (struct mapset *ms)
 Create new instance of search_list to run a search. More...
 
static void search_list_search_free (struct search_list *sl, int level)
 
int search_list_level (enum attr_type attr_type)
 Determine search list level for given attr_type. More...
 
char * search_fix_spaces (const char *str)
 Replaces ',' and '/' by ' ', deduplicates spaces within the string and strips spaces from both ends of the string. More...
 
static GListsearch_split_phrases (char *str)
 
static char * search_phrase_str (struct phrase *p)
 
static int search_phrase_used (struct phrase *p, GList *used_phrases)
 
static gint search_by_address_compare (gconstpointer a, gconstpointer b)
 
static GListsearch_by_address_attr (GList *results, struct search_list *sl, GList *phrases, GList *exclude, enum attr_type attr_type, int wordcount)
 
static void search_by_address (struct search_list *this_, char *addr)
 
static void search_address_results_free (struct search_list *this_)
 
void search_list_search (struct search_list *this_, struct attr *search_attr, int partial)
 Start a search. More...
 
struct search_list_commonsearch_list_select (struct search_list *this_, enum attr_type attr_type, int id, int mode)
 
static void search_list_common_addattr (struct attr *attr, struct search_list_common *common)
 
static void search_list_common_new (struct item *item, struct search_list_common *common)
 
static void search_list_common_dup (struct search_list_common *src, struct search_list_common *dst)
 
static void search_list_common_destroy (struct search_list_common *common)
 
static struct search_list_countrysearch_list_country_new (struct item *item)
 
static struct search_list_countrysearch_list_country_dup (struct search_list_country *this_)
 
static struct search_list_townsearch_list_town_new (struct item *item)
 
static struct search_list_townsearch_list_town_dup (struct search_list_town *this_)
 
static struct search_list_streetsearch_list_street_new (struct item *item)
 
static struct search_list_streetsearch_list_street_dup (struct search_list_street *this_)
 
static struct search_list_house_numbersearch_list_house_number_new (struct item *item, struct house_number_interpolation *inter, char *inter_match, int inter_partial)
 
static struct search_list_house_numbersearch_list_house_number_dup (struct search_list_house_number *this_)
 
static void search_list_result_destroy (int level, void *p)
 
char * search_postal_merge (char *mask, char *new)
 
char * search_postal_merge_replace (char *mask, char *new)
 
static int postal_match (char *postal, char *mask)
 
static int search_add_result (struct search_list_level *le, struct search_list_common *slc)
 
struct search_list_resultsearch_list_get_result (struct search_list *this_)
 Get (next) result from a search. More...
 
void search_list_destroy (struct search_list *this_)
 
void search_init (void)
 

Function Documentation

◆ postal_match()

static int postal_match ( char *  postal,
char *  mask 
)
static

Referenced by search_list_get_result().

◆ search_add_result()

◆ search_address_results_free()

◆ search_by_address()

◆ search_by_address_attr()

static GList* search_by_address_attr ( GList results,
struct search_list sl,
GList phrases,
GList exclude,
enum attr_type  attr_type,
int  wordcount 
)
static

◆ search_by_address_compare()

static gint search_by_address_compare ( gconstpointer  a,
gconstpointer  b 
)
static

◆ search_fix_spaces()

char* search_fix_spaces ( const char *  str)

Replaces ',' and '/' by ' ', deduplicates spaces within the string and strips spaces from both ends of the string.

Parameters
pointerto the string to cleanup
Returns
pointer to the cleaned up string

References c.

Referenced by search_by_address(), and start_search().

◆ search_init()

void search_init ( void  )

Referenced by main_real().

◆ search_item_hash_equal()

static gboolean search_item_hash_equal ( gconstpointer  a,
gconstpointer  b 
)
static

References item_is_equal_id.

Referenced by search_list_get_result().

◆ search_item_hash_hash()

static guint search_item_hash_hash ( gconstpointer  key)
static

References item::id_hi, item::id_lo, and key.

Referenced by search_list_get_result().

◆ search_list_common_addattr()

◆ search_list_common_destroy()

◆ search_list_common_dup()

static void search_list_common_dup ( struct search_list_common src,
struct search_list_common dst 
)
static

◆ search_list_common_new()

◆ search_list_country_destroy()

◆ search_list_country_dup()

◆ search_list_country_new()

◆ search_list_destroy()

◆ search_list_get_result()

struct search_list_result* search_list_get_result ( struct search_list this_)

Get (next) result from a search.

Parameters
this_search_list representing the search
Returns
next result

References search_list::address_results_pos, search_list_level::attr, search_list_common::c, search_list_result::c, search_list_country::common, search_list_town::common, search_list_street::common, search_list_house_number::common, search_list_result::country, search_list_level::curr, dbg, search_list_level::hash, search_list_result::house_number, search_list_house_number::house_number_interpolation, house_number_interpolation_clear_all(), search_list_result::id, search_list::inter, search_list::item, search_list_common::item, item_attr_get(), search_list_level::last, search_list::level, search_list::levels, lvl_debug, mapset_search_destroy(), mapset_search_get_item(), mapset_search_new(), search_list::ms, search_list_street::name, navit_utf8_strcasecmp(), p, search_list_level::parent, search_list_common::parent, search_list_level::partial, search_list::postal, postal_match(), search_list::result, search_list_level::search, search_add_result(), search_item_hash_equal(), search_item_hash_hash(), search_list_country_new(), search_list_house_number_destroy(), search_list_house_number_new(), search_list_result_destroy(), search_list_street_new(), search_list_town_new(), search_list_level::selected, search_list_common::selected, attr::str, search_list_result::street, search_list_result::town, attr::u, and search_list::use_address_results.

Referenced by android_search_idle(), changed(), gui_internal_search_idle(), gui_internal_search_list_set_default_country(), Java_org_navitproject_navit_NavitAddressSearchActivity_callbackStartAddressSearch(), Java_org_navitproject_navit_NavitGraphics_getAllCountries(), Java_org_navitproject_navit_NavitGraphics_getDefaultCountry(), NGQProxySearch::NGQProxySearch(), notify_apply(), notify_textchange(), request_search_list_get_result(), search_by_address_attr(), NGQProxySearch::searchXml(), NGQProxySearch::setCountryName(), NGQProxySearch::setPointToResult(), and Backend::updateSearch().

◆ search_list_house_number_destroy()

◆ search_list_house_number_dup()

◆ search_list_house_number_new()

◆ search_list_level()

Determine search list level for given attr_type.

Parameters
attr_typeattribute value
Returns
corresponding search list level (country=0, town=1, ...)

References attr_to_name(), dbg, and lvl_error.

Referenced by android_search_idle(), search_list_search(), and search_list_select().

◆ search_list_new()

◆ search_list_result_destroy()

static void search_list_result_destroy ( int  level,
void *  p 
)
static

◆ search_list_result_dup()

static struct search_list_result * search_list_result_dup ( struct search_list_result slr)
static

Navit, a modular navigation system. Copyright (C) 2005-2008 Navit Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

Boston, MA 02110-1301, USA.

References search_list_result::c, search_list_result::country, search_list_result::house_number, search_list_result::id, search_list_country_dup(), search_list_house_number_dup(), search_list_street_dup(), search_list_town_dup(), search_list_result::street, and search_list_result::town.

Referenced by search_by_address_attr().

◆ search_list_search()

◆ search_list_search_free()

◆ search_list_select()

◆ search_list_street_destroy()

◆ search_list_street_dup()

static struct search_list_street* search_list_street_dup ( struct search_list_street this_)
static

◆ search_list_street_new()

◆ search_list_town_destroy()

◆ search_list_town_dup()

static struct search_list_town* search_list_town_dup ( struct search_list_town this_)
static

◆ search_list_town_new()

◆ search_phrase_str()

static char* search_phrase_str ( struct phrase p)
static

References p.

Referenced by search_by_address_attr().

◆ search_phrase_used()

static int search_phrase_used ( struct phrase p,
GList used_phrases 
)
static

References dbg, phrase::end, lvl_debug, p, and phrase::start.

Referenced by search_by_address_attr().

◆ search_postal_merge()

char* search_postal_merge ( char *  mask,
char *  new 
)

References dbg, and lvl_debug.

Referenced by search_add_result(), and search_postal_merge_replace().

◆ search_postal_merge_replace()

char* search_postal_merge_replace ( char *  mask,
char *  new 
)

References search_postal_merge().

◆ search_split_phrases()

static GList* search_split_phrases ( char *  str)
static