navit  0.5.1-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
Go to the documentation of this file.
20 #include <glib.h>
21 #include "item.h"
22 #include "attr.h"
23 #include "coord.h"
24 #include "data.h"
25 #include "projection.h"
26 #include "map.h"
27 #include "file.h"
29 struct block_data {
30  struct file *file;
31 };
33 struct block {
34 /* int blocks;
35  int size;
36  int next;
37  struct coord_rect r;
38  int count;*/
39  unsigned char p[32];
40 };
41 static inline int block_get_blocks(struct block * blk) { unsigned char *p = blk->p; return get_u32(&p); }
42 static inline int block_get_size(struct block * blk) { unsigned char *p = blk->p+4; return get_u32(&p); }
43 static inline int block_get_next(struct block * blk) { unsigned char *p = blk->p+8; return get_u32(&p); }
44 static inline int block_get_count(struct block * blk) { unsigned char *p = blk->p+28; return get_u32(&p); }
45 static inline void block_get_r(struct block * blk, struct coord_rect * r) { unsigned char *p = blk->p+12; r ->lu.x = get_u32(&p); r ->lu.y = get_u32(&p); r ->rl.x = get_u32(&p); r ->rl.y = get_u32(&p); }
47 struct item_priv {
48  int cidx;
49  int aidx;
50  unsigned char *cstart,*cp,*cend;
51  unsigned char *astart,*ap,*aend;
54  struct item item;
55 };
57 struct town_priv {
58  unsigned int id;
59  struct coord c;
60  char *name;
61  char *district;
62  char *postal_code1;
63  unsigned char order;
64  unsigned char type;
65  unsigned short country;
66  unsigned int unknown2;
67  unsigned char size;
68  unsigned int street_assoc;
69  unsigned char unknown3;
70  char *postal_code2;
71  unsigned int unknown4;
73  int cidx;
74  int aidx;
76  char debug[256];
77  char postal[32];
79 };
81 struct poly_priv {
82  int poly_num;
83  unsigned char *poly_next;
86  unsigned char *subpoly_next;
87  unsigned char *subpoly_start;
88  unsigned char *p;
89  struct coord c[2];
90  char *name;
91  unsigned char order;
92  unsigned char type;
93  unsigned int polys;
94  unsigned int *count;
95  unsigned int count_sum;
97  int aidx;
99 };
102  /*unsigned char order;
103  int count;*/
104  unsigned char p[5];
105 } __attribute__((packed));
106 static inline unsigned char street_header_get_order(struct street_header * str) { return *str->p; }
107 static inline int street_header_get_count(struct street_header * str) { unsigned char *p = str->p+1; return get_u32_unal(&p); }
109 struct street_type {
110  /*unsigned char order;
111  unsigned short country;*/
112  unsigned char p[3];
113 } __attribute__((packed));
114 static inline unsigned char street_type_get_order(struct street_type * str) { return *str->p; }
115 static inline unsigned short street_type_get_country(struct street_type * str) { unsigned char *p = str->p+1; return get_u16_unal(&p); }
120  struct street_type *type;
121 };
123 struct street_str {
124  /*int segid;
125  unsigned char limit;*/ /* 0x03,0x30=One Way,0x33=No Passing */
126  /*unsigned char unknown2;
127  unsigned char unknown3;
128  unsigned char type;
129  unsigned int nameid;*/
130  unsigned char p[12];
131 };
132 static inline int street_str_get_segid(struct street_str * str) { unsigned char *p = str->p; return get_u32_unal(&p); }
133 static inline unsigned char street_str_get_limit(struct street_str * str) { return str->p[4]; }
134 static inline unsigned char street_str_get_unknown2(struct street_str * str) { return str->p[5]; }
135 static inline unsigned char street_str_get_unknown3(struct street_str * str) { return str->p[6]; }
136 static inline unsigned char street_str_get_type(struct street_str * str) { return str->p[7]; }
137 static inline unsigned int street_str_get_nameid(struct street_str * str) { unsigned char *p = str->p+8; return get_u32_unal(&p); }
140  int segid;
141  int country;
142 };
144 struct street_name {
145  int len;
146  int country;
148  char *name1;
149  char *name2;
152  int aux_len;
153  unsigned char *aux_data;
154  int tmp_len;
155  unsigned char *tmp_data;
156 };
158 struct housenumber {
159  int number;
160  char *suffix;
161 };
164  int len;
165  int tag;
166  int dist;
167  int country;
168  struct coord *c;
173  int aux_len;
174  unsigned char *aux_data;
175  int tmp_len;
176  unsigned char *tmp_data;
177 };
178 static inline void street_name_numbers_get_coord(struct street_name_numbers * str, struct coord * c) {
179  unsigned char *p=(unsigned char *)str->c;
180  c->x=get_u32_unal(&p);
181  c->y=get_u32_unal(&p);
182 }
185  int len;
186  int tag;
187  struct coord *c;
191 };
195 struct street_priv {
196  struct file *name_file;
199  struct street_type *type;
200  struct street_str *str;
202  unsigned char *coord_begin;
203  unsigned char *p;
204  unsigned char *p_rewind;
205  unsigned char *end;
206  unsigned char *next;
207  int status;
209  struct coord_rect ref;
210  int bytes;
211  int more;
212  int flags;
214  int cidx;
215  struct coord hnc[100];
216  struct housenumber hn[100];
217  int hn_count;
222  char debug[256];
223  char first_number[32];
224  char last_number[32];
225  char current_number[32];
226  GHashTable *streetname_hash;
227 };
254 };
256 struct map_priv {
257  int id;
258  struct file *file[file_end];
259  char *dirname;
260 };
262 #define BT_STACK_SIZE 32
265  struct block *b;
266  struct coord_rect r, r_curr;
267  int next;
270  int stackp;
271  int order;
272  unsigned char *p;
273  unsigned char *end;
274 };
276 struct block_priv {
279  unsigned char *block_start;
280  struct block *b;
281  unsigned char *p;
282  unsigned char *end;
283  unsigned char *p_start;
286 };
288 struct block_offset {
289 /* unsigned short offset;
290  unsigned short block;*/
291  unsigned char p[4];
292 };
293 static inline unsigned short block_offset_get_offset(struct block_offset * blk) { unsigned char *p = blk->p; return get_u16_unal(&p); }
294 static inline unsigned short block_offset_get_block(struct block_offset * blk) { unsigned char *p = blk->p+2; return get_u16_unal(&p); }
297  struct tree_hdr *hdr;
298  unsigned char *p;
299  unsigned char *last;
300  unsigned char *end;
301  int low;
302  int high;
303  int last_low;
305  };
307 struct tree_search {
308  struct file *f;
312 };
315 struct map_rect_priv {
319  struct map_priv *m;
321  struct file *file;
322  struct block_priv b;
323  struct item item;
324  struct town_priv town;
325  struct poly_priv poly;
327  struct tree_search ts;
330  struct attr *search_attr;
331  char *search_str;
334  unsigned char *search_p;
336  enum attr_type search_type,search_type_next;
341  GHashTable *block_hash[file_end];
342  struct item_priv item3;
343 };
345 int mg_country_from_isonum(int isonum);
349 int block_init(struct map_rect_priv *mr);
350 int block_next(struct map_rect_priv *mr);
351 int block_get_byindex(struct file *file, int idx, struct block_priv *blk);
352 int block_next_lin(struct map_rect_priv *mr);
354 int tree_search_hv(char *dirname, char *filename, unsigned int search1, unsigned int search2, int *result);
355 int town_get(struct map_rect_priv *mr, struct town_priv *poly, struct item *item);
356 int town_get_byid(struct map_rect_priv *mr, struct town_priv *twn, int id_hi, int id_lo, struct item *item);
357 struct item * town_search_get_item(struct map_rect_priv *mr);
358 int poly_get(struct map_rect_priv *mr, struct poly_priv *poly, struct item *item);
359 int poly_get_byid(struct map_rect_priv *mr, struct poly_priv *poly, int id_hi, int id_lo, struct item *item);
360 int street_get(struct map_rect_priv *mr, struct street_priv *street, struct item *item);
361 int street_get_byid(struct map_rect_priv *mr, struct street_priv *street, int id_hi, int id_lo, struct item *item);
362 int street_name_get_byid(struct map_rect_priv *mr, struct street_priv *street, int id_hi, int id_lo, struct item *item);
363 struct item * street_search_get_item(struct map_rect_priv *mr);
364 void tree_search_init(char *dirname, char *filename, struct tree_search *ts, int offset);
365 void tree_search_free(struct tree_search *ts);
366 int tree_search_next(struct tree_search *ts, unsigned char **p, int dir);
367 int tree_search_next_lin(struct tree_search *ts, unsigned char **p);
368 struct item * housenumber_search_get_item(struct map_rect_priv *mr);
369 struct map_rect_priv * map_rect_new_mg(struct map_priv *map, struct map_selection *sel);
370 void map_rect_destroy_mg(struct map_rect_priv *mr);
371 struct item *map_rect_get_item_byid_mg(struct map_rect_priv *mr, int id_hi, int id_lo);
struct file * f
Definition: mg.h:308
int aux_len
Definition: mg.h:173
unsigned char p[4]
Definition: mg.h:291
Definition: mg.h:242
Definition: mg.h:231
Definition: attr.h:34
Definition: command.c:34
struct housenumber last
Definition: mg.h:189
int town_get(struct map_rect_priv *mr, struct town_priv *poly, struct item *item)
Definition: town.c:136
struct street_name_segment * segment
Definition: mg.h:190
struct street_name name
Definition: mg.h:218
struct block_priv b
Definition: mg.h:322
unsigned char * cp
Definition: mg.h:50
unsigned int id
Definition: mg.h:58
unsigned char type
Definition: mg.h:92
Definition: mg.h:81
unsigned int unknown2
Definition: mg.h:66
unsigned char p[5]
Definition: mg.h:48
Definition: mg.h:245
Definition: mg.h:144
enum attr_type attr_last
Definition: mg.h:52
Definition: tree.c:25
static int street_str_get_segid(struct street_str *str)
Definition: mg.h:132
static unsigned int get_u32_unal(unsigned char **p)
Definition: data.h:87
struct street_name_segment * segments
Definition: mg.h:172
struct item * housenumber_search_get_item(struct map_rect_priv *mr)
Definition: street.c:948
int type_count
Definition: mg.h:198
static unsigned char street_str_get_limit(struct street_str *str)
Definition: mg.h:133
int status
Definition: mg.h:207
struct map_selection * cur_sel
Definition: mg.h:317
unsigned int unknown4
Definition: mg.h:71
struct map_rect_priv * map_rect_new_mg(struct map_priv *map, struct map_selection *sel)
Definition: map.c:222
int binarytree
Definition: mg.h:284
unsigned char * next
Definition: mg.h:206
int country
Definition: mg.h:146
int offset
Definition: garmin_img.c:66
unsigned char * block_start
Definition: mg.h:279
struct poly_priv poly
Definition: mg.h:325
unsigned char p[32]
Definition: mg.h:39
Definition: mg.h:229
int y
Definition: coord.h:36
unsigned char * aux_data
Definition: mg.h:174
int tree_search_hv(char *dirname, char *filename, unsigned int search1, unsigned int search2, int *result)
Definition: tree.c:174
struct map_priv * m
Definition: binfile.c:144
char first_number[32]
Definition: mg.h:223
int tmp_len
Definition: mg.h:175
struct coord_rect r r_curr
Definition: mg.h:266
static unsigned char street_str_get_unknown2(struct street_str *str)
Definition: mg.h:134
Definition: mg.h:29
int tmp_len
Definition: mg.h:154
int subpoly_num_all
Definition: mg.h:85
int search_partial
Definition: mg.h:332
char * name2
Definition: mg.h:149
static int block_get_count(struct block *blk)
Definition: mg.h:44
struct file * name_file
Definition: mg.h:196
unsigned char * p_rewind
Definition: mg.h:204
Definition: item.h:99
struct street_header * header
Definition: mg.h:197
unsigned char * end
Definition: mg.h:300
Definition: mg.h:243
char postal[32]
Definition: mg.h:77
unsigned char * tmp_data
Definition: mg.h:176
int len
Definition: mg.h:164
int search_block
Definition: mg.h:340
static int street_header_get_count(struct street_header *str)
Definition: mg.h:107
struct street_type * type
Definition: mg.h:199
int aidx
Definition: mg.h:97
static unsigned short block_offset_get_block(struct block_offset *blk)
Definition: mg.h:294
int number
Definition: mg.h:159
int subpoly_num
Definition: mg.h:84
int low
Definition: mg.h:301
int tree_search_next(struct tree_search *ts, unsigned char **p, int dir)
Definition: tree.c:223
char * name
Definition: mg.h:90
int id
Definition: binfile.c:106
Definition: country.c:31
int housenumber_search_setup(struct map_rect_priv *mr)
Definition: street.c:890
int tree_search_next_lin(struct tree_search *ts, unsigned char **p)
Definition: tree.c:263
unsigned char order
Definition: mg.h:63
struct attr * search_attr
Definition: mg.h:330
unsigned char * p_start
Definition: mg.h:283
static unsigned short street_type_get_country(struct street_type *str)
Definition: mg.h:115
unsigned char * p
Definition: mg.h:272
int hn_count
Definition: mg.h:217
int mg_country_postal_len(int country)
Definition: map.c:141
unsigned char * cstart
Definition: mg.h:50
Definition: mg.h:240
struct coord_rect b_rect
Definition: mg.h:278
int cidx
Definition: mg.h:73
struct item * town_search_get_item(struct map_rect_priv *mr)
Definition: town.c:229
Definition: mg.h:195
struct map_selection * sel
Definition: binfile.c:143
struct block_bt_priv bt
Definition: mg.h:285
char * search_str
Definition: mg.h:331
int aidx
Definition: mg.h:49
int poly_get_byid(struct map_rect_priv *mr, struct poly_priv *poly, int id_hi, int id_lo, struct item *item)
Definition: poly.c:243
char * postal_code1
Definition: mg.h:62
static void block_get_r(struct block *blk, struct coord_rect *r)
Definition: mg.h:45
unsigned char order
Definition: mg.h:91
unsigned char * cend
Definition: mg.h:50
unsigned char size
Definition: mg.h:67
Definition: mg.h:139
unsigned char * aend
Definition: mg.h:51
Definition: mg.h:249
int stackp
Definition: mg.h:270
int poly_get(struct map_rect_priv *mr, struct poly_priv *poly, struct item *item)
Definition: poly.c:101
Definition: mg.h:251
unsigned char * astart
Definition: mg.h:51
unsigned char * search_p
Definition: mg.h:334
int curr_node
Definition: mg.h:310
int high
Definition: mg.h:302
Definition: mg.h:252
struct coord * c
Definition: mg.h:187
unsigned char unknown3
Definition: mg.h:69
static int block_get_size(struct block *blk)
Definition: mg.h:42
struct block * b
Definition: mg.h:280
Definition: mg.h:184
Definition: mg.h:232
static unsigned char street_type_get_order(struct street_type *str)
Definition: mg.h:114
int len
Definition: mg.h:185
struct coord lu
Definition: coord.h:47
int cidx
Definition: mg.h:48
Definition: mg.h:239
struct tree_hdr * hdr
Definition: mg.h:297
unsigned char * p
Definition: mg.h:298
int country
Definition: mg.h:167
Represents the map from a single binfile.
Definition: binfile.c:105
struct tree_search ts
Definition: mg.h:327
struct file * file
Definition: mg.h:321
int dist
Definition: mg.h:166
char debug[256]
Definition: mg.h:76
enum attr_type attr_next
Definition: mg.h:75
Implementation-specific map rect data.
Definition: binfile.c:137
struct street_name_segment * segments
Definition: mg.h:151
struct housenumber first
Definition: mg.h:169
int mg_country_from_isonum(int isonum)
Definition: map.c:125
int street_get_byid(struct map_rect_priv *mr, struct street_priv *street, int id_hi, int id_lo, struct item *item)
Definition: street.c:492
struct housenumber last
Definition: mg.h:170
char last_number[32]
Definition: mg.h:224
int block_count
Definition: mg.h:268
enum attr_type attr_next
Definition: mg.h:53
int block_next_lin(struct map_rect_priv *mr)
Definition: block.c:170
char filename[8]
Definition: garmin_img.c:122
char * suffix
Definition: mg.h:160
Definition: mg.h:253
Definition: mg.h:250
static unsigned char street_header_get_order(struct street_header *str)
Definition: mg.h:106
unsigned char * p
Definition: mg.h:88
struct street_header * header
Definition: mg.h:118
struct block_offset * search_blk_off
Definition: mg.h:339
int status_rewind
Definition: mg.h:208
struct street_priv street
Definition: mg.h:326
unsigned char * tmp_data
Definition: mg.h:155
Definition: mg.h:247
Definition: mg.h:246
int id_lo
Definition: item.h:102
int last_node
Definition: mg.h:309
unsigned char type
Definition: mg.h:64
struct housenumber hn[100]
Definition: mg.h:216
char * postal_code2
Definition: mg.h:70
void map_rect_destroy_mg(struct map_rect_priv *mr)
Definition: map.c:315
int segment_count
Definition: mg.h:171
Definition: mg.h:248
int search_country
Definition: mg.h:328
void tree_search_init(char *dirname, char *filename, struct tree_search *ts, int offset)
Definition: tree.c:293
Definition: mg.h:237
struct street_name_numbers name_numbers
Definition: mg.h:219
char current_number[32]
Definition: mg.h:225
int town_get_byid(struct map_rect_priv *mr, struct town_priv *twn, int id_hi, int id_lo, struct item *item)
Definition: town.c:184
GHashTable * streetname_hash
Definition: mg.h:226
struct coord c
Definition: mg.h:59
int next
Definition: mg.h:267
int aux_len
Definition: mg.h:152
Definition: attr.h:156
static void street_name_numbers_get_coord(struct street_name_numbers *str, struct coord *c)
Definition: mg.h:178
Used to select data from a map.
Definition: map.h:57
enum attr_type search_type search_type_next
Definition: mg.h:336
Definition: mg.h:307
unsigned char * end
Definition: mg.h:282
struct coord c[2]
Definition: mg.h:89
unsigned char p[5]
Definition: mg.h:104
unsigned int polys
Definition: mg.h:93
unsigned char * subpoly_next
Definition: mg.h:86
int cidx
Definition: mg.h:214
Definition: mg.h:33
unsigned char * p
Definition: mg.h:203
struct street_type * type
Definition: mg.h:120
int townassoc
Definition: mg.h:147
int order
Definition: mg.h:271
struct coord_rect stack[BT_STACK_SIZE]
Definition: mg.h:269
struct map_selection * xsel
Definition: mg.h:316
int type_count
Definition: mg.h:119
int more
Definition: mg.h:211
struct block * b
Definition: mg.h:265
static unsigned short get_u16_unal(unsigned char **p)
Definition: data.h:48
GHashTable * block_hash[file_end]
Definition: mg.h:341
char * district
Definition: mg.h:61
Definition: mg.h:158
int flags
Definition: mg.h:212
int search_blk_count
Definition: mg.h:335
Definition: mg.h:123
struct item * street_search_get_item(struct map_rect_priv *mr)
Definition: street.c:811
void tree_search_free(struct tree_search *ts)
Definition: tree.c:304
unsigned char * coord_begin
Definition: mg.h:202
Definition: mg.h:236
Definition: mg.h:234
int bytes
Definition: mg.h:210
Definition: mg.h:262
Definition: mg.h:230
unsigned char * p
Definition: mg.h:281
Holds information about a map.
Definition: map.c:60
unsigned char * aux_data
Definition: mg.h:153
unsigned int count_sum
Definition: mg.h:95
char debug[256]
Definition: mg.h:222
int street_get(struct map_rect_priv *mr, struct street_priv *street, struct item *item)
Definition: street.c:366
int block_get_byindex(struct file *file, int idx, struct block_priv *blk)
Definition: block.c:90
struct item search_item
Definition: mg.h:329
unsigned char * end
Definition: mg.h:273
int segid
Definition: mg.h:140
static int block_get_next(struct block *blk)
Definition: mg.h:43
Definition: mg.h:101
unsigned int * count
Definition: mg.h:94
struct tree_search_node nodes[5]
Definition: mg.h:311
struct item town_attr_item
Definition: mg.h:78
enum attr_type attr_next
Definition: mg.h:98
int aidx
Definition: mg.h:74
int poly_num
Definition: mg.h:82
struct street_str * str_start
Definition: mg.h:201
int tag
Definition: mg.h:165
char * dirname
Definition: mg.h:259
enum file_index current_file
Definition: mg.h:320
Definition: mg.h:241
struct town_priv town
Definition: mg.h:324
Definition: mg.h:47
int last_low
Definition: mg.h:303
Contains exported functions / structures for map.c.
Definition: mg.h:264
static unsigned char street_str_get_unknown3(struct street_str *str)
Definition: mg.h:135
int segment_count
Definition: mg.h:150
Definition: mg.h:288
static unsigned short block_offset_get_offset(struct block_offset *blk)
Definition: mg.h:293
int search_linear
Definition: mg.h:333
struct item * search_item_tmp
Definition: mg.h:338
static unsigned int get_u32(unsigned char **p)
Definition: data.h:75
struct coord_rect ref
Definition: mg.h:209
struct item * map_rect_get_item_byid_mg(struct map_rect_priv *mr, int id_hi, int id_lo)
Definition: map.c:291
struct street_str * str
Definition: mg.h:200
struct coord rl
Definition: coord.h:48
Definition: coord.h:46
struct street_header_type __attribute__
Definition: mg.h:163
unsigned char * subpoly_start
Definition: mg.h:87
Definition: coord.h:34
unsigned char * poly_next
Definition: mg.h:83
int block_num
Definition: mg.h:277
Definition: mg.h:235
int len
Definition: mg.h:145
struct housenumber first
Definition: mg.h:188
struct file * file
Definition: mg.h:30
Definition: mg.h:238
struct street_name_number name_number
Definition: mg.h:220
unsigned char p[3]
Definition: mg.h:112
Definition: mg.h:244
Definition: mg.h:117
unsigned int street_assoc
Definition: mg.h:68
Definition: mg.h:296
Definition: mg.h:233
int country
Definition: mg.h:141
static unsigned int street_str_get_nameid(struct street_str *str)
Definition: mg.h:137
int block_next(struct map_rect_priv *mr)
Definition: block.c:203
unsigned char * end
Definition: mg.h:205
struct coord * c
Definition: mg.h:168
int last_high
Definition: mg.h:304
struct coord hnc[100]
Definition: mg.h:215
int street_name_get_byid(struct map_rect_priv *mr, struct street_priv *street, int id_hi, int id_lo, struct item *item)
Definition: street.c:730
Definition: mg.h:109
int mg_country_to_isonum(int country)
Definition: map.c:133
unsigned char * last
Definition: mg.h:299
int block_init(struct map_rect_priv *mr)
Definition: block.c:154
char * name1
Definition: mg.h:148
enum attr_type attr_next
Definition: mg.h:221
struct item_priv item3
Definition: mg.h:342
int housenumber
Definition: mg.h:213
unsigned char p[12]
Definition: mg.h:130
Definition: mg.h:57
Definition: mg.h:276
unsigned char * ap
Definition: mg.h:51
struct map_rect_priv * search_mr_tmp
Definition: mg.h:337
int id_hi
Definition: item.h:101
unsigned short country
Definition: mg.h:65
int x
Definition: coord.h:35
struct timestamp ts
Definition: garmin_img.c:88
Definition: file.h:36
char * name
Definition: mg.h:60
static int block_get_blocks(struct block *blk)
Definition: mg.h:41
static unsigned char street_str_get_type(struct street_str *str)
Definition: mg.h:136
int tag
Definition: mg.h:186