28 |
#define OSM_FLAG_HIDDEN (1<<3) |
#define OSM_FLAG_HIDDEN (1<<3) |
29 |
|
|
30 |
typedef gulong item_id_t; |
typedef gulong item_id_t; |
31 |
|
#define G_TYPE_ITEM_ID_T G_TYPE_ULONG |
32 |
|
|
33 |
#define ID_ILLEGAL ((item_id_t)0) |
#define ID_ILLEGAL ((item_id_t)0) |
34 |
|
|
97 |
gint width; |
gint width; |
98 |
float zoom_max; |
float zoom_max; |
99 |
gboolean dashed; |
gboolean dashed; |
100 |
|
guint dash_length; |
101 |
|
|
102 |
union { |
union { |
103 |
struct { |
struct { |
139 |
struct relation_chain_s *next; |
struct relation_chain_s *next; |
140 |
} relation_chain_t; |
} relation_chain_t; |
141 |
|
|
142 |
|
/* two of these hash tables are used, one for nodes and one for ways */ |
143 |
|
/* currently relations aren't used often enough to justify the use */ |
144 |
|
/* of a hash table */ |
145 |
|
|
146 |
|
/* the current hash table uses 16 bits. each table thus is */ |
147 |
|
/* 256 kbytes (2^16 * sizeof(void*)) in size */ |
148 |
|
#define ID2HASH(a) ((unsigned short)(a) ^ (unsigned short)((a)>>16)) |
149 |
|
|
150 |
|
typedef struct hash_item_s { |
151 |
|
union { |
152 |
|
node_t *node; |
153 |
|
way_t *way; |
154 |
|
relation_t *relation; |
155 |
|
} data; |
156 |
|
|
157 |
|
struct hash_item_s *next; |
158 |
|
} hash_item_t; |
159 |
|
|
160 |
|
typedef struct { |
161 |
|
hash_item_t *hash[65536]; |
162 |
|
} hash_table_t; |
163 |
|
|
164 |
typedef enum { |
typedef enum { |
165 |
ILLEGAL=0, NODE, WAY, RELATION, NODE_ID, WAY_ID, RELATION_ID |
ILLEGAL=0, NODE, WAY, RELATION, NODE_ID, WAY_ID, RELATION_ID |
166 |
} type_t; |
} type_t; |
173 |
node_t *node; |
node_t *node; |
174 |
way_t *way; |
way_t *way; |
175 |
relation_t *relation; |
relation_t *relation; |
176 |
|
void *ptr; |
177 |
item_id_t id; |
item_id_t id; |
178 |
}; |
}; |
179 |
|
|
183 |
typedef struct osm_s { |
typedef struct osm_s { |
184 |
bounds_t *bounds; // original bounds as they appear in the file |
bounds_t *bounds; // original bounds as they appear in the file |
185 |
user_t *user; |
user_t *user; |
186 |
|
|
187 |
node_t *node; |
node_t *node; |
188 |
|
hash_table_t *node_hash; |
189 |
|
|
190 |
way_t *way; |
way_t *way; |
191 |
|
hash_table_t *way_hash; |
192 |
|
|
193 |
|
// hashing relations doesn't yet make much sense as relations are quite rare |
194 |
relation_t *relation; |
relation_t *relation; |
195 |
|
|
196 |
} osm_t; |
} osm_t; |
197 |
|
|
198 |
#include <libxml/parser.h> |
#include <libxml/parser.h> |
250 |
/* ----------- edit functions ----------- */ |
/* ----------- edit functions ----------- */ |
251 |
node_t *osm_node_new(osm_t *osm, gint x, gint y); |
node_t *osm_node_new(osm_t *osm, gint x, gint y); |
252 |
void osm_node_attach(osm_t *osm, node_t *node); |
void osm_node_attach(osm_t *osm, node_t *node); |
253 |
|
void osm_node_restore(osm_t *osm, node_t *node); |
254 |
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, |
255 |
gboolean permanently, gboolean affect_ways); |
gboolean permanently, gboolean affect_ways); |
256 |
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, |
263 |
item_id_t osm_new_way_id(osm_t *osm); |
item_id_t osm_new_way_id(osm_t *osm); |
264 |
gboolean osm_way_ends_with_node(way_t *way, node_t *node); |
gboolean osm_way_ends_with_node(way_t *way, node_t *node); |
265 |
|
|
266 |
void osm_way_revert(way_t *way); |
void osm_way_reverse(way_t *way); |
267 |
|
guint osm_way_reverse_direction_sensitive_tags(way_t *way); |
268 |
|
guint osm_way_reverse_direction_sensitive_roles(osm_t *osm, way_t *way); |
269 |
|
|
270 |
void osm_node_remove_from_relation(osm_t *osm, node_t *node); |
void osm_node_remove_from_relation(osm_t *osm, node_t *node); |
271 |
void osm_way_remove_from_relation(osm_t *osm, way_t *way); |
void osm_way_remove_from_relation(osm_t *osm, way_t *way); |
276 |
|
|
277 |
tag_t *osm_tags_copy(tag_t *tag, gboolean update_creator); |
tag_t *osm_tags_copy(tag_t *tag, gboolean update_creator); |
278 |
|
|
279 |
|
char *osm_type_string(type_t type); |
280 |
|
char *osm_id_string(type_t type, void *object); |
281 |
|
char *osm_object_string(type_t type, void *object); |
282 |
|
tag_t *osm_object_get_tags(type_t type, void *object); |
283 |
|
|
284 |
|
relation_t *osm_relation_new(void); |
285 |
|
void osm_relation_free(relation_t *relation); |
286 |
|
void osm_relation_attach(osm_t *osm, relation_t *relation); |
287 |
|
void osm_relation_delete(osm_t *osm, relation_t *relation, |
288 |
|
gboolean permanently); |
289 |
|
gint osm_relation_members_num(relation_t *relation); |
290 |
|
|
291 |
#endif /* OSM_H */ |
#endif /* OSM_H */ |
292 |
|
|
293 |
// vim:et:ts=8:sw=2:sts=2:ai |
// vim:et:ts=8:sw=2:sts=2:ai |