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

Diff of /navit/navit/maptool/maptool.h

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

Revision 30 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-2011 Navit Team 22 * Copyright (C) 2005-2011 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
19#include <glib.h> 38#include <glib.h>
20#include "config.h" 39#include "config.h"
21#include "coord.h" 40#include "coord.h"
22#include "item.h" 41#include "item.h"
23#include "attr.h" 42#include "attr.h"
43#include <setjmp.h>
24#ifdef HAVE_LIBCRYPTO 44#ifdef HAVE_LIBCRYPTO
25#include <openssl/md5.h> 45#include <openssl/md5.h>
26#endif 46#endif
27 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
77extern sqlite3 *sql_handle;
78extern sqlite3 *sql_handle002a;
79extern sqlite3 *sql_handle003a;
80extern sqlite3 *sql_handle002b;
81extern sqlite3 *sql_handle003b;
82extern sqlite3 *sql_handle004;
83extern sqlite3 *sql_handle005;
84extern sqlite3 *sql_handle006;
85extern sqlite3 *sql_handle007;
86#else
87extern void *sql_handle;
88extern void *sql_handle002a;
89extern void *sql_handle003a;
90extern void *sql_handle002b;
91extern void *sql_handle003b;
92extern void *sql_handle004;
93extern void *sql_handle005;
94extern void *sql_handle006;
95extern void *sql_handle007;
96#endif
97
98int sql_counter;
99int sql_counter2;
100int sql_counter3;
101int 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
28 110
29#ifdef HAVE_API_WIN32_BASE 111#ifdef HAVE_API_WIN32_BASE
30#define LONGLONG_FMT "%I64d" 112#define LONGLONG_FMT "%I64d"
31#else 113#else
32#define LONGLONG_FMT "%lld" 114#define LONGLONG_FMT "%lld"
33#endif 115#endif
34 116
117#define sq(x) ((double)(x)*(x))
118
35#define BUFFER_SIZE 1280 119#define BUFFER_SIZE 1280
36 120
37#define debug_tile(x) 0 121#define debug_tile(x) 0
38#define debug_itembin(x) 0 122#define debug_itembin(x) 0
39 123
124// ---------EXCEPTIONS--------
125char stack[SIGSTKSZ];
126struct sigaction sa;
127stack_t ss;
128void catch_signal(int param);
129
130jmp_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
146sqlite3_stmt *stmt_nodea;
147sqlite3_stmt *stmt_node__2a;
148sqlite3_stmt *stmt_nodeb;
149sqlite3_stmt *stmt_node__2b;
150sqlite3_stmt *stmt_nodei;
151sqlite3_stmt *stmt_way;
152sqlite3_stmt *stmt_way2;
153sqlite3_stmt *stmt_way_node;
154sqlite3_stmt *stmt_way_node__2;
155sqlite3_stmt *stmt_way_nodeb;
156sqlite3_stmt *stmt_way_node__2b;
157sqlite3_stmt *stmt_way3;
158sqlite3_stmt *stmt_way3a;
159sqlite3_stmt *stmt_way3b;
160sqlite3_stmt *stmt_town_sel001;
161sqlite3_stmt *stmt_sel001;
162sqlite3_stmt *stmt_sel001__2;
163sqlite3_stmt *stmt_sel001b;
164sqlite3_stmt *stmt_sel001__2b;
165sqlite3_stmt *stmt_sel002a;
166sqlite3_stmt *stmt_sel002__2a;
167sqlite3_stmt *stmt_sel002b;
168sqlite3_stmt *stmt_sel002__2b;
169sqlite3_stmt *stmt_town_sel002;
170sqlite3_stmt *stmt_town_sel005;
171sqlite3_stmt *stmt_town_sel006;
172sqlite3_stmt *stmt_town_sel007;
173sqlite3_stmt *stmt_town_sel008;
174sqlite3_stmt *stmt_town;
175sqlite3_stmt *stmt_sel003;
176sqlite3_stmt *stmt_sel003u;
177sqlite3_stmt *stmt_sel004;
178sqlite3_stmt *stmt_bd_001;
179sqlite3_stmt *stmt_bd_002;
180sqlite3_stmt *stmt_bd_003;
181sqlite3_stmt *stmt_bd_004;
182sqlite3_stmt *stmt_bd_005;
183#else
184
185typedef void sqlite3_stmt;
186
187void *stmt_nodea;
188void *stmt_node__2a;
189void *stmt_nodeb;
190void *stmt_node__2b;
191void *stmt_nodei;
192void *stmt_way;
193void *stmt_way2;
194void *stmt_way_node;
195void *stmt_way_node__2;
196void *stmt_way_nodeb;
197void *stmt_way_node__2b;
198void *stmt_way3;
199void *stmt_way3a;
200void *stmt_way3b;
201void *stmt_town_sel001;
202void *stmt_sel001;
203void *stmt_sel001__2;
204void *stmt_sel001b;
205void *stmt_sel001__2b;
206void *stmt_sel002a;
207void *stmt_sel002__2a;
208void *stmt_sel002b;
209void *stmt_sel002__2b;
210void *stmt_town_sel002;
211void *stmt_town_sel005;
212void *stmt_town_sel006;
213void *stmt_town_sel007;
214void *stmt_town_sel008;
215void *stmt_town;
216void *stmt_sel003;
217void *stmt_sel003u;
218void *stmt_sel004;
219void *stmt_bd_001;
220void *stmt_bd_002;
221void *stmt_bd_003;
222void *stmt_bd_004;
223void *stmt_bd_005;
224
225#define SQLITE_STATIC 1
226#define SQLITE_ROW 2
227#define SQLITE_DONE 3
228int sqlite3_reset(void*);
229int sqlite3_step(void*);
230int sqlite3_exec(void*,void*, void*, void*,void*);
231int sqlite3_bind_int64(void*, int, long);
232int sqlite3_bind_int(void*, int, int);
233int sqlite3_bind_double(void*, int, double);
234long sqlite3_column_int64(void*, int);
235double sqlite3_column_double(void*, int);
236int sqlite3_column_int(void*, int);
237int 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
245long long ways_processed_count;
246
40struct rect { 247struct rect
248{
41 struct coord l,h; 249 struct coord l, h;
42}; 250};
43 251
252struct rect_lat_lon
253{
254 double lu_lat;
255 double lu_lon;
256 double rl_lat;
257 double rl_lon;
258};
259
260struct node_lat_lon
261{
262 double lat;
263 double lon;
264 int valid; // 0 -> invalid, 1 -> valid
265};
266
44struct tile_data { 267struct tile_data
268{
45 char buffer[1024]; 269 char buffer[1024];
46 int tile_depth; 270 int tile_depth;
47 struct rect item_bbox; 271 struct rect item_bbox;
48 struct rect tile_bbox; 272 struct rect tile_bbox;
49}; 273};
50 274
51struct tile_parameter { 275struct tile_parameter
276{
52 int min; 277 int min;
53 int max; 278 int max;
54 int overlap; 279 int overlap;
55}; 280};
56 281
57struct tile_info { 282struct tile_info
283{
58 int write; 284 int write;
59 int maxlen; 285 int maxlen;
60 char *suffix; 286 char *suffix;
61 GList **tiles_list; 287 GList **tiles_list;
62 FILE *tilesdir_out; 288 FILE *tilesdir_out;
63}; 289};
64 290
65extern struct tile_head { 291extern struct tile_head
292{
66 int num_subtiles; 293 int num_subtiles;
67 int total_size; 294 int total_size;
68 char *name; 295 char *name;
69 char *zip_data; 296 char *zip_data;
70 int total_size_used; 297 int total_size_used;
71 int zipnum; 298 int zipnum;
72 int process; 299 int process;
73 struct tile_head *next; 300 struct tile_head *next;
74 // char subtiles[0]; 301 // char subtiles[0];
75} *tile_head_root; 302}*tile_head_root;
76 303
77
78
79struct item_bin { 304struct item_bin
305{
80 int len; 306 int len;
81 enum item_type type; 307 enum item_type type;
82 int clen; 308 int clen;
83}; 309};
84 310
85struct attr_bin { 311struct attr_bin
312{
86 int len; 313 int len;
87 enum attr_type type; 314 enum attr_type type;
88}; 315};
89 316
90
91struct item_bin_sink_func { 317struct item_bin_sink_func
318{
92 int (*func)(struct item_bin_sink_func *func, struct item_bin *ib, struct tile_data *tile_data); 319 int (*func)(struct item_bin_sink_func *func, struct item_bin *ib, struct tile_data *tile_data);
93 void *priv_data[8]; 320 void *priv_data[8];
94}; 321};
95 322
96struct item_bin_sink { 323struct item_bin_sink
324{
97 void *priv_data[8]; 325 void *priv_data[8];
98 GList *sink_funcs; 326 GList *sink_funcs;
99}; 327};
100 328
329struct 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
339struct way_tag
340{
341 long long way_id;
342 int tag_id;
343};
344
345struct relation_member
346{
347 int type;
348 long long id;
349 char *role;
350};
351
101struct zip_info; 352struct zip_info;
353struct country_table;
102 354
103/* boundaries.c */ 355/* boundaries.c */
356struct 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};
104 365
366char *osm_tag_value(struct item_bin *ib, char *key);
367long long *boundary_relid(struct boundary *b);
105int process_boundaries(FILE *boundaries, FILE *ways); 368GList *process_boundaries(FILE *boundaries, FILE *coords, FILE *ways);
369void build_boundary_tree(GList *bl);
370GList *boundary_find_matches(GList *bl, struct coord *c);
371GList *boundary_find_matches_level(GList *l, struct coord *c, int min_admin_level, int max_admin_level);
372GList *boundary_find_matches_single(GList *bl, struct coord *c);
373void correct_boundary_ref_point(GList *bl);
106 374
107/* buffer.c */ 375/* buffer.c */
108struct buffer { 376struct buffer
377{
109 int malloced_step; 378 int malloced_step;
110 long long malloced; 379 long long malloced;
111 unsigned char *base; 380 unsigned char *base;
112 long long size; 381 long long size;
113}; 382};
124 393
125void process_coastlines(FILE *in, FILE *out); 394void process_coastlines(FILE *in, FILE *out);
126 395
127/* geom.c */ 396/* geom.c */
128 397
129enum geom_poly_segment_type { 398enum geom_poly_segment_type
130 geom_poly_segment_type_none, 399{
131 geom_poly_segment_type_way_inner, 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,
132 geom_poly_segment_type_way_outer,
133 geom_poly_segment_type_way_left_side,
134 geom_poly_segment_type_way_right_side,
135 geom_poly_segment_type_way_unknown,
136 401
137}; 402};
138 403
139struct geom_poly_segment { 404struct geom_poly_segment
405{
140 enum geom_poly_segment_type type; 406 enum geom_poly_segment_type type;
141 struct coord *first,*last; 407 struct coord *first, *last;
142}; 408};
143 409
144void geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse); 410void geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse);
145void geom_coord_revert(struct coord *c, int count); 411void geom_coord_revert(struct coord *c, int count);
146long long geom_poly_area(struct coord *c, int count); 412long long geom_poly_area(struct coord *c, int count);
151GList *geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type); 417GList *geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type);
152struct geom_poly_segment *item_bin_to_poly_segment(struct item_bin *ib, int type); 418struct geom_poly_segment *item_bin_to_poly_segment(struct item_bin *ib, int type);
153int geom_poly_segments_point_inside(GList *in, struct coord *c); 419int geom_poly_segments_point_inside(GList *in, struct coord *c);
154void clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out); 420void clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out);
155void clip_polygon(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out); 421void clip_polygon(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out);
422int item_bin_is_closed_poly(struct item_bin *ib);
156 423
157/* itembin.c */ 424/* itembin.c */
158 425
159int item_bin_read(struct item_bin *ib, FILE *in); 426int item_bin_read(struct item_bin *ib, FILE *in);
160void item_bin_set_type(struct item_bin *ib, enum item_type type); 427void item_bin_set_type(struct item_bin *ib, enum item_type type);
172void *item_bin_get_attr(struct item_bin *ib, enum attr_type type, void *last); 439void *item_bin_get_attr(struct item_bin *ib, enum attr_type type, void *last);
173struct attr_bin * item_bin_get_attr_bin_last(struct item_bin *ib); 440struct attr_bin * item_bin_get_attr_bin_last(struct item_bin *ib);
174void item_bin_add_attr_longlong(struct item_bin *ib, enum attr_type type, long long val); 441void item_bin_add_attr_longlong(struct item_bin *ib, enum attr_type type, long long val);
175void item_bin_add_attr_string(struct item_bin *ib, enum attr_type type, char *str); 442void item_bin_add_attr_string(struct item_bin *ib, enum attr_type type, char *str);
176void item_bin_add_attr_range(struct item_bin *ib, enum attr_type type, short min, short max); 443void item_bin_add_attr_range(struct item_bin *ib, enum attr_type type, short min, short max);
444void item_bin_remove_attr(struct item_bin *ib, void *ptr);
177void item_bin_write(struct item_bin *ib, FILE *out); 445void item_bin_write(struct item_bin *ib, FILE *out);
446void item_bin_write_xml(struct item_bin *ib, char *filename);
178struct item_bin *item_bin_dup(struct item_bin *ib); 447struct item_bin *item_bin_dup(struct item_bin *ib);
179void item_bin_write_range(struct item_bin *ib, FILE *out, int min, int max); 448void item_bin_write_range(struct item_bin *ib, FILE *out, int min, int max);
180void item_bin_write_clipped(struct item_bin *ib, struct tile_parameter *param, struct item_bin_sink *out); 449void item_bin_write_clipped(struct item_bin *ib, struct tile_parameter *param, struct item_bin_sink *out);
181void item_bin_dump(struct item_bin *ib, FILE *out); 450void item_bin_dump(struct item_bin *ib, FILE *out);
182void dump_itembin(struct item_bin *ib); 451void dump_itembin(struct item_bin *ib);
183void item_bin_set_type_by_population(struct item_bin *ib, int population); 452void item_bin_set_type_by_population(struct item_bin *ib, int population);
184void item_bin_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, FILE *out); 453void item_bin_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, FILE *out);
454void item_bin_town_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, FILE *out);
185int item_bin_sort_file(char *in_file, char *out_file, struct rect *r, int *size); 455int item_bin_sort_file(char *in_file, char *out_file, struct rect *r, int *size);
186 456
187/* itembin_buffer.c */ 457/* itembin_buffer.c */
458struct node_item *read_node_item(FILE *in, int local_thread_num);
188struct item_bin *read_item(FILE *in); 459struct item_bin *read_item(FILE *in, int local_thread_num);
189struct item_bin *read_item_range(FILE *in, int *min, int *max); 460struct item_bin *read_item_range(FILE *in, int *min, int *max, int local_thread_num);
190struct item_bin *init_item(enum item_type type); 461struct item_bin *init_item(enum item_type type, int local_thread_num);
191 462
192/* maptool.c */ 463/* maptool.c */
193 464
194extern long long slice_size; 465extern long long slice_size;
195extern int attr_debug_level; 466extern int attr_debug_level;
196extern char *suffix; 467extern char *suffix;
197extern int ignore_unkown; 468extern int ignore_unkown;
198extern GHashTable *dedupe_ways_hash; 469// extern GHashTable *dedupe_ways_hash;
199extern int phase; 470extern int phase;
200extern int slices; 471extern int slices;
472
473#define MAX_THREADS 8
474
475extern struct buffer node_buffer[MAX_THREADS];
201extern struct buffer node_buffer; 476extern struct buffer waytag_buffer;
477extern GHashTable *node_hash[MAX_THREADS];
478extern
479cfuhash_table_t *node_hash_cfu[MAX_THREADS];
480
481extern char ib_buffer_array[MAX_THREADS][800000];
482
202extern int processed_nodes, processed_nodes_out, processed_ways, processed_relations, processed_tiles; 483extern int processed_nodes, processed_nodes_out, processed_ways, processed_relations, processed_tiles;
203extern struct item_bin *item_bin; 484extern struct item_bin *item_bin;
204extern int bytes_read; 485extern int bytes_read;
205extern int overlap; 486extern int overlap;
487extern int experimental;
488extern int use_global_fixed_country_id;
489extern int global_fixed_country_id;
490extern int unknown_country;
206void sig_alrm(int sig); 491void sig_alrm(int sig);
207void sig_alrm_end(void); 492void sig_alrm_end(void);
493extern int border_only_map;
494extern int coastline_only_map;
495extern int border_only_map_as_xml;
496extern int verbose_mode;
497extern long long dummy_town_id;
498
499void convert_to_human_time(long long seconds, char *outstring);
500void convert_to_human_bytes(long long bytes, char *outstring);
501void convert_to_human_bytes2(long long bytes, char *outstring);
502
503struct 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!!!
513struct streets_index_index_block_start
514{
515 long long count_of_index_blocks;
516}__attribute__ ((packed));
517
518struct streets_index_index_block
519{
520 char first_letter;
521 long long offset;
522 long long len;
523}__attribute__ ((packed));
524
525struct 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!!!
538struct town_index_index_block_start
539{
540 long long count_of_index_blocks;
541}__attribute__ ((packed));
542
543struct town_index_index_block
544{
545 long long first_id;
546 long long offset;
547 long long len;
548}__attribute__ ((packed));
549
550struct 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
208 558
209/* misc.c */ 559/* misc.c */
210extern struct rect world_bbox; 560extern struct rect world_bbox;
211
212 561
213void bbox_extend(struct coord *c, struct rect *r); 562void bbox_extend(struct coord *c, struct rect *r);
214void bbox(struct coord *c, int count, struct rect *r); 563void bbox(struct coord *c, int count, struct rect *r);
215int contains_bbox(int xl, int yl, int xh, int yh, struct rect *r); 564int contains_bbox(int xl, int yl, int xh, int yh, struct rect *r);
216int bbox_contains_coord(struct rect *r, struct coord *c); 565int bbox_contains_coord(struct rect *r, struct coord *c);
222int phase5(FILE **in, FILE **references, int in_count, int with_range, char *suffix, struct zip_info *zip_info); 571int phase5(FILE **in, FILE **references, int in_count, int with_range, char *suffix, struct zip_info *zip_info);
223void process_binfile(FILE *in, FILE *out); 572void process_binfile(FILE *in, FILE *out);
224void add_aux_tiles(char *name, struct zip_info *info); 573void add_aux_tiles(char *name, struct zip_info *info);
225void cat(FILE *in, FILE *out); 574void cat(FILE *in, FILE *out);
226 575
227
228/* osm.c */ 576/* osm.c */
229typedef long int osmid; 577typedef long int osmid;
230 578
579struct 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
592void append_pre_resolved_ways(FILE *out, struct maptool_osm *osm2);
593void osm_warning(char *type, long long id, int cont, char *fmt, ...);
231void osm_add_tag(char *k, char *v); 594void osm_add_tag(char *k, char *v);
232void osm_add_node(osmid id, double lat, double lon); 595void osm_add_node(osmid id, double lat, double lon);
233void osm_add_way(osmid id); 596void osm_add_way(osmid id);
234void osm_add_relation(osmid id); 597void osm_add_relation(osmid id);
235void osm_end_relation(FILE *turn_restrictions, FILE *boundaries); 598void osm_end_relation(struct maptool_osm *osm);
236void osm_add_member(int type, osmid ref, char *role); 599void osm_add_member(int type, osmid ref, char *role);
237void osm_end_way(FILE *out); 600void osm_end_way(struct maptool_osm *osm);
238void osm_end_node(FILE *out); 601void osm_end_node(struct maptool_osm *osm);
239void osm_add_nd(osmid ref); 602void osm_add_nd(osmid ref);
240long long item_bin_get_id(struct item_bin *ib); 603long long item_bin_get_id(struct item_bin *ib);
241void flush_nodes(int final); 604void flush_nodes(int final, int local_thread_num);
242void sort_countries(int keep_tmpfiles); 605void sort_countries(int keep_tmpfiles);
243void process_turn_restrictions(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out); 606void process_turn_restrictions(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out);
607void clear_node_item_buffer(void);
608void ref_ways(FILE *in, int local_thread_num);
244int resolve_ways(FILE *in, FILE *out); 609void resolve_ways(FILE *in, FILE *out);
610long long item_bin_get_nodeid(struct item_bin *ib);
611long long item_bin_get_wayid(struct item_bin *ib);
612long long item_bin_get_relationid(struct item_bin *ib);
613FILE *resolve_ways_file(FILE *in, char *suffix, char *filename);
614void process_way2poi(FILE *in, FILE *out, int type);
245int map_find_intersections(FILE *in, FILE *out, FILE *out_index, FILE *out_graph, FILE *out_coastline, int final); 615int map_find_intersections(FILE *in, FILE *out, FILE *out_index, FILE *out_graph, FILE *out_coastline, int final);
616int copy_tags_to_ways(FILE *in, FILE *out, FILE *tags_in);
246void write_countrydir(struct zip_info *zip_info); 617void write_countrydir(struct zip_info *zip_info);
618GList* osm_process_towns(FILE *in, FILE *coords, FILE *boundaries, FILE *ways);
619void load_countries(void);
247void remove_countryfiles(void); 620void remove_countryfiles(void);
621struct country_table * country_from_iso2(char *iso);
248void osm_init(FILE*); 622void osm_init(FILE*);
249 623
624extern struct item_bin *item_bin_2;
625
250/* osm_psql.c */ 626/* osm_psql.c */
251int map_collect_data_osm_db(char *dbstr, FILE *out_ways, FILE *out_nodes, FILE *out_turn_restrictions, FILE *out_boundaries); 627int map_collect_data_osm_db(char *dbstr, struct maptool_osm *osm);
252 628
253/* osm_protobuf.c */ 629/* osm_protobuf.c */
254int map_collect_data_osm_protobuf(FILE *in, FILE *out_ways, FILE *out_nodes, FILE *out_turn_restrictions, FILE *out_boundaries); 630//int map_collect_data_osm_protobuf(FILE *in, struct maptool_osm *osm);
255int osm_protobufdb_load(FILE *in, char *dir); 631//int osm_protobufdb_load(FILE *in, char *dir);
632
633/* osm_relations.c */
634struct relations * relations_new(void);
635struct relations_func *relations_func_new(void(*func)(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv), void *func_priv);
636void relations_add_func(struct relations *rel, struct relations_func *func, void *relation_priv, void *member_priv, int type, osmid id);
637void relations_process(struct relations *rel, FILE *nodes, FILE *ways, FILE *relations);
256 638
257/* osm_xml.c */ 639/* osm_xml.c */
258int osm_xml_get_attribute(char *xml, char *attribute, char *buffer, int buffer_size); 640int osm_xml_get_attribute(char *xml, char *attribute, char *buffer, int buffer_size);
259void osm_xml_decode_entities(char *buffer); 641void osm_xml_decode_entities(char *buffer);
260int map_collect_data_osm(FILE *in, FILE *out_ways, FILE *out_nodes, FILE *out_turn_restrictions, FILE *out_boundaries); 642int map_collect_data_osm(FILE *in, struct maptool_osm *osm);
261
262 643
263/* sourcesink.c */ 644/* sourcesink.c */
264 645
265struct item_bin_sink *item_bin_sink_new(void); 646struct item_bin_sink *item_bin_sink_new(void);
266struct 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)); 647struct 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));
267void item_bin_sink_func_destroy(struct item_bin_sink_func *func); 648void item_bin_sink_func_destroy(struct item_bin_sink_func *func);
268void item_bin_sink_add_func(struct item_bin_sink *sink, struct item_bin_sink_func *func); 649void item_bin_sink_add_func(struct item_bin_sink *sink, struct item_bin_sink_func *func);
269void item_bin_sink_destroy(struct item_bin_sink *sink); 650void item_bin_sink_destroy(struct item_bin_sink *sink);
270int item_bin_write_to_sink(struct item_bin *ib, struct item_bin_sink *sink, struct tile_data *tile_data); 651int item_bin_write_to_sink(struct item_bin *ib, struct item_bin_sink *sink, struct tile_data *tile_data);
271struct item_bin_sink *file_reader_new(FILE *in, int limit, int offset); 652struct item_bin_sink *file_reader_new(FILE *in, int limit, int offset);
282FILE *tempfile(char *suffix, char *name, int mode); 663FILE *tempfile(char *suffix, char *name, int mode);
283void tempfile_unlink(char *suffix, char *name); 664void tempfile_unlink(char *suffix, char *name);
284void tempfile_rename(char *suffix, char *from, char *to); 665void tempfile_rename(char *suffix, char *from, char *to);
285 666
286/* tile.c */ 667/* tile.c */
287extern GHashTable *tile_hash,*tile_hash2; 668extern GHashTable *tile_hash, *tile_hash2;
288 669
289struct aux_tile { 670struct aux_tile
671{
290 char *name; 672 char *name;
291 char *filename; 673 char *filename;
292 int size; 674 int size;
293}; 675};
294 676
326FILE *zip_get_index(struct zip_info *info); 708FILE *zip_get_index(struct zip_info *info);
327int zip_get_zipnum(struct zip_info *info); 709int zip_get_zipnum(struct zip_info *info);
328void zip_set_zipnum(struct zip_info *info, int num); 710void zip_set_zipnum(struct zip_info *info, int num);
329void zip_close(struct zip_info *info); 711void zip_close(struct zip_info *info);
330void zip_destroy(struct zip_info *info); 712void zip_destroy(struct zip_info *info);
713

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

   
Visit the ZANavi Wiki