Navit SVN
Classes | Functions | Variables

/work/compile/navit/src/navit/mapset.c File Reference

Contains code used for loading more than one map. More...

#include <string.h>
#include <glib.h>
#include <glib/gprintf.h>
#include "debug.h"
#include "item.h"
#include "mapset.h"
#include "projection.h"
#include "map.h"
#include "xmlconfig.h"

Classes

struct  mapset
 A mapset. More...
struct  attr_iter
struct  mapset_handle
 Handle for a mapset in use. More...
struct  mapset_search
 Holds information about a search in a mapset. More...

Functions

struct mapsetmapset_new (struct attr *parent, struct attr **attrs)
 Creates a new, empty mapset.
struct mapsetmapset_dup (struct mapset *ms)
struct attr_itermapset_attr_iter_new (void)
void mapset_attr_iter_destroy (struct attr_iter *iter)
int mapset_add_attr (struct mapset *ms, struct attr *attr)
 Adds a map to a mapset.
int mapset_remove_attr (struct mapset *ms, struct attr *attr)
int mapset_get_attr (struct mapset *ms, enum attr_type type, struct attr *attr, struct attr_iter *iter)
void mapset_destroy (struct mapset *ms)
 Destroys a mapset.
struct mapsetmapset_ref (struct mapset *m)
void mapset_unref (struct mapset *m)
struct mapset_handlemapset_open (struct mapset *ms)
 Returns a new handle for a mapset.
struct mapmapset_next (struct mapset_handle *msh, int active)
 Gets the next map from a mapset handle.
struct mapmapset_get_map_by_name (struct mapset *ms, char *map_name)
 Gets a map from the mapset by name.
void mapset_close (struct mapset_handle *msh)
 Closes a mapset handle after it is no longer used.
struct mapset_searchmapset_search_new (struct mapset *ms, struct item *item, struct attr *search_attr, int partial)
 Starts a search on a mapset.
struct itemmapset_search_get_item (struct mapset_search *this_)
 Returns the next found item from a mapset search.
void mapset_search_destroy (struct mapset_search *this_)
 Destroys a mapset search.

Variables

struct object_func mapset_func

Detailed Description

Contains code used for loading more than one map.

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.

The code in this file introduces "mapsets", which are collections of several maps. This enables navit to operate on more than one map at once. See map.c / map.h to learn how maps are handled.


Function Documentation

int mapset_add_attr ( struct mapset ms,
struct attr attr 
)

Adds a map to a mapset.

Parameters:
msThe mapset to add the map to
mThe map to be added

References mapset::maps.

void mapset_close ( struct mapset_handle msh)

Closes a mapset handle after it is no longer used.

Parameters:
mshMapset handle to be closed
void mapset_destroy ( struct mapset ms)

Destroys a mapset.

This destroys a mapset. Please note that it does not touch the contained maps in any way.

Parameters:
msThe mapset to be destroyed

References mapset::maps.

struct map* mapset_get_map_by_name ( struct mapset ms,
char *  map_name 
) [read]

Gets a map from the mapset by name.

Parameters:
msThe map
map_namethe map name used by the search
Returns:
The next map

References map_get_attr(), mapset_next(), and mapset_open().

struct mapset* mapset_new ( struct attr parent,
struct attr **  attrs 
) [read]

Creates a new, empty mapset.

Returns:
The new mapset
struct map* mapset_next ( struct mapset_handle msh,
int  active 
) [read]

Gets the next map from a mapset handle.

If you set active to true, this function will not return any maps that have the attr_active attribute associated with them and set to false.

Parameters:
mshThe mapset handle to get the next map of
activeSet to true to only get active maps (See description)
Returns:
The next map

References mapset_handle::l, and map_get_attr().

Referenced by mapset_get_map_by_name().

struct mapset_handle* mapset_open ( struct mapset ms) [read]

Returns a new handle for a mapset.

This returns a new handle for an existing mapset. The new handle points to the first map in the set.

Parameters:
msThe mapset to get a handle of
Returns:
The new mapset handle

References mapset_handle::l, and mapset::maps.

Referenced by mapset_get_map_by_name().

void mapset_search_destroy ( struct mapset_search this_)

Destroys a mapset search.

Parameters:
thisThe mapset search to be destroyed

References map_search_destroy(), and mapset_search::ms.

struct item* mapset_search_get_item ( struct mapset_search this_) [read]

Returns the next found item from a mapset search.

This function returns the next item from a mapset search or NULL if there are no more items found. It automatically iterates through all the maps in the mapset. Please note that maps which have the attr_active attribute associated with them and set to false are not searched.

Parameters:
thisThe mapset search to return an item from
Returns:
The next found item or NULL if there are no more items found

References mapset_search::item, mapset_search::map, map_get_attr(), map_search_destroy(), map_search_get_item(), map_search_new(), mapset_search::ms, mapset_search::partial, and mapset_search::search_attr.

struct mapset_search* mapset_search_new ( struct mapset ms,
struct item item,
struct attr search_attr,
int  partial 
) [read]

Starts a search on a mapset.

This function starts a search on a mapset. What attributes one can search for depends on the map plugin. See the description of map_search_new() in map.c for details.

If you enable partial matches bear in mind that the search matches only the begin of the strings - a search for a street named "street" would match to "streetfoo", but not to "somestreet". Search is case insensitive.

The item passed to this function specifies a "superior item" to "search within" - e.g. a town in which we want to search for a street, or a country in which to search for a town.

Parameters:
msThe mapset that should be searched
itemSpecifies a superior item to "search within" (see description)
search_attrAttribute specifying what to search for. See description.
partialSet this to true to also have partial matches. See description.
Returns:
A new mapset search struct for this search

References mapset_search::item, map_search_new(), mapset::maps, mapset_search::partial, and mapset_search::search_attr.


Variable Documentation

struct object_func mapset_func
Initial value:
 {
        attr_mapset,
        (object_func_new)mapset_new,
        (object_func_get_attr)mapset_get_attr,
        (object_func_iter_new)mapset_attr_iter_new,
        (object_func_iter_destroy)mapset_attr_iter_destroy,
        (object_func_set_attr)NULL,
        (object_func_add_attr)mapset_add_attr,
        (object_func_remove_attr)mapset_remove_attr,
        (object_func_init)NULL,
        (object_func_destroy)mapset_destroy,
        (object_func_dup)mapset_dup,
        (object_func_ref)mapset_ref,
        (object_func_unref)mapset_unref,
}