/[zanavi_public1]/navit/navit/maptool/maptool.h
ZANavi

Contents of /navit/navit/maptool/maptool.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (show annotations) (download)
Mon Feb 4 17:41:59 2013 UTC (7 years, 6 months ago) by zoff99
File MIME type: text/plain
File size: 22643 byte(s)
new map version, lots of fixes and experimental new features
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
20 /**
21 * Navit, a modular navigation system.
22 * Copyright (C) 2005-2011 Navit Team
23 *
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License
26 * version 2 as published by the Free Software Foundation.
27 *
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
32 *
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, write to the
35 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
36 * Boston, MA 02110-1301, USA.
37 */
38 #include <glib.h>
39 #include "config.h"
40 #include "coord.h"
41 #include "item.h"
42 #include "attr.h"
43 #include <setjmp.h>
44 #ifdef HAVE_LIBCRYPTO
45 #include <openssl/md5.h>
46 #endif
47
48 #define MAPTOOL_USE_SQL 1 // if u want to use SQL and all the related stuff
49 #define MAPTOOL_USE_STRINDEX_COMPRESSION 1 // use street index compression
50 // #define MAPTOOL_USE_ASYNC_SQL 1 // sql writes are done in async thread
51 #define USE_STREET_INDEX_COMPRESSION 1
52 #define MAPTOOL_TRIANGULATE 1 // use polygon to triangle conversion
53 // #define MAPTOOL_SPLIT_NODE_DB 1 // split up node sql db
54 // #define MAPTOOL_SPLIT_NODE_DB_MORE 1 // split up node sql db into 2 more files
55 #define MAPTOOL_SPLIT_NODE_BIT 268435456 // split up at bit X (set value of bit e.g. 64)
56 #define MAPTOOL_SPLIT_WAYNODE_DB 1 // split up way-node sql db
57 #define MAPTOOL_SPLIT_WAYNODE_BIT 2 // split up at bit X
58 #define MAPTOOL_SPLIT_WAYNODE_BIT2 256 // split up at bit X
59
60 // cfu hash
61 #include "cfuhash.h"
62
63 #define CFUHASH_BUCKETS_NODES 2097152
64 #define CFUHASH_BUCKETS_WAYS 2097152
65 #define CFUHASH_BUCKETS_OTHER 2097152 // also nodes!?
66
67 // sqlite 3
68 #ifdef MAPTOOL_USE_SQL
69
70 #define SQLITE_ENABLE_STAT3
71 #define SQLITE_OMIT_AUTOVACUUM
72 #define SQLITE_OMIT_AUTOMATIC_INDEX
73
74 #include "sqlite3.h"
75 #include "sqlite3async.h"
76
77 extern sqlite3 *sql_handle;
78 extern sqlite3 *sql_handle002a;
79 extern sqlite3 *sql_handle003a;
80 extern sqlite3 *sql_handle002b;
81 extern sqlite3 *sql_handle003b;
82 extern sqlite3 *sql_handle004;
83 extern sqlite3 *sql_handle005;
84 extern sqlite3 *sql_handle006;
85 extern sqlite3 *sql_handle007;
86 #else
87 extern void *sql_handle;
88 extern void *sql_handle002a;
89 extern void *sql_handle003a;
90 extern void *sql_handle002b;
91 extern void *sql_handle003b;
92 extern void *sql_handle004;
93 extern void *sql_handle005;
94 extern void *sql_handle006;
95 extern void *sql_handle007;
96 #endif
97
98 int sql_counter;
99 int sql_counter2;
100 int sql_counter3;
101 int sql_counter4;
102 #define MAX_ROWS_WO_COMMIT 140000 // nodes
103 #define MAX_ROWS_WO_COMMIT_2 1000 // town to streets (2)
104 #define MAX_ROWS_WO_COMMIT_2a 100 // town to streets (1)
105 #define MAX_ROWS_WO_COMMIT_2b 10000 // town to streets (with boundaries)
106 #define MAX_ROWS_WO_COMMIT_3 90000 // ways
107 #define MAX_ROWS_WO_COMMIT_4 220000 // waynodes
108 #define MAX_ROWS_WO_COMMIT_5 6000 // towns to country
109 // sqlite 3
110
111 #ifdef HAVE_API_WIN32_BASE
112 #define LONGLONG_FMT "%I64d"
113 #else
114 #define LONGLONG_FMT "%lld"
115 #endif
116
117 #define sq(x) ((double)(x)*(x))
118
119 #define BUFFER_SIZE 1280
120
121 #define debug_tile(x) 0
122 #define debug_itembin(x) 0
123
124 // ---------EXCEPTIONS--------
125 char stack[SIGSTKSZ];
126 struct sigaction sa;
127 stack_t ss;
128 void catch_signal(int param);
129
130 jmp_buf ex_buf__; // global var!
131
132 // #define TRY do{ jmp_buf ex_buf__; switch( setjmp(ex_buf__) ){ case 0: while(1){
133 #define TRY do{ switch( setjmp(ex_buf__) ){ case 0: while(1){
134 #define CATCH(x) break; case x:
135 #define FINALLY break; } default:
136 #define ETRY } }while(0)
137 #define THROW(x) longjmp(ex_buf__, x)
138
139 #define MAPTOOL_00001_EXCEPTION (1)
140 #define MAPTOOL_00002_EXCEPTION (2)
141 #define MAPTOOL_00003_EXCEPTION (3)
142 // ---------EXCEPTIONS--------
143
144
145 #ifdef MAPTOOL_USE_SQL
146 sqlite3_stmt *stmt_nodea;
147 sqlite3_stmt *stmt_node__2a;
148 sqlite3_stmt *stmt_nodeb;
149 sqlite3_stmt *stmt_node__2b;
150 sqlite3_stmt *stmt_nodei;
151 sqlite3_stmt *stmt_way;
152 sqlite3_stmt *stmt_way2;
153 sqlite3_stmt *stmt_way_node;
154 sqlite3_stmt *stmt_way_node__2;
155 sqlite3_stmt *stmt_way_nodeb;
156 sqlite3_stmt *stmt_way_node__2b;
157 sqlite3_stmt *stmt_way3;
158 sqlite3_stmt *stmt_way3a;
159 sqlite3_stmt *stmt_way3b;
160 sqlite3_stmt *stmt_town_sel001;
161 sqlite3_stmt *stmt_sel001;
162 sqlite3_stmt *stmt_sel001__2;
163 sqlite3_stmt *stmt_sel001b;
164 sqlite3_stmt *stmt_sel001__2b;
165 sqlite3_stmt *stmt_sel002a;
166 sqlite3_stmt *stmt_sel002__2a;
167 sqlite3_stmt *stmt_sel002b;
168 sqlite3_stmt *stmt_sel002__2b;
169 sqlite3_stmt *stmt_town_sel002;
170 sqlite3_stmt *stmt_town_sel005;
171 sqlite3_stmt *stmt_town_sel006;
172 sqlite3_stmt *stmt_town_sel007;
173 sqlite3_stmt *stmt_town_sel008;
174 sqlite3_stmt *stmt_town;
175 sqlite3_stmt *stmt_sel003;
176 sqlite3_stmt *stmt_sel003u;
177 sqlite3_stmt *stmt_sel004;
178 sqlite3_stmt *stmt_bd_001;
179 sqlite3_stmt *stmt_bd_002;
180 sqlite3_stmt *stmt_bd_003;
181 sqlite3_stmt *stmt_bd_004;
182 sqlite3_stmt *stmt_bd_005;
183 #else
184
185 typedef void sqlite3_stmt;
186
187 void *stmt_nodea;
188 void *stmt_node__2a;
189 void *stmt_nodeb;
190 void *stmt_node__2b;
191 void *stmt_nodei;
192 void *stmt_way;
193 void *stmt_way2;
194 void *stmt_way_node;
195 void *stmt_way_node__2;
196 void *stmt_way_nodeb;
197 void *stmt_way_node__2b;
198 void *stmt_way3;
199 void *stmt_way3a;
200 void *stmt_way3b;
201 void *stmt_town_sel001;
202 void *stmt_sel001;
203 void *stmt_sel001__2;
204 void *stmt_sel001b;
205 void *stmt_sel001__2b;
206 void *stmt_sel002a;
207 void *stmt_sel002__2a;
208 void *stmt_sel002b;
209 void *stmt_sel002__2b;
210 void *stmt_town_sel002;
211 void *stmt_town_sel005;
212 void *stmt_town_sel006;
213 void *stmt_town_sel007;
214 void *stmt_town_sel008;
215 void *stmt_town;
216 void *stmt_sel003;
217 void *stmt_sel003u;
218 void *stmt_sel004;
219 void *stmt_bd_001;
220 void *stmt_bd_002;
221 void *stmt_bd_003;
222 void *stmt_bd_004;
223 void *stmt_bd_005;
224
225 #define SQLITE_STATIC 1
226 #define SQLITE_ROW 2
227 #define SQLITE_DONE 3
228 int sqlite3_reset(void*);
229 int sqlite3_step(void*);
230 int sqlite3_exec(void*,void*, void*, void*,void*);
231 int sqlite3_bind_int64(void*, int, long);
232 int sqlite3_bind_int(void*, int, int);
233 int sqlite3_bind_double(void*, int, double);
234 long sqlite3_column_int64(void*, int);
235 double sqlite3_column_double(void*, int);
236 int sqlite3_column_int(void*, int);
237 int sqlite3_bind_text(void*, int, char*, int, int);
238
239 #endif
240
241 #define TOWN_BY_BOUNDARY_SIZE_FACTOR 1000000
242 #define TOWN_ADMIN_LEVEL_CORR_BASE 99999
243 #define TOWN_ADMIN_LEVEL_START 8
244
245 long long ways_processed_count;
246
247 struct rect
248 {
249 struct coord l, h;
250 };
251
252 struct rect_lat_lon
253 {
254 double lu_lat;
255 double lu_lon;
256 double rl_lat;
257 double rl_lon;
258 };
259
260 struct node_lat_lon
261 {
262 double lat;
263 double lon;
264 int valid; // 0 -> invalid, 1 -> valid
265 };
266
267 struct tile_data
268 {
269 char buffer[1024];
270 int tile_depth;
271 struct rect item_bbox;
272 struct rect tile_bbox;
273 };
274
275 struct tile_parameter
276 {
277 int min;
278 int max;
279 int overlap;
280 };
281
282 struct tile_info
283 {
284 int write;
285 int maxlen;
286 char *suffix;
287 GList **tiles_list;
288 FILE *tilesdir_out;
289 };
290
291 extern struct tile_head
292 {
293 int num_subtiles;
294 int total_size;
295 char *name;
296 char *zip_data;
297 int total_size_used;
298 int zipnum;
299 int process;
300 struct tile_head *next;
301 // char subtiles[0];
302 }*tile_head_root;
303
304 struct item_bin
305 {
306 int len;
307 enum item_type type;
308 int clen;
309 };
310
311 struct attr_bin
312 {
313 int len;
314 enum attr_type type;
315 };
316
317 struct item_bin_sink_func
318 {
319 int (*func)(struct item_bin_sink_func *func, struct item_bin *ib, struct tile_data *tile_data);
320 void *priv_data[8];
321 };
322
323 struct item_bin_sink
324 {
325 void *priv_data[8];
326 GList *sink_funcs;
327 };
328
329 struct node_item
330 {
331 int id;
332 char ref_node;
333 char ref_way;
334 char ref_ref;
335 char dummy;
336 struct coord c;
337 };
338
339 struct way_tag
340 {
341 long long way_id;
342 int tag_id;
343 };
344
345 struct relation_member
346 {
347 int type;
348 long long id;
349 char *role;
350 };
351
352 struct zip_info;
353 struct country_table;
354
355 /* boundaries.c */
356 struct boundary
357 {
358 struct item_bin *ib;
359 struct country_table *country;
360 char *iso2;
361 GList *segments, *sorted_segments;
362 GList *children;
363 struct rect r;
364 };
365
366 char *osm_tag_value(struct item_bin *ib, char *key);
367 long long *boundary_relid(struct boundary *b);
368 GList *process_boundaries(FILE *boundaries, FILE *coords, FILE *ways);
369 void build_boundary_tree(GList *bl);
370 GList *boundary_find_matches(GList *bl, struct coord *c);
371 GList *boundary_find_matches_level(GList *l, struct coord *c, int min_admin_level, int max_admin_level);
372 GList *boundary_find_matches_single(GList *bl, struct coord *c);
373 void correct_boundary_ref_point(GList *bl);
374
375 /* buffer.c */
376 struct buffer
377 {
378 int malloced_step;
379 long long malloced;
380 unsigned char *base;
381 long long size;
382 };
383
384 void save_buffer(char *filename, struct buffer *b, long long offset);
385 void load_buffer(char *filename, struct buffer *b, long long offset, long long size);
386
387 /* ch.c */
388
389 void ch_generate_tiles(char *map_suffix, char *suffix, FILE *tilesdir_out, struct zip_info *zip_info);
390 void ch_assemble_map(char *map_suffix, char *suffix, struct zip_info *zip_info);
391
392 /* coastline.c */
393
394 void process_coastlines(FILE *in, FILE *out);
395
396 /* geom.c */
397
398 enum geom_poly_segment_type
399 {
400 geom_poly_segment_type_none, geom_poly_segment_type_way_inner, geom_poly_segment_type_way_outer, geom_poly_segment_type_way_left_side, geom_poly_segment_type_way_right_side, geom_poly_segment_type_way_unknown,
401
402 };
403
404 struct geom_poly_segment
405 {
406 enum geom_poly_segment_type type;
407 struct coord *first, *last;
408 };
409
410 void geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse);
411 void geom_coord_revert(struct coord *c, int count);
412 long long geom_poly_area(struct coord *c, int count);
413 GList *geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second, struct geom_poly_segment *third);
414 void geom_poly_segment_destroy(struct geom_poly_segment *seg);
415 GList *geom_poly_segments_remove(GList *list, struct geom_poly_segment *seg);
416 int geom_poly_segment_compatible(struct geom_poly_segment *s1, struct geom_poly_segment *s2, int dir);
417 GList *geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type);
418 struct geom_poly_segment *item_bin_to_poly_segment(struct item_bin *ib, int type);
419 int geom_poly_segments_point_inside(GList *in, struct coord *c);
420 void clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out);
421 void clip_polygon(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out);
422 int item_bin_is_closed_poly(struct item_bin *ib);
423
424 /* itembin.c */
425
426 int item_bin_read(struct item_bin *ib, FILE *in);
427 void item_bin_set_type(struct item_bin *ib, enum item_type type);
428 void item_bin_init(struct item_bin *ib, enum item_type type);
429 void item_bin_add_coord(struct item_bin *ib, struct coord *c, int count);
430 void item_bin_add_coord_reverse(struct item_bin *ib, struct coord *c, int count);
431 void item_bin_bbox(struct item_bin *ib, struct rect *r);
432 void item_bin_copy_coord(struct item_bin *ib, struct item_bin *from, int dir);
433 void item_bin_add_coord_rect(struct item_bin *ib, struct rect *r);
434 int attr_bin_write_data(struct attr_bin *ab, enum attr_type type, void *data, int size);
435 int attr_bin_write_attr(struct attr_bin *ab, struct attr *attr);
436 void item_bin_add_attr_data(struct item_bin *ib, enum attr_type type, void *data, int size);
437 void item_bin_add_attr(struct item_bin *ib, struct attr *attr);
438 void item_bin_add_attr_int(struct item_bin *ib, enum attr_type type, int val);
439 void *item_bin_get_attr(struct item_bin *ib, enum attr_type type, void *last);
440 struct attr_bin * item_bin_get_attr_bin_last(struct item_bin *ib);
441 void item_bin_add_attr_longlong(struct item_bin *ib, enum attr_type type, long long val);
442 void item_bin_add_attr_string(struct item_bin *ib, enum attr_type type, char *str);
443 void item_bin_add_attr_range(struct item_bin *ib, enum attr_type type, short min, short max);
444 void item_bin_remove_attr(struct item_bin *ib, void *ptr);
445 void item_bin_write(struct item_bin *ib, FILE *out);
446 void item_bin_write_xml(struct item_bin *ib, char *filename);
447 struct item_bin *item_bin_dup(struct item_bin *ib);
448 void item_bin_write_range(struct item_bin *ib, FILE *out, int min, int max);
449 void item_bin_write_clipped(struct item_bin *ib, struct tile_parameter *param, struct item_bin_sink *out);
450 void item_bin_dump(struct item_bin *ib, FILE *out);
451 void dump_itembin(struct item_bin *ib);
452 void item_bin_set_type_by_population(struct item_bin *ib, int population);
453 void item_bin_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, FILE *out);
454 void item_bin_town_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, FILE *out);
455 int item_bin_sort_file(char *in_file, char *out_file, struct rect *r, int *size);
456
457 /* itembin_buffer.c */
458 struct node_item *read_node_item(FILE *in, int local_thread_num);
459 struct item_bin *read_item(FILE *in, int local_thread_num);
460 struct item_bin *read_item_range(FILE *in, int *min, int *max, int local_thread_num);
461 struct item_bin *init_item(enum item_type type, int local_thread_num);
462
463 /* maptool.c */
464
465 extern long long slice_size;
466 extern int attr_debug_level;
467 extern char *suffix;
468 extern int ignore_unkown;
469 // extern GHashTable *dedupe_ways_hash;
470 extern int phase;
471 extern int slices;
472
473 #define MAX_THREADS 8
474
475 extern struct buffer node_buffer[MAX_THREADS];
476 extern struct buffer waytag_buffer;
477 extern GHashTable *node_hash[MAX_THREADS];
478 extern
479 cfuhash_table_t *node_hash_cfu[MAX_THREADS];
480
481 extern char ib_buffer_array[MAX_THREADS][800000];
482
483 extern int processed_nodes, processed_nodes_out, processed_ways, processed_relations, processed_tiles;
484 extern struct item_bin *item_bin;
485 extern int bytes_read;
486 extern int overlap;
487 extern int experimental;
488 extern int use_global_fixed_country_id;
489 extern int global_fixed_country_id;
490 extern int unknown_country;
491 void sig_alrm(int sig);
492 void sig_alrm_end(void);
493 extern int border_only_map;
494 extern int coastline_only_map;
495 extern int border_only_map_as_xml;
496 extern int verbose_mode;
497 extern long long dummy_town_id;
498
499 void convert_to_human_time(long long seconds, char *outstring);
500 void convert_to_human_bytes(long long bytes, char *outstring);
501 void convert_to_human_bytes2(long long bytes, char *outstring);
502
503 struct phase_001_thread_var
504 {
505 int thread_num;
506 int count;
507 FILE* file1;
508 };
509
510 // ------ STREET INDEX FILE ------
511
512 #define STREET_INDEX_STREET_NAME_SIZE 48 // (this value + 16) must be a 2^n number!!!
513 struct streets_index_index_block_start
514 {
515 long long count_of_index_blocks;
516 }__attribute__ ((packed));
517
518 struct streets_index_index_block
519 {
520 char first_letter;
521 long long offset;
522 long long len;
523 }__attribute__ ((packed));
524
525 struct streets_index_data_block
526 {
527 long long town_id;
528 int lat;
529 int lon;
530 char street_name[STREET_INDEX_STREET_NAME_SIZE];
531 }__attribute__ ((packed));
532 // ------ STREET INDEX FILE ------
533
534
535 // ------ TOWN INDEX FILE ------
536
537 #define TOWN_INDEX_TOWN_NAME_SIZE 52 // (this value + 12) must be a 2^n number!!!
538 struct town_index_index_block_start
539 {
540 long long count_of_index_blocks;
541 }__attribute__ ((packed));
542
543 struct town_index_index_block
544 {
545 long long first_id;
546 long long offset;
547 long long len;
548 }__attribute__ ((packed));
549
550 struct town_index_data_block
551 {
552 long long town_id;
553 int country_id;
554 char town_name[TOWN_INDEX_TOWN_NAME_SIZE];
555 }__attribute__ ((packed));
556 // ------ TOWN INDEX FILE ------
557
558
559 /* misc.c */
560 extern struct rect world_bbox;
561
562 void bbox_extend(struct coord *c, struct rect *r);
563 void bbox(struct coord *c, int count, struct rect *r);
564 int contains_bbox(int xl, int yl, int xh, int yh, struct rect *r);
565 int bbox_contains_coord(struct rect *r, struct coord *c);
566 int bbox_contains_bbox(struct rect *out, struct rect *in);
567 long long bbox_area(struct rect const *r);
568 void phase1_map(GList *maps, FILE *out_ways, FILE *out_nodes);
569 void dump(FILE *in);
570 int phase4(FILE **in, int in_count, int with_range, char *suffix, FILE *tilesdir_out, struct zip_info *zip_info);
571 int phase5(FILE **in, FILE **references, int in_count, int with_range, char *suffix, struct zip_info *zip_info);
572 void process_binfile(FILE *in, FILE *out);
573 void add_aux_tiles(char *name, struct zip_info *info);
574 void cat(FILE *in, FILE *out);
575
576 /* osm.c */
577 typedef long int osmid;
578
579 struct maptool_osm
580 {
581 FILE *boundaries;
582 FILE *turn_restrictions;
583 FILE *nodes;
584 FILE *ways;
585 FILE *line2poi;
586 FILE *poly2poi;
587 FILE *towns;
588 FILE *relations_riverbank;
589 FILE *ways_with_coords;
590 };
591
592 void append_pre_resolved_ways(FILE *out, struct maptool_osm *osm2);
593 void osm_warning(char *type, long long id, int cont, char *fmt, ...);
594 void osm_add_tag(char *k, char *v);
595 void osm_add_node(osmid id, double lat, double lon);
596 void osm_add_way(osmid id);
597 void osm_add_relation(osmid id);
598 void osm_end_relation(struct maptool_osm *osm);
599 void osm_add_member(int type, osmid ref, char *role);
600 void osm_end_way(struct maptool_osm *osm);
601 void osm_end_node(struct maptool_osm *osm);
602 void osm_add_nd(osmid ref);
603 long long item_bin_get_id(struct item_bin *ib);
604 void flush_nodes(int final, int local_thread_num);
605 void sort_countries(int keep_tmpfiles);
606 void process_turn_restrictions(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out);
607 void clear_node_item_buffer(void);
608 void ref_ways(FILE *in, int local_thread_num);
609 void resolve_ways(FILE *in, FILE *out);
610 long long item_bin_get_nodeid(struct item_bin *ib);
611 long long item_bin_get_wayid(struct item_bin *ib);
612 long long item_bin_get_relationid(struct item_bin *ib);
613 FILE *resolve_ways_file(FILE *in, char *suffix, char *filename);
614 void process_way2poi(FILE *in, FILE *out, int type);
615 int map_find_intersections(FILE *in, FILE *out, FILE *out_index, FILE *out_graph, FILE *out_coastline, int final);
616 int copy_tags_to_ways(FILE *in, FILE *out, FILE *tags_in);
617 void write_countrydir(struct zip_info *zip_info);
618 GList* osm_process_towns(FILE *in, FILE *coords, FILE *boundaries, FILE *ways);
619 void load_countries(void);
620 void remove_countryfiles(void);
621 struct country_table * country_from_iso2(char *iso);
622 void osm_init(FILE*);
623
624 extern struct item_bin *item_bin_2;
625
626 /* osm_psql.c */
627 int map_collect_data_osm_db(char *dbstr, struct maptool_osm *osm);
628
629 /* osm_protobuf.c */
630 //int map_collect_data_osm_protobuf(FILE *in, struct maptool_osm *osm);
631 //int osm_protobufdb_load(FILE *in, char *dir);
632
633 /* osm_relations.c */
634 struct relations * relations_new(void);
635 struct relations_func *relations_func_new(void(*func)(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv), void *func_priv);
636 void relations_add_func(struct relations *rel, struct relations_func *func, void *relation_priv, void *member_priv, int type, osmid id);
637 void relations_process(struct relations *rel, FILE *nodes, FILE *ways, FILE *relations);
638
639 /* osm_xml.c */
640 int osm_xml_get_attribute(char *xml, char *attribute, char *buffer, int buffer_size);
641 void osm_xml_decode_entities(char *buffer);
642 int map_collect_data_osm(FILE *in, struct maptool_osm *osm);
643
644 /* sourcesink.c */
645
646 struct item_bin_sink *item_bin_sink_new(void);
647 struct item_bin_sink_func *item_bin_sink_func_new(int(*func)(struct item_bin_sink_func *func, struct item_bin *ib, struct tile_data *tile_data));
648 void item_bin_sink_func_destroy(struct item_bin_sink_func *func);
649 void item_bin_sink_add_func(struct item_bin_sink *sink, struct item_bin_sink_func *func);
650 void item_bin_sink_destroy(struct item_bin_sink *sink);
651 int item_bin_write_to_sink(struct item_bin *ib, struct item_bin_sink *sink, struct tile_data *tile_data);
652 struct item_bin_sink *file_reader_new(FILE *in, int limit, int offset);
653 int file_reader_finish(struct item_bin_sink *sink);
654 int file_writer_process(struct item_bin_sink_func *func, struct item_bin *ib, struct tile_data *tile_data);
655 struct item_bin_sink_func *file_writer_new(FILE *out);
656 int file_writer_finish(struct item_bin_sink_func *file_writer);
657 int tile_collector_process(struct item_bin_sink_func *tile_collector, struct item_bin *ib, struct tile_data *tile_data);
658 struct item_bin_sink_func *tile_collector_new(struct item_bin_sink *out);
659
660 /* tempfile.c */
661
662 char *tempfile_name(char *suffix, char *name);
663 FILE *tempfile(char *suffix, char *name, int mode);
664 void tempfile_unlink(char *suffix, char *name);
665 void tempfile_rename(char *suffix, char *from, char *to);
666
667 /* tile.c */
668 extern GHashTable *tile_hash, *tile_hash2;
669
670 struct aux_tile
671 {
672 char *name;
673 char *filename;
674 int size;
675 };
676
677 extern GList *aux_tile_list;
678
679 int tile(struct rect *r, char *suffix, char *ret, int max, int overlap, struct rect *tr);
680 void tile_bbox(char *tile, struct rect *r, int overlap);
681 int tile_len(char *tile);
682 void tile_write_item_to_tile(struct tile_info *info, struct item_bin *ib, FILE *reference, char *name);
683 void tile_write_item_minmax(struct tile_info *info, struct item_bin *ib, FILE *reference, int min, int max);
684 int add_aux_tile(struct zip_info *zip_info, char *name, char *filename, int size);
685 int write_aux_tiles(struct zip_info *zip_info);
686 int create_tile_hash(void);
687 void write_tilesdir(struct tile_info *info, struct zip_info *zip_info, FILE *out);
688 void merge_tiles(struct tile_info *info);
689 struct attr map_information_attrs[32];
690 void index_init(struct zip_info *info, int version);
691 void index_submap_add(struct tile_info *info, struct tile_head *th);
692
693 /* zip.c */
694 void write_zipmember(struct zip_info *zip_info, char *name, int filelen, char *data, int data_size);
695 void zip_write_index(struct zip_info *info);
696 int zip_write_directory(struct zip_info *info);
697 struct zip_info *zip_new(void);
698 void zip_set_md5(struct zip_info *info, int on);
699 int zip_get_md5(struct zip_info *info, unsigned char *out);
700 void zip_set_zip64(struct zip_info *info, int on);
701 void zip_set_compression_level(struct zip_info *info, int level);
702 void zip_set_maxnamelen(struct zip_info *info, int max);
703 int zip_get_maxnamelen(struct zip_info *info);
704 int zip_add_member(struct zip_info *info);
705 int zip_set_timestamp(struct zip_info *info, char *timestamp);
706 int zip_set_password(struct zip_info *info, char *password);
707 void zip_open(struct zip_info *info, char *out, char *dir, char *index);
708 FILE *zip_get_index(struct zip_info *info);
709 int zip_get_zipnum(struct zip_info *info);
710 void zip_set_zipnum(struct zip_info *info, int num);
711 void zip_close(struct zip_info *info);
712 void zip_destroy(struct zip_info *info);
713

   
Visit the ZANavi Wiki