Navit SVN

/work/compile/navit/src/navit/item.h

00001 
00020 #ifndef NAVIT_ITEM_H
00021 #define NAVIT_ITEM_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 #include <stdio.h>
00028 
00029 enum item_type {
00030 #define ITEM2(x,y) type_##y=x,
00031 #define ITEM(x) type_##x,
00032 #include "item_def.h"
00033 #undef ITEM2
00034 #undef ITEM
00035 };
00036 
00037 #define route_item_first type_street_0
00038 #define route_item_last type_path
00039 extern int default_flags[];
00040 
00041 #include "attr.h"
00042 
00043 
00044 /* NOTE: we treat districts as towns for now, since
00045    a) navit does not implement district search yet
00046    b) OSM "place=suburb" maps to type_district in maptool. with the OSM USA maps,
00047       there are many "suburbs" that users will consider towns (not districts/counties);
00048       we want navit's town search to find them
00049 */
00050 #define item_type_is_area(type) ((type) >= type_area)
00051 #define item_is_town(item) ((item).type >= type_town_label && (item).type <= type_district_label_1e7)
00052 #define item_is_district(item) ((item).type >= type_district_label && (item).type <= type_district_label_1e7)
00053 #define item_is_poly_place(item) ((item).type >= type_poly_place1 && (item).type <= type_poly_place6)
00054 #define item_is_point(item) ((item).type < type_line) 
00055 #define item_is_custom_poi(item) ((item).type >= type_poi_custom0 && (item).type < type_line)
00056 #define item_is_street(item) (((item).type >= type_street_0 && (item).type < type_street_1_land) \
00057                                ||  (item).type == type_street_pedestrian \
00058                                ||  (item).type == type_living_street  \
00059                                ||  (item).type == type_footway)
00060 
00061 #define item_is_equal_id(a,b) ((a).id_hi == (b).id_hi && (a).id_lo == (b).id_lo)
00062 #define item_is_equal(a,b) (item_is_equal_id(a,b) && (a).map == (b).map)
00063 
00064 struct coord;
00065 
00066 enum change_mode {
00067         change_mode_delete,
00068         change_mode_modify,
00069         change_mode_append,
00070         change_mode_prepend,
00071 };
00072 
00073 struct item_methods {
00074         void (*item_coord_rewind)(void *priv_data);
00075         int (*item_coord_get)(void *priv_data, struct coord *c, int count);
00076         void (*item_attr_rewind)(void *priv_data);
00077         int (*item_attr_get)(void *priv_data, enum attr_type attr_type, struct attr *attr);
00078         int (*item_coord_is_node)(void *priv_data);
00079         int (*item_attr_set)(void *priv_data, struct attr *attr, enum change_mode mode);
00080         int (*item_coord_set)(void *priv_data, struct coord *c, int count, enum change_mode mode);
00081         int (*item_type_set)(void *priv_data, enum item_type type);
00082 };
00083 
00084 struct item_id {
00085         int id_hi;
00086         int id_lo;
00087 };
00088 
00089 #define ITEM_ID_FMT "(0x%x,0x%x)"
00090 #define ITEM_ID_ARGS(x) (x).id_hi,(x).id_lo
00091 
00092 struct item {
00093         enum item_type type;
00094         int id_hi;
00095         int id_lo;
00096         struct map *map;
00097         struct item_methods *meth;
00098         void *priv_data;
00099 };
00100 
00101 extern struct item_range {
00102         enum item_type min,max;
00103 } item_range_all;
00104 
00105 extern struct item busy_item;
00106 
00107 /* prototypes */
00108 enum attr_type;
00109 enum change_mode;
00110 enum item_type;
00111 enum projection;
00112 struct attr;
00113 struct coord;
00114 struct item;
00115 struct item_hash;
00116 struct item_range;
00117 struct map;
00118 struct map_selection;
00119 int *item_get_default_flags(enum item_type type);
00120 void item_coord_rewind(struct item *it);
00121 int item_coord_get(struct item *it, struct coord *c, int count);
00122 int item_coord_set(struct item *it, struct coord *c, int count, enum change_mode mode);
00123 int item_coord_get_within_selection(struct item *it, struct coord *c, int count, struct map_selection *sel);
00124 int item_coord_get_pro(struct item *it, struct coord *c, int count, enum projection to);
00125 int item_coord_is_node(struct item *it);
00126 void item_attr_rewind(struct item *it);
00127 int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr);
00128 int item_attr_set(struct item *it, struct attr *attr, enum change_mode mode);
00129 int item_type_set(struct item *it, enum item_type type);
00130 struct item *item_new(char *type, int zoom);
00131 enum item_type item_from_name(const char *name);
00132 char *item_to_name(enum item_type item);
00133 unsigned int item_id_hash(const void *key);
00134 int item_id_equal(const void *a, const void *b);
00135 struct item_hash *item_hash_new(void);
00136 void item_hash_insert(struct item_hash *h, struct item *item, void *val);
00137 int item_hash_remove(struct item_hash *h, struct item *item);
00138 void *item_hash_lookup(struct item_hash *h, struct item *item);
00139 void item_hash_destroy(struct item_hash *h);
00140 int item_range_intersects_range(struct item_range *range1, struct item_range *range2);
00141 int item_range_contains_item(struct item_range *range, enum item_type type);
00142 void item_dump_attr(struct item *item, struct map *map, FILE *out);
00143 void item_dump_filedesc(struct item *item, struct map *map, FILE *out);
00144 void item_cleanup(void);
00145 
00146 /* end of prototypes */
00147 
00148 
00149 #ifdef __cplusplus
00150 }
00151 /* __cplusplus */
00152 #endif
00153 
00154 /* NAVIT_ITEM_H */
00155 #endif