Add:data_binfile:Initial USA search! Add USA country code to osm2navit. Add item_is_s...
[navit-package] / navit / item.h
1 /**
2  * Navit, a modular navigation system.
3  * Copyright (C) 2005-2008 Navit Team
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public License
7  * version 2 as published by the Free Software Foundation.
8  *
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 Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License 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.
18  */
19
20 #ifndef NAVIT_ITEM_H
21 #define NAVIT_ITEM_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 enum item_type {
28 #define ITEM2(x,y) type_##y=x,
29 #define ITEM(x) type_##x,
30 #include "item_def.h"
31 #undef ITEM2
32 #undef ITEM
33 };
34
35 #include "attr.h"
36
37
38 /* NOTE: we treat districts as towns for now, since
39    a) navit does not implement district search yet
40    b) OSM "place=suburb" maps to type_district in osm2navit. with the OSM USA maps,
41       there are many "suburbs" that users will consider towns (not districts/counties);
42       we want navit's town search to find them
43 */
44 #define item_is_town(item) ((item).type >= type_town_label && (item).type <= type_district_label_1e7)
45 #define item_is_street(item) ((item).type >= type_street_nopass && (item).type <= type_ferry)
46
47 #define item_is_equal_id(a,b) ((a).id_hi == (b).id_hi && (a).id_lo == (b).id_lo)
48 #define item_is_equal(a,b) (item_is_equal_id(a,b) && (a).map == (b).map)
49
50 struct coord;
51
52 struct item_methods {
53         void (*item_coord_rewind)(void *priv_data);
54         int (*item_coord_get)(void *priv_data, struct coord *c, int count);
55         void (*item_attr_rewind)(void *priv_data);
56         int (*item_attr_get)(void *priv_data, enum attr_type attr_type, struct attr *attr);
57         int (*item_coord_is_segment)(void *priv_data);
58 };
59
60 struct item {
61         enum item_type type;
62         int id_hi;
63         int id_lo;
64         struct map *map;
65         struct item_methods *meth;      
66         void *priv_data;
67 };
68
69 /* prototypes */
70 enum attr_type;
71 enum item_type;
72 struct attr;
73 struct coord;
74 struct item;
75 struct item_hash;
76 void item_coord_rewind(struct item *it);
77 int item_coord_get(struct item *it, struct coord *c, int count);
78 /* does the next returned coordinate mark a segment */
79 int item_coord_is_segment(struct item *it);
80 void item_attr_rewind(struct item *it);
81 int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr);
82 struct item *item_new(char *type, int zoom);
83 enum item_type item_from_name(const char *name);
84 char *item_to_name(enum item_type item);
85 struct item_hash *item_hash_new(void);
86 void item_hash_insert(struct item_hash *h, struct item *item, void *val);
87 int item_hash_remove(struct item_hash *h, struct item *item);
88 void *item_hash_lookup(struct item_hash *h, struct item *item);
89 void item_hash_destroy(struct item_hash *h);
90 /* end of prototypes */
91
92
93 #ifdef __cplusplus
94 }
95 /* __cplusplus */
96 #endif
97
98 /* NAVIT_ITEM_H */
99 #endif