navit 0.5.3-trunk
Loading...
Searching...
No Matches
item.h
Go to the documentation of this file.
1
20#ifndef NAVIT_ITEM_H
21#define NAVIT_ITEM_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include <stdio.h>
28#include "item_type_def.h"
29
30#define route_item_first type_street_0
31#define route_item_last type_street_parking_lane
32extern int default_flags[];
33
34#include "attr.h"
35
36
37/* NOTE: we treat districts as towns for now, since
38 a) navit does not implement district search yet
39 b) OSM "place=suburb" maps to type_district in maptool. with the OSM USA maps,
40 there are many "suburbs" that users will consider towns (not districts/counties);
41 we want navit's town search to find them
42*/
43#define item_type_is_area(type) ((type) >= type_area)
44#define item_is_town(item) ((item).type >= type_town_label && (item).type <= type_district_label_1e7)
45#define item_is_district(item) ((item).type >= type_district_label && (item).type <= type_district_label_1e7)
46#define item_is_poly_place(item) ((item).type >= type_poly_place1 && (item).type <= type_poly_place6)
47#define item_is_point(item) ((item).type < type_line)
48#define item_is_custom_poi(item) ((item).type >= type_poi_customg && (item).type < type_line)
49#define item_is_street(item) (((item).type >= type_street_nopass && (item).type <= type_roundabout) \
50 || (item).type == type_street_service \
51 || ((item).type >= type_street_pedestrian && (item).type <= type_track_grass) \
52 || (item).type == type_living_street \
53 || (item).type == type_street_construction \
54 || (item).type == type_path \
55 || (item).type == type_street_parking_lane \
56 || (item).type == type_footway )
63#define item_is_poi(item) (((item).type >= type_poi_lake && (item).type <= type_poi) \
64 || ((item).type >= type_poi_land_feature && (item).type <= type_poi_zoo) \
65 || ((item).type >= type_poi_gc_multi && (item).type <= type_poi_cafe) \
66 || ((item).type >= type_poi_peak && (item).type <= type_poi_image) \
67 || ((item).type >= type_poi_townhall && (item).type <= type_poi_ruins) \
68 || ((item).type >= type_poi_post_box && (item).type <= type_poi_tennis) \
69 || ((item).type >= type_poi_vending_machine && (item).type <= type_poi_shop_shoes) \
70 || ((item).type >= type_poi_tree && (item).type <= type_poi_shop_photo) \
71 || ((item).type >= type_poi_pub && (item).type <= type_poi_bahai) \
72 || ((item).type >= type_poi_customh && (item).type <= type_poi_customf))
73
74#define item_is_equal_id(a,b) ((a).id_hi == (b).id_hi && (a).id_lo == (b).id_lo)
75#define item_is_equal(a,b) (item_is_equal_id(a,b) && (a).map == (b).map)
76
77struct coord;
78
85
87 void (*item_coord_rewind)(void *priv_data);
88 int (*item_coord_get)(void *priv_data, struct coord *c, int count);
89 void (*item_attr_rewind)(void *priv_data);
90 int (*item_attr_get)(void *priv_data, enum attr_type attr_type, struct attr *attr);
91 int (*item_coord_is_node)(void *priv_data);
92 int (*item_attr_set)(void *priv_data, struct attr *attr, enum change_mode mode);
93 int (*item_coord_set)(void *priv_data, struct coord *c, int count, enum change_mode mode);
94 int (*item_type_set)(void *priv_data, enum item_type type);
95 int (*item_coords_left)(void *priv_data);
96};
97
98struct item_id {
99 int id_hi;
100 int id_lo;
101};
102
103#define ITEM_ID_FMT "(0x%x,0x%x)"
104#define ITEM_ID_ARGS(x) (x).id_hi,(x).id_lo
105
124struct item {
126 int id_hi;
127 int id_lo;
128 struct map *map;
130 void *priv_data;
131};
132
133extern struct item_range {
134 enum item_type min,max;
136
143extern struct item busy_item;
144
145/* prototypes */
146enum attr_type;
147enum change_mode;
148enum item_type;
149enum projection;
150struct attr;
151struct coord;
152struct item;
153struct item_hash;
154struct item_range;
155struct map;
156struct map_selection;
157void item_create_hash(void);
158void item_destroy_hash(void);
160void item_coord_rewind(struct item *it);
161int item_coords_left(struct item * it);
162int item_coord_get(struct item *it, struct coord *c, int count);
163int item_coord_set(struct item *it, struct coord *c, int count, enum change_mode mode);
164int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel);
165int item_coord_get_within_range(struct item *i, struct coord *c, int max, struct coord *start, struct coord *end);
166int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to);
167int item_coord_is_node(struct item *it);
168void item_attr_rewind(struct item *it);
169int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr);
170int item_attr_set(struct item *it, struct attr *attr, enum change_mode mode);
171int item_type_set(struct item *it, enum item_type type);
172struct item *item_new(char *type, int zoom);
173enum item_type item_from_name(const char *name);
174char *item_to_name(enum item_type item);
175unsigned int item_id_hash(const void *key);
176int item_id_equal(const void *a, const void *b);
177void item_id_from_ptr(struct item *item, void *id);
178struct item_hash *item_hash_new(void);
179void item_hash_insert(struct item_hash *h, struct item *item, void *val);
180int item_hash_remove(struct item_hash *h, struct item *item);
181void *item_hash_lookup(struct item_hash *h, struct item *item);
182void item_hash_destroy(struct item_hash *h);
183int item_range_intersects_range(struct item_range *range1, struct item_range *range2);
185void item_dump_attr(struct item *item, struct map *map, FILE *out);
186void item_dump_filedesc(struct item *item, struct map *map, FILE *out);
187void item_cleanup(void);
188
189/* end of prototypes */
190
191
192#ifdef __cplusplus
193}
194/* __cplusplus */
195#endif
196
197/* NAVIT_ITEM_H */
198#endif
attr_type
Definition attr_type_def.h:11
#define max(a, b)
Definition garmin.c:691
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
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:79
@ change_mode_append
Definition item.h:82
@ change_mode_prepend
Definition item.h:83
@ change_mode_delete
Definition item.h:80
@ change_mode_modify
Definition item.h:81
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
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
char * item_to_name(enum item_type item)
Definition item.c:483
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
int * item_get_default_flags(enum item_type type)
Definition item.c:109
void item_coord_rewind(struct item *it)
Resets the "coordinate pointer" of an item.
Definition item.c:137
void item_cleanup(void)
Definition item.c:120
void item_create_hash(void)
Definition item.c:96
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
struct item_hash * item_hash_new(void)
Definition item.c:545
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
struct item * item_new(char *type, int zoom)
Definition item.c:460
void * item_hash_lookup(struct item_hash *h, struct item *item)
Definition item.c:569
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
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
item_type
Definition item_type_def.h:8
static struct pcoord c
Definition popup.c:375
projection
Definition projection.h:23
char name[0]
Definition street.c:3
Definition attr.h:136
Definition coord.h:34
Definition item.c:36
Definition item.c:493
GHashTable * h
Definition item.c:494
Definition item.h:98
int id_hi
Definition item.h:99
int id_lo
Definition item.h:100
Definition item.h:86
void(* item_coord_rewind)(void *priv_data)
Definition item.h:87
int(* item_attr_get)(void *priv_data, enum attr_type attr_type, struct attr *attr)
Definition item.h:90
int(* item_coords_left)(void *priv_data)
Definition item.h:95
int(* item_type_set)(void *priv_data, enum item_type type)
Definition item.h:94
int(* item_attr_set)(void *priv_data, struct attr *attr, enum change_mode mode)
Definition item.h:92
int(* item_coord_get)(void *priv_data, struct coord *c, int count)
Definition item.h:88
void(* item_attr_rewind)(void *priv_data)
Definition item.h:89
int(* item_coord_is_node)(void *priv_data)
Definition item.h:91
int(* item_coord_set)(void *priv_data, struct coord *c, int count, enum change_mode mode)
Definition item.h:93
Definition item.h:133
enum item_type min max
Definition item.h:134
Represents an object on a map.
Definition item.h:124
int id_hi
Definition item.h:126
void * priv_data
Definition item.h:130
enum item_type type
Definition item.h:125
int id_lo
Definition item.h:127
struct map * map
Definition item.h:128
struct item_methods * meth
Definition item.h:129
Used to select data from a map.
Definition map.h:58
Definition map.c:55
Definition attr.h:132
unsigned char key
Definition tree.c:0