"Fossies" - the Fresh Open Source Software Archive

Member "navit-0.5.6/navit/item.h" (6 Mar 2021, 7869 Bytes) of package /linux/privat/navit-0.5.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "item.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 0.5.5_vs_0.5.6.

    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_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 
   70 enum change_mode {
   71     change_mode_delete,
   72     change_mode_modify,
   73     change_mode_append,
   74     change_mode_prepend,
   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 
   97 /**
   98  * @brief Represents an object on a map.
   99  *
  100  * An item holds the data for an individual item on a map, including its coordinates and various attributes. The item
  101  * type specifies what the map item refers to, such as a POI, a building, a way or a boundary. There are also special
  102  * item types used internally, such as the various kinds of turn instructions. Item types are internally represented as
  103  * numbers.
  104  *
  105  * Outside map implementations, items are generally retrieved from map rectangles, and their methods are implemented by
  106  * the respective map driver. Items retrieved from a map rectangle are generally short-lived: a previously retrieved
  107  * item should be considered invalid when a new item is retrieved from the same map rectangle, or after its map
  108  * rectangle has been destroyed. After that, functions may segfault or return invalid data, and even the item itself
  109  * may have been deallocated.
  110  *
  111  * Actual behavior may differ between map implementations, but do not rely on any behavior not covered by the above
  112  * interface contract. Exceptions apply, of course, for code that is limited to working with items from one particular
  113  * map (typically inside a map implementation).
  114  */
  115 struct item {
  116     enum item_type type; /**< Type of the item.*/
  117     int id_hi;  /**< First part of the ID of the item (item IDs have two parts).*/
  118     int id_lo; /**< Second part of the ID of the item.*/
  119     struct map *map; /**< The map this items belongs to.*/
  120     struct item_methods *meth; /**< Methods to manipulate this item.*/
  121     void *priv_data; /**< Private item data, only used by the map plugin which supplied this item.*/
  122 };
  123 
  124 extern struct item_range {
  125     enum item_type min,max;
  126 } item_range_all;
  127 
  128 /**
  129  * @brief An item indicating that the map driver is busy fetching more items.
  130  *
  131  * This is a “magic” item which may be returned by one of the query methods of a map driver. Receiving this item means
  132  * that the map driver is currently busy fetching more items, and they can be retrieved at a later point in time.
  133  */
  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);
  150 int *item_get_default_flags(enum item_type type);
  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);
  175 int item_range_contains_item(struct item_range *range, enum item_type type);
  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