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 |
#define route_item_first type_street_0
|
38 |
#define route_item_last type_footway_and_piste_nordic
|
39 |
extern int default_flags[];
|
40 |
|
41 |
#include "attr.h"
|
42 |
|
43 |
|
44 |
/* NOTE OLD: 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 |
NOTE NEW: oct.2012: now we DONT treat districts as towns
|
51 |
|
52 |
*/
|
53 |
#define item_type_is_area(type) ((type) >= type_area)
|
54 |
#define item_is_town(item) ((item).type >= type_town_label && (item).type < type_district_label)
|
55 |
#define item_is_district(item) ((item).type >= type_district_label && (item).type <= type_district_label_1e7)
|
56 |
#define item_is_poly_place(item) ((item).type >= type_poly_place1 && (item).type <= type_poly_place6)
|
57 |
#define item_is_point(item) ((item).type < type_line)
|
58 |
#define item_is_custom_poi(item) ((item).type >= type_poi_custom0 && (item).type < type_line)
|
59 |
#define item_is_street(item) (((item).type >= type_street_0 && (item).type < type_street_1_land) \
|
60 |
|| (item).type == type_street_pedestrian \
|
61 |
|| (item).type == type_living_street)
|
62 |
|
63 |
#define item_is_equal_id(a,b) ((a).id_hi == (b).id_hi && (a).id_lo == (b).id_lo)
|
64 |
#define item_is_equal(a,b) (item_is_equal_id(a,b) && (a).map == (b).map)
|
65 |
|
66 |
struct coord;
|
67 |
|
68 |
enum change_mode {
|
69 |
change_mode_delete,
|
70 |
change_mode_modify,
|
71 |
change_mode_append,
|
72 |
change_mode_prepend,
|
73 |
};
|
74 |
|
75 |
struct item_methods {
|
76 |
void (*item_coord_rewind)(void *priv_data);
|
77 |
int (*item_coord_get)(void *priv_data, struct coord *c, int count);
|
78 |
void (*item_attr_rewind)(void *priv_data);
|
79 |
int (*item_attr_get)(void *priv_data, enum attr_type attr_type, struct attr *attr);
|
80 |
int (*item_coord_is_node)(void *priv_data);
|
81 |
int (*item_attr_set)(void *priv_data, struct attr *attr, enum change_mode mode);
|
82 |
int (*item_coord_set)(void *priv_data, struct coord *c, int count, enum change_mode mode);
|
83 |
int (*item_type_set)(void *priv_data, enum item_type type);
|
84 |
};
|
85 |
|
86 |
struct item_id {
|
87 |
int id_hi;
|
88 |
int id_lo;
|
89 |
};
|
90 |
|
91 |
#define ITEM_ID_FMT "(0x%x,0x%x)"
|
92 |
#define ITEM_ID_ARGS(x) (x).id_hi,(x).id_lo
|
93 |
|
94 |
struct item {
|
95 |
enum item_type type;
|
96 |
int id_hi;
|
97 |
int id_lo;
|
98 |
struct map *map;
|
99 |
struct item_methods *meth;
|
100 |
void *priv_data;
|
101 |
// added flags from attr!! --> Zoff
|
102 |
long flags;
|
103 |
};
|
104 |
|
105 |
extern struct item_range {
|
106 |
enum item_type min,max;
|
107 |
} item_range_all;
|
108 |
|
109 |
extern struct item busy_item;
|
110 |
|
111 |
/* prototypes */
|
112 |
enum attr_type;
|
113 |
enum change_mode;
|
114 |
enum item_type;
|
115 |
enum projection;
|
116 |
struct attr;
|
117 |
struct coord;
|
118 |
struct item;
|
119 |
struct item_hash;
|
120 |
struct item_range;
|
121 |
struct map;
|
122 |
struct map_selection;
|
123 |
int *item_get_default_flags(enum item_type type);
|
124 |
void item_coord_rewind(struct item *it);
|
125 |
int item_coord_get(struct item *it, struct coord *c, int count);
|
126 |
int item_coord_set(struct item *it, struct coord *c, int count, enum change_mode mode);
|
127 |
int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel);
|
128 |
int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to);
|
129 |
int item_coord_is_node(struct item *it);
|
130 |
void item_attr_rewind(struct item *it);
|
131 |
int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr);
|
132 |
int item_attr_set(struct item *it, struct attr *attr, enum change_mode mode);
|
133 |
struct item *item_new(char *type, int zoom);
|
134 |
enum item_type item_from_name(const char *name);
|
135 |
char *item_to_name(enum item_type item);
|
136 |
unsigned int item_id_hash(const void *key);
|
137 |
int item_id_equal(const void *a, const void *b);
|
138 |
struct item_hash *item_hash_new(void);
|
139 |
void item_hash_insert(struct item_hash *h, struct item *item, void *val);
|
140 |
int item_hash_remove(struct item_hash *h, struct item *item);
|
141 |
void *item_hash_lookup(struct item_hash *h, struct item *item);
|
142 |
void item_hash_destroy(struct item_hash *h);
|
143 |
int item_range_intersects_range(struct item_range *range1, struct item_range *range2);
|
144 |
int item_range_contains_item(struct item_range *range, enum item_type type);
|
145 |
void item_dump_attr(struct item *item, struct map *map, FILE *out);
|
146 |
void item_dump_filedesc(struct item *item, struct map *map, FILE *out);
|
147 |
void item_cleanup(void);
|
148 |
|
149 |
void item_dump_attr_stdout(struct item *item, struct map *map);
|
150 |
|
151 |
/* end of prototypes */
|
152 |
|
153 |
|
154 |
#ifdef __cplusplus
|
155 |
}
|
156 |
/* __cplusplus */
|
157 |
#endif
|
158 |
|
159 |
/* NAVIT_ITEM_H */
|
160 |
#endif
|