navit  0.5.3-trunk
item.h
Go to the documentation of this file.
1 
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 #define route_item_first type_street_0
38 #define route_item_last type_street_parking_lane
39 extern int default_flags[];
40 
41 #include "attr.h"
42 
43 
44 /* NOTE: we treat districts as towns for now, since
45  a) navit does not implement district search yet
46  b) OSM "place=suburb" maps to type_district in maptool. with the OSM USA maps,
47  there are many "suburbs" that users will consider towns (not districts/counties);
48  we want navit's town search to find them
49 */
50 #define item_type_is_area(type) ((type) >= type_area)
51 #define item_is_town(item) ((item).type >= type_town_label && (item).type <= type_district_label_1e7)
52 #define item_is_district(item) ((item).type >= type_district_label && (item).type <= type_district_label_1e7)
53 #define item_is_poly_place(item) ((item).type >= type_poly_place1 && (item).type <= type_poly_place6)
54 #define item_is_point(item) ((item).type < type_line)
55 #define item_is_custom_poi(item) ((item).type >= type_poi_customg && (item).type < type_line)
56 #define item_is_street(item) (((item).type >= type_street_nopass && (item).type <= type_roundabout) \
57  || (item).type == type_street_service \
58  || ((item).type >= type_street_pedestrian && (item).type <= type_track_grass) \
59  || (item).type == type_living_street \
60  || (item).type == type_street_construction \
61  || (item).type == type_path \
62  || (item).type == type_street_parking_lane \
63  || (item).type == type_footway )
64 
65 #define item_is_equal_id(a,b) ((a).id_hi == (b).id_hi && (a).id_lo == (b).id_lo)
66 #define item_is_equal(a,b) (item_is_equal_id(a,b) && (a).map == (b).map)
67 
68 struct coord;
69 
75 };
76 
77 struct item_methods {
78  void (*item_coord_rewind)(void *priv_data);
79  int (*item_coord_get)(void *priv_data, struct coord *c, int count);
80  void (*item_attr_rewind)(void *priv_data);
81  int (*item_attr_get)(void *priv_data, enum attr_type attr_type, struct attr *attr);
82  int (*item_coord_is_node)(void *priv_data);
83  int (*item_attr_set)(void *priv_data, struct attr *attr, enum change_mode mode);
84  int (*item_coord_set)(void *priv_data, struct coord *c, int count, enum change_mode mode);
85  int (*item_type_set)(void *priv_data, enum item_type type);
86  int (*item_coords_left)(void *priv_data);
87 };
88 
89 struct item_id {
90  int id_hi;
91  int id_lo;
92 };
93 
94 #define ITEM_ID_FMT "(0x%x,0x%x)"
95 #define ITEM_ID_ARGS(x) (x).id_hi,(x).id_lo
96 
115 struct item {
116  enum item_type type;
117  int id_hi;
118  int id_lo;
119  struct map *map;
120  struct item_methods *meth;
121  void *priv_data;
122 };
123 
124 extern struct item_range {
125  enum item_type min,max;
127 
134 extern struct item busy_item;
135 
136 /* prototypes */
137 enum attr_type;
138 enum change_mode;
139 enum item_type;
140 enum projection;
141 struct attr;
142 struct coord;
143 struct item;
144 struct item_hash;
145 struct item_range;
146 struct map;
147 struct map_selection;
148 void item_create_hash(void);
149 void item_destroy_hash(void);
151 void item_coord_rewind(struct item *it);
152 int item_coords_left(struct item * it);
153 int item_coord_get(struct item *it, struct coord *c, int count);
154 int item_coord_set(struct item *it, struct coord *c, int count, enum change_mode mode);
155 int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel);
156 int item_coord_get_within_range(struct item *i, struct coord *c, int max, struct coord *start, struct coord *end);
157 int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to);
158 int item_coord_is_node(struct item *it);
159 void item_attr_rewind(struct item *it);
160 int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr);
161 int item_attr_set(struct item *it, struct attr *attr, enum change_mode mode);
162 int item_type_set(struct item *it, enum item_type type);
163 struct item *item_new(char *type, int zoom);
164 enum item_type item_from_name(const char *name);
165 char *item_to_name(enum item_type item);
166 unsigned int item_id_hash(const void *key);
167 int item_id_equal(const void *a, const void *b);
168 void item_id_from_ptr(struct item *item, void *id);
169 struct item_hash *item_hash_new(void);
170 void item_hash_insert(struct item_hash *h, struct item *item, void *val);
171 int item_hash_remove(struct item_hash *h, struct item *item);
172 void *item_hash_lookup(struct item_hash *h, struct item *item);
173 void item_hash_destroy(struct item_hash *h);
174 int item_range_intersects_range(struct item_range *range1, struct item_range *range2);
176 void item_dump_attr(struct item *item, struct map *map, FILE *out);
177 void item_dump_filedesc(struct item *item, struct map *map, FILE *out);
178 void item_cleanup(void);
179 
180 /* end of prototypes */
181 
182 
183 #ifdef __cplusplus
184 }
185 /* __cplusplus */
186 #endif
187 
188 /* NAVIT_ITEM_H */
189 #endif
attr_type
Definition: attr.h:34
#define max(a, b)
Definition: garmin.c:685
unsigned char zoom
Definition: garmin_img.c:0
char type[3]
Definition: garmin_img.c:2
int item_range_intersects_range(struct item_range *range1, struct item_range *range2)
Definition: item.c:579
int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to)
Gets the next coordinates from an item and reprojects them.
Definition: item.c:347
void item_dump_attr(struct item *item, struct map *map, FILE *out)
Definition: item.c:592
int item_range_contains_item(struct item_range *range, enum item_type type)
Definition: item.c:586
void item_attr_rewind(struct item *it)
Resets the "attribute pointer" of an item.
Definition: item.c:387
struct item busy_item
An item indicating that the map driver is busy fetching more items.
Definition: item.c:41
int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr)
Gets the next matching attribute from an item.
Definition: item.c:414
void item_dump_filedesc(struct item *item, struct map *map, FILE *out)
Definition: item.c:599
item_type
Definition: item.h:29
int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel)
Get coordinates within selection This function returns the coordinates of an item if at least one coo...
Definition: item.c:228
change_mode
Definition: item.h:70
@ change_mode_append
Definition: item.h:73
@ change_mode_prepend
Definition: item.h:74
@ change_mode_delete
Definition: item.h:71
@ change_mode_modify
Definition: item.h:72
int item_coord_set(struct item *it, struct coord *c, int count, enum change_mode mode)
Sets coordinates of an item.
Definition: item.c:208
struct item_hash * item_hash_new(void)
Definition: item.c:545
int item_coords_left(struct item *it)
Gets the number of coordinates left for this item.
Definition: item.c:176
int item_hash_remove(struct item_hash *h, struct item *item)
Definition: item.c:559
int item_attr_set(struct item *it, struct attr *attr, enum change_mode mode)
Sets an attribute of an item.
Definition: item.c:440
int item_coord_get_within_range(struct item *i, struct coord *c, int max, struct coord *start, struct coord *end)
Gets all the coordinates of an item within a specified range.
Definition: item.c:304
void item_coord_rewind(struct item *it)
Resets the "coordinate pointer" of an item.
Definition: item.c:137
struct item * item_new(char *type, int zoom)
Definition: item.c:460
void item_cleanup(void)
Definition: item.c:120
void item_create_hash(void)
Definition: item.c:96
int * item_get_default_flags(enum item_type type)
Definition: item.c:109
struct item_range item_range_all
unsigned int item_id_hash(const void *key)
Definition: item.c:511
void item_hash_destroy(struct item_hash *h)
Definition: item.c:574
void * item_hash_lookup(struct item_hash *h, struct item *item)
Definition: item.c:569
int item_id_equal(const void *a, const void *b)
Definition: item.c:516
int item_type_set(struct item *it, enum item_type type)
Sets the type of a map item.
Definition: item.c:454
void item_hash_insert(struct item_hash *h, struct item *item, void *val)
Definition: item.c:552
void item_id_from_ptr(struct item *item, void *id)
Derive item id_lo and id_hi from pointer, considering pointer could be 32 or 64 bit wide but both ids...
Definition: item.c:529
enum item_type item_from_name(const char *name)
Definition: item.c:470
char * item_to_name(enum item_type item)
Definition: item.c:483
int item_coord_get(struct item *it, struct coord *c, int count)
Gets the next coordinates from an item.
Definition: item.c:163
int item_coord_is_node(struct item *it)
Whether the current coordinates of an item correspond to a node.
Definition: item.c:369
void item_destroy_hash(void)
Definition: item.c:104
static struct pcoord c
Definition: popup.c:375
projection
Definition: projection.h:23
char name[0]
Definition: street.c:3
Definition: attr.h:157
Definition: coord.h:34
Definition: item.c:36
Definition: item.c:493
GHashTable * h
Definition: item.c:494
Definition: item.h:89
int id_hi
Definition: item.h:90
int id_lo
Definition: item.h:91
Definition: item.h:77
void(* item_coord_rewind)(void *priv_data)
Definition: item.h:78
int(* item_attr_get)(void *priv_data, enum attr_type attr_type, struct attr *attr)
Definition: item.h:81
int(* item_coords_left)(void *priv_data)
Definition: item.h:86
int(* item_type_set)(void *priv_data, enum item_type type)
Definition: item.h:85
int(* item_attr_set)(void *priv_data, struct attr *attr, enum change_mode mode)
Definition: item.h:83
int(* item_coord_get)(void *priv_data, struct coord *c, int count)
Definition: item.h:79
void(* item_attr_rewind)(void *priv_data)
Definition: item.h:80
int(* item_coord_is_node)(void *priv_data)
Definition: item.h:82
int(* item_coord_set)(void *priv_data, struct coord *c, int count, enum change_mode mode)
Definition: item.h:84
Definition: item.h:124
enum item_type min max
Definition: item.h:125
Represents an object on a map.
Definition: item.h:115
int id_hi
Definition: item.h:117
void * priv_data
Definition: item.h:121
enum item_type type
Definition: item.h:116
int id_lo
Definition: item.h:118
struct map * map
Definition: item.h:119
struct item_methods * meth
Definition: item.h:120
Used to select data from a map.
Definition: map.h:58
Definition: map.c:55
Definition: attr.h:153
unsigned char key
Definition: tree.c:0