/[zanavi_public1]/navit/navit/map/mg/mg.h
ZANavi

Contents of /navit/navit/map/mg/mg.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Fri Oct 28 21:19:04 2011 UTC (9 years, 5 months ago) by zoff99
File MIME type: text/plain
File size: 10818 byte(s)
import files
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 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
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"
28
29 struct block_data {
30 struct file *file;
31 };
32
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); }
46
47 struct item_priv {
48 int cidx;
49 int aidx;
50 unsigned char *cstart,*cp,*cend;
51 unsigned char *astart,*ap,*aend;
52 enum attr_type attr_last;
53 enum attr_type attr_next;
54 struct item item;
55 };
56
57 struct town_priv {
58 unsigned int id; /*!< Identifier */
59 struct coord c; /*!< Coordinates */
60 char *name; /*!< Name */
61 char *district; /*!< District */
62 char *postal_code1; /*!< Postal code */
63 unsigned char order; /*!< Order (Importance) */
64 unsigned char type; /*!< Type */
65 unsigned short country; /*!< Country */
66 unsigned int unknown2; /*!< Unknown */
67 unsigned char size; /*!< Size of town */
68 unsigned int street_assoc; /*!< Association to streets */
69 unsigned char unknown3; /*!< Unknown */
70 char *postal_code2; /*!< 2nd postal code */
71 unsigned int unknown4; /*!< Unknown */
72
73 int cidx;
74 int aidx;
75 enum attr_type attr_next;
76 char debug[256];
77 char postal[32];
78 struct item town_attr_item;
79 };
80
81 struct poly_priv {
82 int poly_num;
83 unsigned char *poly_next;
84 int subpoly_num;
85 int subpoly_num_all;
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;
96
97 int aidx;
98 enum attr_type attr_next;
99 };
100
101 struct street_header {
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); }
108
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); }
116
117 struct street_header_type {
118 struct street_header *header;
119 int type_count;
120 struct street_type *type;
121 };
122
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); }
138
139 struct street_name_segment {
140 int segid;
141 int country;
142 };
143
144 struct street_name {
145 int len;
146 int country;
147 int townassoc;
148 char *name1;
149 char *name2;
150 int segment_count;
151 struct street_name_segment *segments;
152 int aux_len;
153 unsigned char *aux_data;
154 int tmp_len;
155 unsigned char *tmp_data;
156 };
157
158 struct housenumber {
159 int number;
160 char *suffix;
161 };
162
163 struct street_name_numbers {
164 int len;
165 int tag;
166 int dist;
167 int country;
168 struct coord *c;
169 struct housenumber first;
170 struct housenumber last;
171 int segment_count;
172 struct street_name_segment *segments;
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 }
183
184 struct street_name_number {
185 int len;
186 int tag;
187 struct coord *c;
188 struct housenumber first;
189 struct housenumber last;
190 struct street_name_segment *segment;
191 };
192
193
194
195 struct street_priv {
196 struct file *name_file;
197 struct street_header *header;
198 int type_count;
199 struct street_type *type;
200 struct street_str *str;
201 struct street_str *str_start;
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;
208 int status_rewind;
209 struct coord_rect ref;
210 int bytes;
211 int more;
212 int flags;
213 int housenumber;
214 int cidx;
215 struct coord hnc[100];
216 struct housenumber hn[100];
217 int hn_count;
218 struct street_name name;
219 struct street_name_numbers name_numbers;
220 struct street_name_number name_number;
221 enum attr_type attr_next;
222 char debug[256];
223 char first_number[32];
224 char last_number[32];
225 char current_number[32];
226 GHashTable *streetname_hash;
227 };
228
229 enum file_index {
230 file_border_ply=0,
231 file_bridge_ply,
232 file_build_ply,
233 file_golf_ply,
234 file_height_ply,
235 file_natpark_ply,
236 file_nature_ply,
237 file_other_ply,
238 file_rail_ply,
239 file_sea_ply,
240 file_street_bti,
241 file_street_str,
242 file_strname_stn,
243 file_town_twn,
244 file_tunnel_ply,
245 file_water_ply,
246 file_woodland_ply,
247 file_end,
248 file_town_twn_alt1,
249 file_town_twn_alt2,
250 file_street_str_alt1,
251 file_street_str_alt2,
252 file_street_str_alt3,
253 file_street_str_alt4,
254 };
255
256 struct map_priv {
257 int id;
258 struct file *file[file_end];
259 char *dirname;
260 };
261
262 #define BT_STACK_SIZE 32
263
264 struct block_bt_priv {
265 struct block *b;
266 struct coord_rect r, r_curr;
267 int next;
268 int block_count;
269 struct coord_rect stack[BT_STACK_SIZE];
270 int stackp;
271 int order;
272 unsigned char *p;
273 unsigned char *end;
274 };
275
276 struct block_priv {
277 int block_num;
278 struct coord_rect b_rect;
279 unsigned char *block_start;
280 struct block *b;
281 unsigned char *p;
282 unsigned char *end;
283 unsigned char *p_start;
284 int binarytree;
285 struct block_bt_priv bt;
286 };
287
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); }
295
296 struct tree_search_node {
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;
304 int last_high;
305 };
306
307 struct tree_search {
308 struct file *f;
309 int last_node;
310 int curr_node;
311 struct tree_search_node nodes[5];
312 };
313
314
315 struct map_rect_priv {
316 struct map_selection *xsel;
317 struct map_selection *cur_sel;
318
319 struct map_priv *m;
320 enum file_index current_file;
321 struct file *file;
322 struct block_priv b;
323 struct item item;
324 struct town_priv town;
325 struct poly_priv poly;
326 struct street_priv street;
327 struct tree_search ts;
328 int search_country;
329 struct item search_item;
330 struct attr *search_attr;
331 char *search_str;
332 int search_partial;
333 int search_linear;
334 unsigned char *search_p;
335 int search_blk_count;
336 enum attr_type search_type,search_type_next;
337 struct map_rect_priv *search_mr_tmp;
338 struct item *search_item_tmp;
339 struct block_offset *search_blk_off;
340 int search_block;
341 GHashTable *block_hash[file_end];
342 struct item_priv item3;
343 };
344
345 int mg_country_from_isonum(int isonum);
346 int mg_country_to_isonum(int country);
347 int mg_country_postal_len(int country);
348
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);
353
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);
372 int housenumber_search_setup(struct map_rect_priv *mr);

   
Visit the ZANavi Wiki