/[zanavi_public1]/navit/navit/item.h
ZANavi

Contents of /navit/navit/item.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 41 - (show annotations) (download)
Tue Aug 11 18:50:37 2015 UTC (8 years, 7 months ago) by zoff99
File MIME type: text/plain
File size: 6767 byte(s)
many fixes, and new features
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 #include <stdio.h>
28
29 enum item_type {
30 #define ITEM2(x,y) type_##y=x,
31 #define ITEM(x) type_##x,
32 #include "item_def.h"
33 #undef ITEM2
34 #undef ITEM
35 };
36
37
38 // ------- dont forget to update these if you add street types for navigation !! -------
39 // ------- dont forget to update these if you add street types for navigation !! -------
40 #define route_item_first type_street_0
41 #define route_item_last type_ramp_street_2_city
42 extern int default_flags[];
43 // ------- dont forget to update these if you add street types for navigation !! -------
44 // ------- dont forget to update these if you add street types for navigation !! -------
45
46
47 #include "attr.h"
48
49
50 /* NOTE OLD: we treat districts as towns for now, since
51 a) navit does not implement district search yet
52 b) OSM "place=suburb" maps to type_district in maptool. with the OSM USA maps,
53 there are many "suburbs" that users will consider towns (not districts/counties);
54 we want navit's town search to find them
55
56 NOTE NEW: oct.2012: now we DONT treat districts as towns
57
58 */
59 #define item_type_is_area(type) ((type) >= type_area)
60 #define item_is_town(item) ((item).type >= type_town_label && (item).type < type_district_label)
61 #define item_is_district(item) ((item).type >= type_district_label && (item).type <= type_district_label_1e7)
62 #define item_is_poly_place(item) ((item).type >= type_poly_place1 && (item).type <= type_poly_place6)
63 #define item_is_point(item) ((item).type < type_line)
64 #define item_is_custom_poi(item) ((item).type >= type_poi_custom0 && (item).type < type_line)
65 #define item_is_street(item) (((item).type >= type_street_0 && (item).type <= type_highway_land) \
66 || (item).type == type_street_service \
67 || (item).type == type_street_parking_lane \
68 || (item).type == type_ramp_highway_land \
69 || (item).type == type_ramp_street_4_city \
70 || (item).type == type_ramp_street_3_city \
71 || (item).type == type_ramp_street_2_city \
72 || (item).type == type_street_pedestrian \
73 || (item).type == type_living_street)
74
75 #define item_is_ramp(item) ( (item).type == type_ramp_highway_land \
76 || (item).type == type_ramp_street_4_city \
77 || (item).type == type_ramp_street_3_city \
78 || (item).type == type_ramp_street_2_city)
79
80
81 #define item_is_equal_id(a,b) ((a).id_hi == (b).id_hi && (a).id_lo == (b).id_lo)
82 #define item_is_equal(a,b) (item_is_equal_id(a,b) && (a).map == (b).map)
83
84 struct coord;
85
86 enum change_mode {
87 change_mode_delete,
88 change_mode_modify,
89 change_mode_append,
90 change_mode_prepend,
91 };
92
93 struct item_methods {
94 void (*item_coord_rewind)(void *priv_data);
95 int (*item_coord_get)(void *priv_data, struct coord *c, int count);
96 void (*item_attr_rewind)(void *priv_data);
97 int (*item_attr_get)(void *priv_data, enum attr_type attr_type, struct attr *attr);
98 int (*item_coord_is_node)(void *priv_data);
99 int (*item_attr_set)(void *priv_data, struct attr *attr, enum change_mode mode);
100 int (*item_coord_set)(void *priv_data, struct coord *c, int count, enum change_mode mode);
101 int (*item_type_set)(void *priv_data, enum item_type type);
102 };
103
104 struct item_id {
105 int id_hi;
106 int id_lo;
107 };
108
109 #define ITEM_ID_FMT "(0x%x,0x%x)"
110 #define ITEM_ID_ARGS(x) (x).id_hi,(x).id_lo
111
112 struct item {
113 enum item_type type;
114 int id_hi;
115 int id_lo;
116 struct map *map;
117 struct item_methods *meth;
118 void *priv_data;
119 // added flags from attr!! --> Zoff
120 long flags;
121 };
122
123 extern struct item_range {
124 enum item_type min,max;
125 } item_range_all;
126
127 extern struct item busy_item;
128
129 /* prototypes */
130 enum attr_type;
131 enum change_mode;
132 enum item_type;
133 enum projection;
134 struct attr;
135 struct coord;
136 struct item;
137 struct item_hash;
138 struct item_range;
139 struct map;
140 struct map_selection;
141 int *item_get_default_flags(enum item_type type);
142 void item_coord_rewind(struct item *it);
143 int item_coord_get(struct item *it, struct coord *c, int count);
144 int item_coord_set(struct item *it, struct coord *c, int count, enum change_mode mode);
145 int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel);
146 int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to);
147 int item_coord_is_node(struct item *it);
148 void item_attr_rewind(struct item *it);
149 int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr);
150 int item_attr_set(struct item *it, struct attr *attr, enum change_mode mode);
151 struct item *item_new(char *type, int zoom);
152 enum item_type item_from_name(const char *name);
153 char *item_to_name(enum item_type item);
154 unsigned int item_id_hash(const void *key);
155 int item_id_equal(const void *a, const void *b);
156 struct item_hash *item_hash_new(void);
157 void item_hash_insert(struct item_hash *h, struct item *item, void *val);
158 int item_hash_remove(struct item_hash *h, struct item *item);
159 void *item_hash_lookup(struct item_hash *h, struct item *item);
160 void item_hash_destroy(struct item_hash *h);
161 int item_range_intersects_range(struct item_range *range1, struct item_range *range2);
162 int item_range_contains_item(struct item_range *range, enum item_type type);
163 void item_dump_attr(struct item *item, struct map *map, FILE *out);
164 void item_dump_filedesc(struct item *item, struct map *map, FILE *out);
165 void item_cleanup(void);
166 int item_is_poi(enum item_type i_type);
167 int item_is_district_label(enum item_type i_type);
168 int item_is_town_label_no_major(enum item_type i_type);
169 int item_is_town_label_major(enum item_type i_type);
170 void item_dump_coords(struct item *item, struct map *map);
171
172 void item_dump_attr_stdout(struct item *item, struct map *map);
173
174 /* end of prototypes */
175
176
177 #ifdef __cplusplus
178 }
179 /* __cplusplus */
180 #endif
181
182 /* NAVIT_ITEM_H */
183 #endif

   
Visit the ZANavi Wiki