Diff of /trunk/src/osm.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by achadwick, Wed Dec 10 00:00:05 2008 UTC revision 153 by harbaum, Mon Mar 30 11:14:20 2009 UTC
# Line 27  Line 27 
27  #define OSM_FLAG_NEW      (1<<2)  #define OSM_FLAG_NEW      (1<<2)
28  #define OSM_FLAG_HIDDEN   (1<<3)  #define OSM_FLAG_HIDDEN   (1<<3)
29    
30  typedef gulong item_id_t;  /* item_id_t needs to be signed as osm2go uses negative ids for items */
31    /* not yet registered with the main osm database */
32    typedef glong item_id_t;
33    #define G_TYPE_ITEM_ID_T G_TYPE_LONG
34    
35  #define ID_ILLEGAL  ((item_id_t)0)  #define ID_ILLEGAL  ((item_id_t)0)
36    
# Line 95  typedef struct way_s { Line 98  typedef struct way_s {
98      gulong color;      gulong color;
99      gint width;      gint width;
100      float zoom_max;      float zoom_max;
101        gboolean dashed;
102        guint dash_length;
103    
104      union {      union {
105        struct {        struct {
# Line 136  typedef struct relation_chain_s { Line 141  typedef struct relation_chain_s {
141    struct relation_chain_s *next;    struct relation_chain_s *next;
142  } relation_chain_t;  } relation_chain_t;
143    
144    /* two of these hash tables are used, one for nodes and one for ways */
145    /* currently relations aren't used often enough to justify the use */
146    /* of a hash table */
147    
148    /* the current hash table uses 16 bits. each table thus is */
149    /* 256 kbytes (2^16 * sizeof(void*)) in size */
150    #define ID2HASH(a) ((unsigned short)(a) ^ (unsigned short)((a)>>16))
151    
152    typedef struct hash_item_s {
153      union {
154        node_t *node;
155        way_t *way;
156        relation_t *relation;
157      } data;
158    
159      struct hash_item_s *next;
160    } hash_item_t;
161    
162    typedef struct {
163      hash_item_t *hash[65536];
164    } hash_table_t;
165    
166  typedef enum {  typedef enum {
167    ILLEGAL=0, NODE, WAY, RELATION, NODE_ID, WAY_ID, RELATION_ID    ILLEGAL=0, NODE, WAY, RELATION, NODE_ID, WAY_ID, RELATION_ID
168  } type_t;  } type_t;
169    
170    typedef struct {
171      type_t type;
172      union {
173        node_t *node;
174        way_t *way;
175        relation_t *relation;
176      };
177    } object_t;
178    
179  typedef struct member_s {  typedef struct member_s {
180    type_t type;    type_t type;
181    char   *role;    char   *role;
# Line 148  typedef struct member_s { Line 184  typedef struct member_s {
184      node_t *node;      node_t *node;
185      way_t *way;      way_t *way;
186      relation_t *relation;      relation_t *relation;
187        void *ptr;
188      item_id_t id;      item_id_t id;
189    };    };
190    
# Line 157  typedef struct member_s { Line 194  typedef struct member_s {
194  typedef struct osm_s {  typedef struct osm_s {
195    bounds_t *bounds;   // original bounds as they appear in the file    bounds_t *bounds;   // original bounds as they appear in the file
196    user_t *user;    user_t *user;
197    
198    node_t *node;    node_t *node;
199      hash_table_t *node_hash;
200    
201    way_t  *way;    way_t  *way;
202      hash_table_t *way_hash;
203    
204      // hashing relations doesn't yet make much sense as relations are quite rare
205    relation_t  *relation;    relation_t  *relation;
206    
207  } osm_t;  } osm_t;
208    
209  #include <libxml/parser.h>  #include <libxml/parser.h>
# Line 217  way_chain_t *osm_node_to_way(osm_t *osm, Line 261  way_chain_t *osm_node_to_way(osm_t *osm,
261  /* ----------- edit functions ----------- */  /* ----------- edit functions ----------- */
262  node_t *osm_node_new(osm_t *osm, gint x, gint y);  node_t *osm_node_new(osm_t *osm, gint x, gint y);
263  void osm_node_attach(osm_t *osm, node_t *node);  void osm_node_attach(osm_t *osm, node_t *node);
264    void osm_node_restore(osm_t *osm, node_t *node);
265  way_chain_t *osm_node_delete(osm_t *osm, struct icon_s **icon, node_t *node,  way_chain_t *osm_node_delete(osm_t *osm, struct icon_s **icon, node_t *node,
266                               gboolean permanently, gboolean affect_ways);                               gboolean permanently, gboolean affect_ways);
267  void osm_way_delete(osm_t *osm, struct icon_s **icon, way_t *way,  void osm_way_delete(osm_t *osm, struct icon_s **icon, way_t *way,
# Line 229  gboolean osm_position_within_bounds(osm_ Line 274  gboolean osm_position_within_bounds(osm_
274  item_id_t osm_new_way_id(osm_t *osm);  item_id_t osm_new_way_id(osm_t *osm);
275  gboolean osm_way_ends_with_node(way_t *way, node_t *node);  gboolean osm_way_ends_with_node(way_t *way, node_t *node);
276    
277  void osm_way_revert(way_t *way);  void osm_way_reverse(way_t *way);
278    guint osm_way_reverse_direction_sensitive_tags(way_t *way);
279    guint osm_way_reverse_direction_sensitive_roles(osm_t *osm, way_t *way);
280    
281  void osm_node_remove_from_relation(osm_t *osm, node_t *node);  void osm_node_remove_from_relation(osm_t *osm, node_t *node);
282  void osm_way_remove_from_relation(osm_t *osm, way_t *way);  void osm_way_remove_from_relation(osm_t *osm, way_t *way);
# Line 240  void osm_way_rotate(way_t *way, gint off Line 287  void osm_way_rotate(way_t *way, gint off
287    
288  tag_t *osm_tags_copy(tag_t *tag, gboolean update_creator);  tag_t *osm_tags_copy(tag_t *tag, gboolean update_creator);
289    
290    char *osm_type_string(type_t type);
291    char *osm_id_string(type_t type, void *object);
292    char *osm_object_string(type_t type, void *object);
293    tag_t *osm_object_get_tags(type_t type, void *object);
294    
295    relation_t *osm_relation_new(void);
296    void osm_relation_free(relation_t *relation);
297    void osm_relation_attach(osm_t *osm, relation_t *relation);
298    void osm_relation_delete(osm_t *osm, relation_t *relation,
299                             gboolean permanently);
300    gint osm_relation_members_num(relation_t *relation);
301    
302    void osm_object_set_flags(object_t *map_item, int set, int clr);
303    
304  #endif /* OSM_H */  #endif /* OSM_H */
305    
306    // vim:et:ts=8:sw=2:sts=2:ai

Legend:
Removed from v.2  
changed lines
  Added in v.153