/[zanavi_public1]/navit/navit/item.c
ZANavi

Diff of /navit/navit/item.c

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

Revision 29 Revision 31
1/**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011-2012 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU 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 General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * 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
1/** 20/**
2 * Navit, a modular navigation system. 21 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team 22 * Copyright (C) 2005-2008 Navit Team
4 * 23 *
5 * This program is free software; you can redistribute it and/or 24 * This program is free software; you can redistribute it and/or
30{ 49{
31 enum item_type item; 50 enum item_type item;
32 char *name; 51 char *name;
33}; 52};
34 53
35struct item_range item_range_all = 54struct item_range item_range_all = { type_none, type_last };
36{ type_none, type_last };
37 55
38struct default_flags 56struct default_flags
39{ 57{
40 enum item_type type; 58 enum item_type type;
41 int flags; 59 int flags;
42}; 60};
43 61
44struct item busy_item; 62struct item busy_item;
45 63
46struct default_flags default_flags2[] = 64struct default_flags default_flags2[] = { { type_street_nopass, AF_PBH }, { type_street_0, AF_ALL }, { type_street_1_city, AF_ALL }, { type_street_2_city, AF_ALL }, { type_street_3_city, AF_ALL }, { type_street_4_city, AF_ALL }, { type_highway_city, AF_MOTORIZED_FAST }, { type_street_1_land, AF_ALL }, { type_street_2_land, AF_ALL }, { type_street_3_land, AF_ALL }, { type_street_4_land, AF_ALL }, { type_street_n_lanes, AF_MOTORIZED_FAST }, { type_highway_land, AF_MOTORIZED_FAST }, { type_ramp, AF_MOTORIZED_FAST }, { type_roundabout, AF_ALL }, { type_ferry, AF_ALL }, { type_cycleway, AF_PBH }, { type_track_paved, AF_ALL }, { type_track_gravelled, AF_ALL }, { type_track_unpaved, AF_ALL }, { type_track_ground, AF_ALL }, { type_track_grass, AF_ALL }, { type_footway, AF_PBH }, { type_living_street, AF_ALL }, { type_street_service, AF_ALL }, { type_street_parking_lane, AF_ALL }, { type_bridleway, AF_PBH }, { type_path, AF_PBH }, { type_steps, AF_PBH }, { type_street_pedestrian, AF_PBH }, };
47{
48{ type_street_nopass, AF_PBH },
49{ type_street_0, AF_ALL },
50{ type_street_1_city, AF_ALL },
51{ type_street_2_city, AF_ALL },
52{ type_street_3_city, AF_ALL },
53{ type_street_4_city, AF_ALL },
54{ type_highway_city, AF_MOTORIZED_FAST },
55{ type_street_1_land, AF_ALL },
56{ type_street_2_land, AF_ALL },
57{ type_street_3_land, AF_ALL },
58{ type_street_4_land, AF_ALL },
59{ type_street_n_lanes, AF_MOTORIZED_FAST },
60{ type_highway_land, AF_MOTORIZED_FAST },
61{ type_ramp, AF_MOTORIZED_FAST },
62{ type_roundabout, AF_ALL },
63{ type_ferry, AF_ALL },
64{ type_cycleway, AF_PBH },
65{ type_track_paved, AF_ALL },
66{ type_track_gravelled, AF_ALL },
67{ type_track_unpaved, AF_ALL },
68{ type_track_ground, AF_ALL },
69{ type_track_grass, AF_ALL },
70{ type_footway, AF_PBH },
71{ type_living_street, AF_ALL },
72{ type_street_service, AF_ALL },
73{ type_street_parking_lane, AF_ALL },
74{ type_bridleway, AF_PBH },
75{ type_path, AF_PBH },
76{ type_steps, AF_PBH },
77{ type_street_pedestrian, AF_PBH },
78};
79 65
80struct item_name item_names[] = 66struct item_name item_names[] = {
81{
82#define ITEM2(x,y) ITEM(y) 67#define ITEM2(x,y) ITEM(y)
83#define ITEM(x) { type_##x, #x }, 68#define ITEM(x) { type_##x, #x },
84#include "item_def.h" 69#include "item_def.h"
85#undef ITEM2 70#undef ITEM2
86#undef ITEM 71#undef ITEM
209 /* FIXME evaluate arguments */ 194 /* FIXME evaluate arguments */
210 195
211 return it; 196 return it;
212} 197}
213 198
214
215// not working yet!!!!! ------ 199// not working yet!!!!! ------
216/* 200/*
217void item_dup(struct item *src, struct item *dst) 201 void item_dup(struct item *src, struct item *dst)
218{ 202 {
219 int size; 203 int size;
220 void *priv_data; 204 void *priv_data;
221 205
222 dst = g_new0(struct item, 1); 206 dst = g_new0(struct item, 1);
223 dst->type=src->type; 207 dst->type=src->type;
224 dst->id_hi=src->id_hi; 208 dst->id_hi=src->id_hi;
225 dst->id_lo=src->id_lo; 209 dst->id_lo=src->id_lo;
226 210
227 dst->priv_data=g_malloc(size); 211 dst->priv_data=g_malloc(size);
228 memcpy(dst->priv_data, src->priv_data, size); 212 memcpy(dst->priv_data, src->priv_data, size);
229 // int len = (ib->len + 1) * 4; 213 // int len = (ib->len + 1) * 4;
230 214
231} 215 }
232*/ 216 */
233// not working yet!!!!! ------ 217// not working yet!!!!! ------
234 218
235 219
236enum item_type item_from_name(const char *name) 220enum item_type item_from_name(const char *name)
237{ 221{
295struct item_hash * 279struct item_hash *
296item_hash_new(void) 280item_hash_new(void)
297{ 281{
298 struct item_hash *ret=g_new(struct item_hash, 1); 282 struct item_hash *ret=g_new(struct item_hash, 1);
299 283
300 ret->h = g_hash_table_new_full(item_hash_hash, item_hash_equal, g_free, NULL); 284 ret->h = g_hash_table_new_full(item_hash_hash, item_hash_equal, g_free_func, NULL);
301 return ret; 285 return ret;
302} 286}
303 287
304void item_hash_insert(struct item_hash *h, struct item *item, void *val) 288void item_hash_insert(struct item_hash *h, struct item *item, void *val)
305{ 289{
348} 332}
349 333
350void item_dump_attr_stdout(struct item *item, struct map *map) 334void item_dump_attr_stdout(struct item *item, struct map *map)
351{ 335{
352 struct attr attr; 336 struct attr attr;
353 dbg(0, "type=%s\n", item_to_name(item->type)); 337 dbg(0, "type=%d:%s\n", item->type, item_to_name(item->type));
354 while (item_attr_get(item, attr_any, &attr)) 338 while (item_attr_get(item, attr_any, &attr))
355 { 339 {
356 dbg(0, " %s='%s'", attr_to_name(attr.type), attr_to_text(&attr, map, 1)); 340 dbg(0, " %d:%s='%s'", attr.type, attr_to_name(attr.type), attr_to_text(&attr, map, 1));
357 // dbg(0," %s\n", attr_to_name(attr.type)); 341 // dbg(0," %s\n", attr_to_name(attr.type));
358 } 342 }
359} 343}
360 344
361void item_dump_attr(struct item *item, struct map *map, FILE *out) 345void item_dump_attr(struct item *item, struct map *map, FILE *out)
362{ 346{
363 struct attr attr; 347 struct attr attr;
364 fprintf(out, "type=%s", item_to_name(item->type)); 348 fprintf(out, "type=%s", item_to_name(item->type));
365 while (item_attr_get(item, attr_any, &attr)) 349 while (item_attr_get(item, attr_any, &attr))
350 {
366 fprintf(out, " %s='%s'", attr_to_name(attr.type), attr_to_text(&attr, map, 1)); 351 fprintf(out, " %s='%s'", attr_to_name(attr.type), attr_to_text(&attr, map, 1));
352 }
367} 353}
368 354
369void item_dump_filedesc(struct item *item, struct map *map, FILE *out) 355void item_dump_filedesc(struct item *item, struct map *map, FILE *out)
370{ 356{
371 357

Legend:
Removed from v.29  
changed lines
  Added in v.31

   
Visit the ZANavi Wiki