navit  0.5.1-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
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 };
87 
88 struct item_id {
89  int id_hi;
90  int id_lo;
91 };
92 
93 #define ITEM_ID_FMT "(0x%x,0x%x)"
94 #define ITEM_ID_ARGS(x) (x).id_hi,(x).id_lo
95 
99 struct item {
101  int id_hi;
102  int id_lo;
103  struct map *map;
104  struct item_methods *meth;
105  void *priv_data;
106 };
107 
108 extern struct item_range {
109  enum item_type min,max;
111 
112 extern struct item busy_item;
113 
114 /* prototypes */
115 enum attr_type;
116 enum change_mode;
117 enum item_type;
118 enum projection;
119 struct attr;
120 struct coord;
121 struct item;
122 struct item_hash;
123 struct item_range;
124 struct map;
125 struct map_selection;
126 void item_create_hash(void);
127 void item_destroy_hash(void);
129 void item_coord_rewind(struct item *it);
130 int item_coord_get(struct item *it, struct coord *c, int count);
131 int item_coord_set(struct item *it, struct coord *c, int count, enum change_mode mode);
132 int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel);
133 int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to);
134 int item_coord_is_node(struct item *it);
135 void item_attr_rewind(struct item *it);
136 int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr);
137 int item_attr_set(struct item *it, struct attr *attr, enum change_mode mode);
138 int item_type_set(struct item *it, enum item_type type);
139 struct item *item_new(char *type, int zoom);
140 enum item_type item_from_name(const char *name);
141 char *item_to_name(enum item_type item);
142 unsigned int item_id_hash(const void *key);
143 int item_id_equal(const void *a, const void *b);
144 void item_id_from_ptr(struct item *item, void *id);
145 struct item_hash *item_hash_new(void);
146 void item_hash_insert(struct item_hash *h, struct item *item, void *val);
147 int item_hash_remove(struct item_hash *h, struct item *item);
148 void *item_hash_lookup(struct item_hash *h, struct item *item);
149 void item_hash_destroy(struct item_hash *h);
150 int item_range_intersects_range(struct item_range *range1, struct item_range *range2);
152 void item_dump_attr(struct item *item, struct map *map, FILE *out);
153 void item_dump_filedesc(struct item *item, struct map *map, FILE *out);
154 void item_cleanup(void);
155 
156 /* end of prototypes */
157 
158 
159 #ifdef __cplusplus
160 }
161 /* __cplusplus */
162 #endif
163 
164 /* NAVIT_ITEM_H */
165 #endif
int(* item_type_set)(void *priv_data, enum item_type type)
Definition: item.h:85
attr_type
Definition: attr.h:34
void item_hash_insert(struct item_hash *h, struct item *item, void *val)
Definition: item.c:392
struct map * map
Definition: item.h:103
change_mode
Definition: item.h:70
void item_dump_attr(struct item *item, struct map *map, FILE *out)
Definition: item.c:444
Definition: item.h:99
void item_hash_destroy(struct item_hash *h)
Definition: item.c:420
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:366
Definition: item.h:74
void item_coord_rewind(struct item *it)
Resets the "coordinate pointer" of an item.
Definition: item.c:143
item_type
Definition: item.h:29
unsigned char zoom
Definition: garmin_img.c:509
Definition: item.c:321
int item_coord_is_node(struct item *it)
Definition: item.c:242
enum item_type type
Definition: item.h:100
Definition: item.h:88
GHashTable * h
Definition: item.c:322
int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel)
Definition: item.c:182
Definition: item.h:108
int item_id_equal(const void *a, const void *b)
Definition: item.c:351
int(* item_coord_set)(void *priv_data, struct coord *c, int count, enum change_mode mode)
Definition: item.h:84
void item_create_hash(void)
Definition: item.c:97
struct item_methods * meth
Definition: item.h:104
int mode
Definition: graphics_win32.c:59
struct item_hash * item_hash_new(void)
Definition: item.c:383
int(* item_coord_get)(void *priv_data, struct coord *c, int count)
Definition: item.h:79
int item_type_set(struct item *it, enum item_type type)
Set map item type.
Definition: item.c:276
int item_coord_get(struct item *it, struct coord *c, int count)
Gets the next coordinates from an item.
Definition: item.c:168
struct item busy_item
Definition: item.c:41
projection
Definition: projection.h:23
void item_cleanup(void)
Definition: item.c:127
void(* item_coord_rewind)(void *priv_data)
Definition: item.h:78
int item_attr_set(struct item *it, struct attr *attr, enum change_mode mode)
Definition: item.c:262
int id_lo
Definition: item.h:102
void item_destroy_hash(void)
Definition: item.c:107
enum item_type item_from_name(const char *name)
Definition: item.c:295
unsigned char key
Definition: tree.c:65
Definition: attr.h:152
Definition: attr.h:156
Used to select data from a map.
Definition: map.h:57
int * item_get_default_flags(enum item_type type)
Definition: item.c:114
void item_attr_rewind(struct item *it)
Definition: item.c:250
int id_hi
Definition: item.h:89
int item_range_contains_item(struct item_range *range, enum item_type type)
Definition: item.c:436
Definition: item.h:73
Definition: item.h:77
int(* item_coord_is_node)(void *priv_data)
Definition: item.h:82
void * item_hash_lookup(struct item_hash *h, struct item *item)
Definition: item.c:413
int item_coord_set(struct item *it, struct coord *c, int count, enum change_mode mode)
Definition: item.c:174
Holds information about a map.
Definition: map.c:60
int(* item_attr_set)(void *priv_data, struct attr *attr, enum change_mode mode)
Definition: item.h:83
int item_range_intersects_range(struct item_range *range1, struct item_range *range2)
Definition: item.c:427
char * item_to_name(enum item_type item)
Definition: item.c:310
struct item_range item_range_all
int(* item_attr_get)(void *priv_data, enum attr_type attr_type, struct attr *attr)
Definition: item.h:81
void(* item_attr_rewind)(void *priv_data)
Definition: item.h:80
Definition: item.c:36
unsigned int item_id_hash(const void *key)
Definition: item.c:344
Definition: item.h:72
typedef int(WINAPI *FP_SetStretchBltMode)(HDC dc
int id_lo
Definition: item.h:90
char type[3]
Definition: garmin_img.c:130
Definition: coord.h:34
char name[0]
Definition: street.c:559
struct item * item_new(char *type, int zoom)
Definition: item.c:283
int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr)
Definition: item.c:256
int item_hash_remove(struct item_hash *h, struct item *item)
Definition: item.c:401
Definition: item.h:71
void * priv_data
Definition: item.h:105
void item_dump_filedesc(struct item *item, struct map *map, FILE *out)
Definition: item.c:453
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:230
enum item_type min max
Definition: item.h:109
int id_hi
Definition: item.h:101