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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 57 - (show annotations) (download)
Sun Mar 19 16:46:08 2017 UTC (7 years, 1 month ago) by zoff99
File MIME type: text/plain
File size: 33243 byte(s)
updates
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 "trans_lat_lon_geo.h"
44 #include <setjmp.h>
45 #ifdef HAVE_LIBCRYPTO
46 #include <openssl/md5.h>
47 #endif
48
49 #define MAX_THREADS 8
50
51 #define MIN_SLICE_SIZE_BYTES 32768
52
53 #define NO_GTYPES_ 1
54
55 #define NAVIT_TRANS_LAT_LON_GEO_NOFUNCS 1
56
57 // --------------------------------------------
58 // --
59 // which binfilemap version this maptool will generate
60 #define GENERATE_BINFILE_MAPVERSION 4
61 // --
62 // --------------------------------------------
63
64
65 // --------------------------------------------
66 // --
67 // if the turn angle is greater than this (in degrees) in bicycle mode, then speak a turn command
68 #define ROAD_ANGLE_MIN_FOR_TURN_BICYCLEMODE 30
69 // --
70 // --------------------------------------------
71
72
73 extern int MAPTOOL_QUICK_RUN; // only set this to 1 for testing !!!!!!
74
75
76 #define MAPTOOL_SQL_INPUT_TOO_SMALL 0 // only set this to 1 for testing very small input files!!!!!!
77
78 #define MAPTOOL_USE_SQL 1 // if u want to use SQL and all the related stuff
79 #define MAPTOOL_USE_STRINDEX_COMPRESSION 1 // use street index compression
80 // #define MAPTOOL_USE_ASYNC_SQL 1 // sql writes are done in async thread
81 #define USE_STREET_INDEX_COMPRESSION 1
82 #define MAPTOOL_TRIANGULATE 1 // use polygon to triangle conversion
83 // #define MAPTOOL_SPLIT_NODE_DB 1 // split up node sql db
84 // #define MAPTOOL_SPLIT_NODE_DB_MORE 1 // split up node sql db into 2 more files
85 #define MAPTOOL_SPLIT_NODE_BIT 268435456 // split up at bit X (set value of bit e.g. 64)
86 //#define MAPTOOL_SPLIT_WAYNODE_DB 1 // split up way-node sql db
87 #define MAPTOOL_SPLIT_WAYNODE_BIT 2 // split up at bit X
88 #define MAPTOOL_SPLIT_WAYNODE_BIT2 256 // split up at bit X
89
90 // cfu hash
91 #include "cfuhash.h"
92
93 #define CFUHASH_BUCKETS_NODES 8388608 // 2100000 // 4194304 // 8388608 // for planet and 2GB ram, we get about 80million nodes to cache
94 #define CFUHASH_BUCKETS_WAYS 65536 // normally unused now
95 #define CFUHASH_BUCKETS_OTHER 65536 // also nodes!? ---> unused now
96
97 // sqlite 3
98 #ifdef MAPTOOL_USE_SQL
99
100 #define SQLITE_ENABLE_STAT3
101 #define SQLITE_ENABLE_STAT4
102 #define SQLITE_OMIT_AUTOVACUUM
103 #define SQLITE_OMIT_AUTOMATIC_INDEX
104 #define SQLITE_ENABLE_API_ARMOR
105 #define SQLITE_DEFAULT_TEMP_CACHE_SIZE 1000
106 #define SQLITE_DEFAULT_WORKER_THREADS 2
107 #define SQLITE_MAX_WORKER_THREADS 2
108 //#define SQLITE_DEFAULT_WORKER_THREADS 0
109 //#define SQLITE_MAX_WORKER_THREADS 0
110
111
112 #include "sqlite3.h"
113 /* #include "sqlite3async.h" */
114
115 extern sqlite3 *sql_handle;
116 extern sqlite3 *sql_handle002a;
117 extern sqlite3 *sql_handle003a;
118 extern sqlite3 *sql_handle002b;
119 extern sqlite3 *sql_handle003b;
120 extern sqlite3 *sql_handle004;
121 extern sqlite3 *sql_handle005;
122 extern sqlite3 *sql_handle006;
123 extern sqlite3 *sql_handle007;
124 #else
125 extern void *sql_handle;
126 extern void *sql_handle002a;
127 extern void *sql_handle003a;
128 extern void *sql_handle002b;
129 extern void *sql_handle003b;
130 extern void *sql_handle004;
131 extern void *sql_handle005;
132 extern void *sql_handle006;
133 extern void *sql_handle007;
134 #endif
135
136 int sql_counter;
137 int sql_counter2;
138 int sql_counter3;
139 int sql_counter4;
140 #define MAX_ROWS_WO_COMMIT 140000 // nodes
141 #define MAX_ROWS_WO_COMMIT_2 1000 // town to streets (2)
142 #define MAX_ROWS_WO_COMMIT_2a 100 // town to streets (1)
143 #define MAX_ROWS_WO_COMMIT_2b 10000 // town to streets (with boundaries)
144 #define MAX_ROWS_WO_COMMIT_3 90000 // ways
145 #define MAX_ROWS_WO_COMMIT_4 220000 // waynodes
146 #define MAX_ROWS_WO_COMMIT_5 6000 // towns to country
147 // sqlite 3
148
149 #ifdef HAVE_API_WIN32_BASE
150 #define LONGLONG_FMT "%I64d"
151 #else
152 #define LONGLONG_FMT "%lld"
153 #endif
154
155 #define sq(x) ((double)(x)*(x))
156
157 #define BUFFER_SIZE 1280
158
159 #define debug_tile(x) 0
160 #define debug_itembin(x) 0
161
162 // ---------EXCEPTIONS--------
163 char stack[SIGSTKSZ];
164 struct sigaction sa;
165 stack_t ss;
166 void catch_signal(int param);
167
168 jmp_buf ex_buf__; // global var!
169
170 // #define TRY do{ jmp_buf ex_buf__; switch( setjmp(ex_buf__) ){ case 0: while(1){
171 #define TRY do{ switch( setjmp(ex_buf__) ){ case 0: while(1){
172 #define CATCH(x) break; case x:
173 #define FINALLY break; } default:
174 #define ETRY } }while(0)
175 #define THROW(x) longjmp(ex_buf__, x)
176
177 #define MAPTOOL_00001_EXCEPTION (1)
178 #define MAPTOOL_00002_EXCEPTION (2)
179 #define MAPTOOL_00003_EXCEPTION (3)
180 // ---------EXCEPTIONS--------
181
182
183 #ifdef MAPTOOL_USE_SQL
184 sqlite3_stmt *stmt_nodea;
185 sqlite3_stmt *stmt_node__2a;
186 sqlite3_stmt *stmt_nodeb;
187 sqlite3_stmt *stmt_node__2b;
188 sqlite3_stmt *stmt_nodei;
189 sqlite3_stmt *stmt_way;
190 sqlite3_stmt *stmt_way2;
191 sqlite3_stmt *stmt_way_node;
192 sqlite3_stmt *stmt_way_node__2;
193 sqlite3_stmt *stmt_way_nodeb;
194 sqlite3_stmt *stmt_way_node__2b;
195 sqlite3_stmt *stmt_way3;
196 sqlite3_stmt *stmt_way3a;
197 sqlite3_stmt *stmt_way3b;
198 sqlite3_stmt *stmt_town_sel001;
199 sqlite3_stmt *stmt_sel001;
200 sqlite3_stmt *stmt_sel001__2;
201 sqlite3_stmt *stmt_sel001b;
202 sqlite3_stmt *stmt_sel001__2b;
203 sqlite3_stmt *stmt_sel0012;
204 sqlite3_stmt *stmt_sel0012__2;
205 sqlite3_stmt *stmt_sel0012b;
206 sqlite3_stmt *stmt_sel0012__2b;
207 sqlite3_stmt *stmt_sel002a;
208 sqlite3_stmt *stmt_sel002__2a;
209 sqlite3_stmt *stmt_sel002b;
210 sqlite3_stmt *stmt_sel002__2b;
211 sqlite3_stmt *stmt_town_sel002;
212 sqlite3_stmt *stmt_town_sel005;
213 sqlite3_stmt *stmt_town_sel006;
214 sqlite3_stmt *stmt_town_sel007;
215 sqlite3_stmt *stmt_town_sel008;
216 sqlite3_stmt *stmt_town;
217 sqlite3_stmt *stmt_sel003;
218 sqlite3_stmt *stmt_sel003u;
219 sqlite3_stmt *stmt_sel004;
220 sqlite3_stmt *stmt_bd_001;
221 sqlite3_stmt *stmt_bd_002;
222 sqlite3_stmt *stmt_bd_003;
223 sqlite3_stmt *stmt_bd_004;
224 sqlite3_stmt *stmt_bd_005;
225 sqlite3_stmt *stmt_sel0012_tt[MAX_THREADS];
226 sqlite3_stmt *stmt_sel0012__2_tt[MAX_THREADS];
227 sqlite3_stmt *stmt_sel0012b_tt[MAX_THREADS];
228 sqlite3_stmt *stmt_sel0012__2b_tt[MAX_THREADS];
229 #else
230
231 typedef void sqlite3_stmt;
232
233 void *stmt_nodea;
234 void *stmt_node__2a;
235 void *stmt_nodeb;
236 void *stmt_node__2b;
237 void *stmt_nodei;
238 void *stmt_way;
239 void *stmt_way2;
240 void *stmt_way_node;
241 void *stmt_way_node__2;
242 void *stmt_way_nodeb;
243 void *stmt_way_node__2b;
244 void *stmt_way3;
245 void *stmt_way3a;
246 void *stmt_way3b;
247 void *stmt_town_sel001;
248 void *stmt_sel001;
249 void *stmt_sel001__2;
250 void *stmt_sel001b;
251 void *stmt_sel001__2b;
252 void *stmt_sel0012;
253 void *stmt_sel0012__2;
254 void *stmt_sel0012b;
255 void *stmt_sel0012__2b;
256 void *stmt_sel002a;
257 void *stmt_sel002__2a;
258 void *stmt_sel002b;
259 void *stmt_sel002__2b;
260 void *stmt_town_sel002;
261 void *stmt_town_sel005;
262 void *stmt_town_sel006;
263 void *stmt_town_sel007;
264 void *stmt_town_sel008;
265 void *stmt_town;
266 void *stmt_sel003;
267 void *stmt_sel003u;
268 void *stmt_sel004;
269 void *stmt_bd_001;
270 void *stmt_bd_002;
271 void *stmt_bd_003;
272 void *stmt_bd_004;
273 void *stmt_bd_005;
274 void *stmt_sel0012_tt[MAX_THREADS];
275 void *stmt_sel0012__2_tt[MAX_THREADS];
276 void *stmt_sel0012b_tt[MAX_THREADS];
277 void *stmt_sel0012__2b_tt[MAX_THREADS];
278
279
280 #define SQLITE_STATIC 1
281 #define SQLITE_ROW 2
282 #define SQLITE_DONE 3
283 int sqlite3_reset(void*);
284 int sqlite3_step(void*);
285 int sqlite3_exec(void*,void*, void*, void*,void*);
286 int sqlite3_bind_int64(void*, int, long);
287 int sqlite3_bind_int(void*, int, int);
288 int sqlite3_bind_double(void*, int, double);
289 long sqlite3_column_int64(void*, int);
290 double sqlite3_column_double(void*, int);
291 int sqlite3_column_int(void*, int);
292 int sqlite3_bind_text(void*, int, char*, int, int);
293
294 #endif
295
296 #define TOWN_BY_BOUNDARY_SIZE_FACTOR 1000000
297 #define TOWN_ADMIN_LEVEL_CORR_BASE 99999
298 #define TOWN_ADMIN_LEVEL_START 8
299
300 long long ways_processed_count;
301 extern int global_keep_tmpfiles;
302 extern int global_use_runtime_db;
303 extern char *runtime_db_filename_with_path;
304
305
306 void fprintf_(FILE *f, const char *fmt, ...);
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325 // quick_hash.c -------------------
326
327
328
329
330 //-----------------------------------------------------------------------------
331 // MurmurHash2 was written by Austin Appleby, and is placed in the public
332 // domain. The author hereby disclaims copyright to this source code.
333
334 #ifndef _MURMURHASH2_H_
335 #define _MURMURHASH2_H_
336
337 //-----------------------------------------------------------------------------
338 // Platform-specific functions and macros
339
340 // typedef unsigned char uint8_t;
341 // typedef unsigned long uint32_t;
342 // typedef unsigned __int64 uint64_t;
343
344 #include <stdint.h>
345
346 //-----------------------------------------------------------------------------
347
348 //uint32_t MurmurHash2 ( const void * key, int len, uint32_t seed );
349 //uint64_t MurmurHash64A ( const void * key, int len, uint64_t seed );
350 uint64_t MurmurHash64B ( const void * key, int len, uint64_t seed );
351 //uint32_t MurmurHash2A ( const void * key, int len, uint32_t seed );
352 //uint32_t MurmurHashNeutral2 ( const void * key, int len, uint32_t seed );
353 //uint32_t MurmurHashAligned2 ( const void * key, int len, uint32_t seed );
354
355 unsigned int MurmurHash1Aligned ( const void * key, int len, unsigned int seed );
356
357 //-----------------------------------------------------------------------------
358
359
360 struct quickhash_table* quick_hash_init(int num_buckets);
361 void quick_hash_destroy(struct quickhash_table* table);
362 int quick_hash_lookup(struct quickhash_table* table, long long key);
363 void quick_hash_add_entry(struct quickhash_table* table, long long key, int value_ptr);
364 void* quick_hash_print_stats(struct quickhash_table* table);
365
366 #define HASH_SIMPLE 1 // for simple hash algo
367
368 #endif // _MURMURHASH2_H_
369
370
371 // quick_hash.c -------------------
372
373
374
375
376
377
378
379
380 // 24 MBytes for item buffer
381 #define MAX_ITEMBIN_BYTES_ 24000000
382
383
384
385
386
387
388
389
390
391
392 struct rect
393 {
394 struct coord l, h;
395 };
396
397 struct rect_lat_lon
398 {
399 double lu_lat;
400 double lu_lon;
401 double rl_lat;
402 double rl_lon;
403 };
404
405 struct node_lat_lon
406 {
407 double lat;
408 double lon;
409 int valid; // 0 -> invalid, 1 -> valid
410 };
411
412 struct tile_data
413 {
414 char buffer[1024];
415 int tile_depth;
416 struct rect item_bbox;
417 struct rect tile_bbox;
418 };
419
420 struct tile_parameter
421 {
422 int min;
423 int max;
424 int overlap;
425 };
426
427 struct tile_info
428 {
429 int write;
430 int maxlen;
431 char *suffix;
432 GList **tiles_list;
433 FILE *tilesdir_out;
434 };
435
436 extern struct tile_head
437 {
438 int num_subtiles;
439 int total_size;
440 char *name;
441 char *zip_data;
442 int total_size_used;
443 int zipnum;
444 int process;
445 struct tile_head *next;
446 // char subtiles[0];
447 }*tile_head_root;
448
449 struct item_bin
450 {
451 int len;
452 enum item_type type;
453 int clen;
454 };
455
456 struct attr_bin
457 {
458 int len;
459 enum attr_type type;
460 };
461
462 struct item_bin_sink_func
463 {
464 int (*func)(struct item_bin_sink_func *func, struct item_bin *ib, struct tile_data *tile_data);
465 void *priv_data[8];
466 };
467
468 struct item_bin_sink
469 {
470 void *priv_data[8];
471 GList *sink_funcs;
472 };
473
474 typedef long long osmid;
475
476 struct node_item
477 {
478 osmid id;
479 char ref_node;
480 char ref_way;
481 char ref_ref;
482 char dummy;
483 struct coord c;
484 };
485
486 struct way_tag
487 {
488 long long way_id;
489 int tag_id;
490 };
491
492 struct relation_member
493 {
494 int type;
495 long long id;
496 char *role;
497 };
498
499 struct zip_info;
500
501 struct country_table;
502
503
504 /* boundaries.c */
505 struct boundary
506 {
507 struct item_bin *ib;
508 struct country_table *country;
509 char *iso2;
510 GList *segments, *sorted_segments;
511 GList *children;
512 struct rect r; // bbox
513 };
514
515 struct boundary_manual
516 {
517 // struct item_bin *ib;
518 struct coord *c;
519 int coord_count;
520 int countryid;
521 struct country_table *country;
522 struct rect r; // bbox
523 long long town_id;
524 };
525
526 GList *boundary_list_inner_manual;
527
528
529 char *osm_tag_value(struct item_bin *ib, char *key);
530 long long *boundary_relid(struct boundary *b);
531 GList *process_boundaries(FILE *boundaries, FILE *coords, FILE *ways);
532 void build_boundary_tree(GList *bl, GList *man_bl);
533 GList *boundary_find_matches(GList *bl, struct coord *c);
534 GList *boundary_find_matches_level(GList *l, struct coord *c, int min_admin_level, int max_admin_level);
535 GList *boundary_find_matches_single(GList *bl, struct coord *c);
536 void correct_boundary_ref_point(GList *bl);
537 void free_boundaries(GList *l);
538 GList *load_manual_country_borders();
539 void save_manual_country_borders(GList *borders);
540
541 /* buffer.c */
542 struct buffer
543 {
544 int malloced_step;
545 long long malloced;
546 unsigned char *base;
547 long long size;
548 };
549
550 void save_buffer(char *filename, struct buffer *b, long long offset);
551 void free_buffer(char *filename, struct buffer *b);
552 void load_buffer(char *filename, struct buffer *b, long long offset, long long size);
553
554 /* ch.c */
555
556 void ch_generate_tiles(char *map_suffix, char *suffix, FILE *tilesdir_out, struct zip_info *zip_info);
557 void ch_assemble_map(char *map_suffix, char *suffix, struct zip_info *zip_info);
558
559 /* coastline.c */
560
561 void process_coastlines(FILE *in, FILE *out);
562
563 /* geom.c */
564
565 enum geom_poly_segment_type
566 {
567 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,
568
569 };
570
571 struct geom_poly_segment
572 {
573 enum geom_poly_segment_type type;
574 struct coord *first, *last;
575 };
576
577 void geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse);
578 void geom_coord_revert(struct coord *c, int count);
579 long long geom_poly_area(struct coord *c, int count);
580 GList *geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second, struct geom_poly_segment *third);
581 void geom_poly_segment_destroy(struct geom_poly_segment *seg);
582 GList *geom_poly_segments_remove(GList *list, struct geom_poly_segment *seg);
583 int geom_poly_segment_compatible(struct geom_poly_segment *s1, struct geom_poly_segment *s2, int dir);
584 GList *geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type);
585 struct geom_poly_segment *item_bin_to_poly_segment(struct item_bin *ib, int type);
586 int geom_poly_segments_point_inside(GList *in, struct coord *c);
587 void clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out);
588 void clip_polygon(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out);
589 int item_bin_is_closed_poly(struct item_bin *ib);
590
591 /* itembin.c */
592
593 int item_bin_read(struct item_bin *ib, FILE *in);
594 void item_bin_set_type(struct item_bin *ib, enum item_type type);
595 void item_bin_init(struct item_bin *ib, enum item_type type);
596 void item_bin_add_coord(struct item_bin *ib, struct coord *c, int count);
597 void item_bin_add_coord_reverse(struct item_bin *ib, struct coord *c, int count);
598 void item_bin_bbox(struct item_bin *ib, struct rect *r);
599 void item_bin_copy_coord(struct item_bin *ib, struct item_bin *from, int dir);
600 void item_bin_add_coord_rect(struct item_bin *ib, struct rect *r);
601 int attr_bin_write_data(struct attr_bin *ab, enum attr_type type, void *data, int size);
602 int attr_bin_write_attr(struct attr_bin *ab, struct attr *attr);
603 void item_bin_add_attr_data(struct item_bin *ib, enum attr_type type, void *data, int size);
604 void item_bin_add_attr(struct item_bin *ib, struct attr *attr);
605 void item_bin_add_attr_int(struct item_bin *ib, enum attr_type type, int val);
606 void *item_bin_get_attr(struct item_bin *ib, enum attr_type type, void *last);
607 struct attr_bin * item_bin_get_attr_bin_last(struct item_bin *ib);
608 void item_bin_add_attr_longlong(struct item_bin *ib, enum attr_type type, long long val);
609 void item_bin_add_attr_string(struct item_bin *ib, enum attr_type type, char *str);
610 void item_bin_add_attr_range(struct item_bin *ib, enum attr_type type, short min, short max);
611 void item_bin_remove_attr(struct item_bin *ib, void *ptr);
612 void item_bin_write(struct item_bin *ib, FILE *out);
613 void item_bin_write_xml(struct item_bin *ib, char *filename);
614 struct item_bin *item_bin_dup(struct item_bin *ib);
615 void item_bin_write_range(struct item_bin *ib, FILE *out, int min, int max);
616 void item_bin_write_clipped(struct item_bin *ib, struct tile_parameter *param, struct item_bin_sink *out);
617 void item_bin_dump(struct item_bin *ib, FILE *out);
618 void dump_itembin(struct item_bin *ib);
619 void item_bin_set_type_by_population(struct item_bin *ib, int population);
620 void item_bin_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, FILE *out);
621 void item_bin_town_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, FILE *out);
622 int item_bin_sort_file(char *in_file, char *out_file, struct rect *r, int *size);
623
624 /* itembin_buffer.c */
625 struct node_item *read_node_item(FILE *in, int local_thread_num);
626 struct item_bin *read_item(FILE *in, int local_thread_num);
627 struct item_bin *read_item_range(FILE *in, int *min, int *max, int local_thread_num);
628 struct item_bin *init_item(enum item_type type, int local_thread_num);
629
630 /* maptool.c */
631
632 extern long long slice_size;
633 extern int attr_debug_level;
634 extern char *suffix;
635 extern int ignore_unkown;
636 // extern GHashTable *dedupe_ways_hash;
637 extern int phase;
638 extern int slices;
639
640 extern FILE *ways_ref_file;
641 extern FILE *ways_ref_file_thread[MAX_THREADS];
642
643 extern struct buffer node_buffer[MAX_THREADS];
644 extern struct buffer waytag_buffer;
645 extern GHashTable *node_hash[MAX_THREADS];
646
647 #if 0
648 extern cfuhash_table_t *node_hash_cfu[MAX_THREADS];
649 #endif
650 extern struct quickhash_table *node_hash_cfu[MAX_THREADS];
651
652 extern char *ib_buffer_array[MAX_THREADS]; // [2400000]; // 24 MB max size for 1 item
653
654 extern int processed_nodes_out, processed_tiles;
655 extern long long processed_nodes;
656 extern long long processed_ways;
657 extern long long processed_relations;
658
659 extern long long processed_nodes_sum;
660 extern long long processed_ways_sum;
661 extern long long processed_relations_sum;
662
663 extern struct item_bin *item_bin;
664 extern int bytes_read;
665 extern int overlap;
666 extern int experimental;
667 extern int use_global_fixed_country_id;
668 extern int global_fixed_country_id;
669 extern int unknown_country;
670 void sig_alrm(int sig);
671 void sig_alrm_end(void);
672 extern int border_only_map;
673 extern int coastline_only_map;
674 extern int border_only_map_as_xml;
675 extern int verbose_mode;
676 extern long long dummy_town_id;
677 extern char* manual_country_border_dir;
678
679 extern int global_less_verbose;
680
681
682 void convert_to_human_time(long long seconds, char *outstring);
683 void convert_to_human_bytes(long long bytes, char *outstring);
684 void convert_to_human_bytes2(long long bytes, char *outstring);
685
686 struct phase_001_thread_var
687 {
688 int thread_num;
689 int count;
690 FILE* file1;
691 };
692
693 // ------ STREET INDEX FILE ------
694
695 #define REF_X 1073741834 // lat
696 #define REF_Y 240000000 // lon
697
698 #define STREET_INDEX_STREET_NAME_SIZE 48 // (this value + 16) must be a 2^n number!!!
699 struct streets_index_index_block_start
700 {
701 long long count_of_index_blocks;
702 }__attribute__ ((packed));
703
704 struct streets_index_index_block
705 {
706 char first_letter;
707 long long offset;
708 long long len;
709 }__attribute__ ((packed));
710
711 struct streets_index_data_block
712 {
713 long long town_id;
714 int lat;
715 int lon;
716 char street_type;
717 char street_name[STREET_INDEX_STREET_NAME_SIZE - 1];
718 }__attribute__ ((packed));
719 // ------ STREET INDEX FILE ------
720
721
722 // ------ TOWN INDEX FILE ------
723
724 #define TOWN_INDEX_TOWN_NAME_SIZE 52 // (this value + 12) must be a 2^n number!!!
725 struct town_index_index_block_start
726 {
727 long long count_of_index_blocks;
728 }__attribute__ ((packed));
729
730 struct town_index_index_block
731 {
732 long long first_id;
733 long long offset;
734 long long len;
735 }__attribute__ ((packed));
736
737 struct town_index_data_block
738 {
739 long long town_id;
740 int country_id;
741 char town_name[TOWN_INDEX_TOWN_NAME_SIZE];
742 }__attribute__ ((packed));
743 // ------ TOWN INDEX FILE ------
744
745
746 /* misc.c */
747 extern struct rect world_bbox;
748
749 void bbox_extend(struct coord *c, struct rect *r);
750 void bbox(struct coord *c, int count, struct rect *r);
751 int contains_bbox(int xl, int yl, int xh, int yh, struct rect *r);
752 int bbox_contains_coord(struct rect *r, struct coord *c);
753 int bbox_contains_bbox(struct rect *out, struct rect *in);
754 long long bbox_area(struct rect const *r);
755 void phase1_map(GList *maps, FILE *out_ways, FILE *out_nodes);
756 void dump(FILE *in);
757 int phase4(FILE **in, int in_count, int with_range, char *suffix, FILE *tilesdir_out, struct zip_info *zip_info);
758 int phase5(FILE **in, FILE **references, int in_count, int with_range, char *suffix, struct zip_info *zip_info);
759 void process_binfile(FILE *in, FILE *out);
760 void add_aux_tiles(char *name, struct zip_info *info);
761 void cat(FILE *in, FILE *out);
762
763 /* osm.c */
764
765 extern long long seekpos_waynode[MAX_THREADS];
766 extern long long last_seekpos_waynode[MAX_THREADS];
767 extern osmid last_seek_wayid[MAX_THREADS];
768
769 struct maptool_osm
770 {
771 FILE *boundaries;
772 FILE *turn_restrictions;
773 FILE *nodes;
774 FILE *ways;
775 FILE *line2poi;
776 FILE *poly2poi;
777 FILE *towns;
778 FILE *relations_riverbank;
779 FILE *ways_with_coords;
780 };
781
782 struct country_table *country_from_countryid(int id);
783 void append_pre_resolved_ways(FILE *out, struct maptool_osm *osm2);
784 void osm_warning(char *type, long long id, int cont, char *fmt, ...);
785 void osm_add_tag(char *k, char *v);
786 void osm_add_node(osmid id, double lat, double lon);
787 void osm_add_way(osmid id);
788 void osm_add_relation(osmid id);
789 void osm_end_relation(struct maptool_osm *osm);
790 void osm_add_member(int type, osmid ref, char *role);
791 void osm_end_way(struct maptool_osm *osm);
792 void osm_end_node(struct maptool_osm *osm);
793 void osm_add_nd(osmid ref);
794 long long item_bin_get_id(struct item_bin *ib);
795 void flush_nodes(int final, int local_thread_num);
796 void sort_countries(int keep_tmpfiles);
797 void process_turn_restrictions(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out);
798 void clear_node_item_buffer(void);
799 void ref_ways(FILE *in, int local_thread_num);
800 void resolve_ways(FILE *in, FILE *out);
801 long long item_bin_get_nodeid(struct item_bin *ib);
802 long long item_bin_get_wayid(struct item_bin *ib);
803 long long item_bin_get_relationid(struct item_bin *ib);
804 FILE *resolve_ways_file(FILE *in, char *suffix, char *filename);
805 void process_way2poi(FILE *in, FILE *out, int type);
806 int map_find_intersections(FILE *in, FILE *out, FILE *out_index, FILE *out_graph, FILE *out_coastline, int final);
807 int map_find_intersections__quick__for__debug(FILE *in, FILE *out, FILE *out_index, FILE *out_graph, FILE *out_coastline, int final);
808 int copy_tags_to_ways(FILE *in, FILE *out, FILE *tags_in);
809 void write_countrydir(struct zip_info *zip_info);
810 GList* osm_process_towns(FILE *in, FILE *coords, FILE *boundaries, FILE *ways, GList *bl_manual);
811 void load_countries(void);
812 void remove_countryfiles(void);
813 struct country_table * country_from_iso2(char *iso);
814 void osm_init(FILE*);
815 osmid get_waynode_num(osmid way_id, int coord_num, int local_thread_num);
816 void map_find_housenumbers_interpolation(FILE *in, FILE *out);
817 void add_point_as_way_to_db(char *label, osmid id, int waytype, double lat, double lon);
818 int transform_from_geo_lat(double lat);
819 int transform_from_geo_lon(double lon);
820 double transform_to_geo_lat(int y);
821 double transform_to_geo_lon(int x);
822 void save_manual_country_borders_to_db(GList *man_borders);
823 int string_endswith2(const char* ending, const char* instring);
824 struct node_lat_lon* get_first_coord_of_boundary(struct item_bin *item_bin_3, struct relation_member *memb);
825 void purge_unused_towns();
826
827 extern struct item_bin *item_bin_2;
828
829 /* osm_psql.c */
830 int map_collect_data_osm_db(char *dbstr, struct maptool_osm *osm);
831
832 /* osm_protobuf.c */
833 //int map_collect_data_osm_protobuf(FILE *in, struct maptool_osm *osm);
834 //int osm_protobufdb_load(FILE *in, char *dir);
835
836 /* osm_relations.c */
837 struct relations * relations_new(void);
838 struct relations_func *relations_func_new(void(*func)(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv), void *func_priv);
839 void relations_add_func(struct relations *rel, struct relations_func *func, void *relation_priv, void *member_priv, int type, osmid id);
840 void relations_process(struct relations *rel, FILE *nodes, FILE *ways, FILE *relations);
841 void relations_destroy(struct relations *rel);
842
843 /* osm_xml.c */
844 int osm_xml_get_attribute(char *xml, char *attribute, char *buffer, int buffer_size);
845 void osm_xml_decode_entities(char *buffer);
846 int map_collect_data_osm(FILE *in, struct maptool_osm *osm);
847
848 /* sourcesink.c */
849
850 struct item_bin_sink *item_bin_sink_new(void);
851 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));
852 void item_bin_sink_func_destroy(struct item_bin_sink_func *func);
853 void item_bin_sink_add_func(struct item_bin_sink *sink, struct item_bin_sink_func *func);
854 void item_bin_sink_destroy(struct item_bin_sink *sink);
855 int item_bin_write_to_sink(struct item_bin *ib, struct item_bin_sink *sink, struct tile_data *tile_data);
856 struct item_bin_sink *file_reader_new(FILE *in, int limit, int offset);
857 int file_reader_finish(struct item_bin_sink *sink);
858 int file_writer_process(struct item_bin_sink_func *func, struct item_bin *ib, struct tile_data *tile_data);
859 struct item_bin_sink_func *file_writer_new(FILE *out);
860 int file_writer_finish(struct item_bin_sink_func *file_writer);
861 int tile_collector_process(struct item_bin_sink_func *tile_collector, struct item_bin *ib, struct tile_data *tile_data);
862 struct item_bin_sink_func *tile_collector_new(struct item_bin_sink *out);
863
864 /* tempfile.c */
865
866 char *tempfile_name(char *suffix, char *name);
867 FILE *tempfile(char *suffix, char *name, int mode);
868 void tempfile_unlink(char *suffix, char *name);
869 void tempfile_rename(char *suffix, char *from, char *to);
870 void tempfile_copyrename(char *suffix, char *from, char *to);
871
872 /* tile.c */
873 extern GHashTable *tile_hash, *tile_hash2;
874
875 struct aux_tile
876 {
877 char *name;
878 char *filename;
879 int size;
880 };
881
882 extern GList *aux_tile_list;
883
884 int tile(struct rect *r, char *suffix, char *ret, int max, int overlap, struct rect *tr);
885 void tile_bbox(char *tile, struct rect *r, int overlap);
886 int tile_len(char *tile);
887 void tile_write_item_to_tile(struct tile_info *info, struct item_bin *ib, FILE *reference, char *name);
888 void tile_write_item_minmax(struct tile_info *info, struct item_bin *ib, FILE *reference, int min, int max);
889 int add_aux_tile(struct zip_info *zip_info, char *name, char *filename, int size);
890 int write_aux_tiles(struct zip_info *zip_info);
891 int create_tile_hash(void);
892 void write_tilesdir(struct tile_info *info, struct zip_info *zip_info, FILE *out);
893 void merge_tiles(struct tile_info *info);
894 struct attr map_information_attrs[32];
895 void index_init(struct zip_info *info, int version);
896 void index_submap_add(struct tile_info *info, struct tile_head *th);
897
898 /* zip.c */
899 void write_zipmember(struct zip_info *zip_info, char *name, int filelen, char *data, int data_size);
900 void zip_write_index(struct zip_info *info);
901 int zip_write_directory(struct zip_info *info);
902 struct zip_info *zip_new(void);
903 void zip_set_md5(struct zip_info *info, int on);
904 int zip_get_md5(struct zip_info *info, unsigned char *out);
905 void zip_set_zip64(struct zip_info *info, int on);
906 void zip_set_compression_level(struct zip_info *info, int level);
907 void zip_set_maxnamelen(struct zip_info *info, int max);
908 int zip_get_maxnamelen(struct zip_info *info);
909 int zip_add_member(struct zip_info *info);
910 int zip_set_timestamp(struct zip_info *info, char *timestamp);
911 int zip_set_password(struct zip_info *info, char *password);
912 void zip_open(struct zip_info *info, char *out, char *dir, char *index);
913 FILE *zip_get_index(struct zip_info *info);
914 int zip_get_zipnum(struct zip_info *info);
915 void zip_set_zipnum(struct zip_info *info, int num);
916 void zip_close(struct zip_info *info);
917 void zip_destroy(struct zip_info *info);
918
919
920 // color codes for colour attribute in OS;
921
922 unsigned int color_int_value_from_string(char* color_str);
923
924 struct css_color
925 {
926 char *col_name;
927 unsigned int col_value;
928 };
929
930 /*
931 unsinged int color_int;
932
933 unsinged int b=color_int & 0xff;
934 unsinged int g=(color_int >> 8) & 0xff;
935 unsinged int r=(color_int >> 16) & 0xff;
936
937 b=b << 8;
938 g=g << 8;
939 r=r << 8;
940 */
941
942
943 #define _css_aliceblue 0xf0f8ff
944 #define _css_antiquewhite 0xfaebd7
945 #define _css_aqua 0x00ffff
946 #define _css_aquamarine 0x7fffd4
947 #define _css_azure 0xf0ffff
948 #define _css_beige 0xf5f5dc
949 #define _css_bisque 0xffe4c4
950 #define _css_black 0x000000
951 #define _css_blanchedalmond 0xffebcd
952 #define _css_blue 0x0000ff
953 #define _css_blueviolet 0x8a2be2
954 #define _css_brown 0xa52a2a
955 #define _css_burlywood 0xdeb887
956 #define _css_cadetblue 0x5f9ea0
957 #define _css_chartreuse 0x7fff00
958 #define _css_chocolate 0xd2691e
959 #define _css_coral 0xff7f50
960 #define _css_cornflowerblue 0x6495ed
961 #define _css_cornsilk 0xfff8dc
962 #define _css_crimson 0xdc143c
963 #define _css_cyan 0x00ffff
964 #define _css_darkblue 0x00008b
965 #define _css_darkcyan 0x008b8b
966 #define _css_darkgoldenrod 0xb8860b
967 #define _css_darkgray 0xa9a9a9
968 #define _css_darkgreen 0x006400
969 #define _css_darkkhaki 0xbdb76b
970 #define _css_darkmagenta 0x8b008b
971 #define _css_darkolivegreen 0x556b2f
972 #define _css_darkorange 0xff8c00
973 #define _css_darkorchid 0x9932cc
974 #define _css_darkred 0x8b0000
975 #define _css_darksalmon 0xe9967a
976 #define _css_darkseagreen 0x8fbc8f
977 #define _css_darkslateblue 0x483d8b
978 #define _css_darkslategray 0x2f4f4f
979 #define _css_darkturquoise 0x00ced1
980 #define _css_darkviolet 0x9400d3
981 #define _css_deeppink 0xff1493
982 #define _css_deepskyblue 0x00bfff
983 #define _css_dimgray 0x696969
984 #define _css_dodgerblue 0x1e90ff
985 #define _css_firebrick 0xb22222
986 #define _css_floralwhite 0xfffaf0
987 #define _css_forestgreen 0x228b22
988 #define _css_fuchsia 0xff00ff
989 #define _css_gainsboro 0xdcdcdc
990 #define _css_ghostwhite 0xf8f8ff
991 #define _css_gold 0xffd700
992 #define _css_goldenrod 0xdaa520
993 #define _css_gray 0x808080
994 #define _css_green 0x008000
995 #define _css_greenyellow 0xadff2f
996 #define _css_honeydew 0xf0fff0
997 #define _css_hotpink 0xff69b4
998 #define _css_indianred 0xcd5c5c
999 #define _css_indigo 0x4b0082
1000 #define _css_ivory 0xfffff0
1001 #define _css_khaki 0xf0e68c
1002 #define _css_lavender 0xe6e6fa
1003 #define _css_lavenderblush 0xfff0f5
1004 #define _css_lawngreen 0x7cfc00
1005 #define _css_lemonchiffon 0xfffacd
1006 #define _css_lightblue 0xadd8e6
1007 #define _css_lightcoral 0xf08080
1008 #define _css_lightcyan 0xe0ffff
1009 #define _css_lightgoldenrodyellow 0xfafad2
1010 #define _css_lightgrey 0xd3d3d3
1011 #define _css_lightgreen 0x90ee90
1012 #define _css_lightpink 0xffb6c1
1013 #define _css_lightsalmon 0xffa07a
1014 #define _css_lightseagreen 0x20b2aa
1015 #define _css_lightskyblue 0x87cefa
1016 #define _css_lightslategray 0x778899
1017 #define _css_lightsteelblue 0xb0c4de
1018 #define _css_lightyellow 0xffffe0
1019 #define _css_lime 0x00ff00
1020 #define _css_limegreen 0x32cd32
1021 #define _css_linen 0xfaf0e6
1022 #define _css_magenta 0xff00ff
1023 #define _css_maroon 0x800000
1024 #define _css_mediumaquamarine 0x66cdaa
1025 #define _css_mediumblue 0x0000cd
1026 #define _css_mediumorchid 0xba55d3
1027 #define _css_mediumpurple 0x9370d8
1028 #define _css_mediumseagreen 0x3cb371
1029 #define _css_mediumslateblue 0x7b68ee
1030 #define _css_mediumspringgreen 0x00fa9a
1031 #define _css_mediumturquoise 0x48d1cc
1032 #define _css_mediumvioletred 0xc71585
1033 #define _css_midnightblue 0x191970
1034 #define _css_mintcream 0xf5fffa
1035 #define _css_mistyrose 0xffe4e1
1036 #define _css_moccasin 0xffe4b5
1037 #define _css_navajowhite 0xffdead
1038 #define _css_navy 0x000080
1039 #define _css_oldlace 0xfdf5e6
1040 #define _css_olive 0x808000
1041 #define _css_olivedrab 0x6b8e23
1042 #define _css_orange 0xffa500
1043 #define _css_orangered 0xff4500
1044 #define _css_orchid 0xda70d6
1045 #define _css_palegoldenrod 0xeee8aa
1046 #define _css_palegreen 0x98fb98
1047 #define _css_paleturquoise 0xafeeee
1048 #define _css_palevioletred 0xd87093
1049 #define _css_papayawhip 0xffefd5
1050 #define _css_peachpuff 0xffdab9
1051 #define _css_peru 0xcd853f
1052 #define _css_pink 0xffc0cb
1053 #define _css_plum 0xdda0dd
1054 #define _css_powderblue 0xb0e0e6
1055 #define _css_purple 0x800080
1056 #define _css_red 0xff0000
1057 #define _css_rosybrown 0xbc8f8f
1058 #define _css_royalblue 0x4169e1
1059 #define _css_saddlebrown 0x8b4513
1060 #define _css_salmon 0xfa8072
1061 #define _css_sandybrown 0xf4a460
1062 #define _css_seagreen 0x2e8b57
1063 #define _css_seashell 0xfff5ee
1064 #define _css_sienna 0xa0522d
1065 #define _css_silver 0xc0c0c0
1066 #define _css_skyblue 0x87ceeb
1067 #define _css_slateblue 0x6a5acd
1068 #define _css_slategray 0x708090
1069 #define _css_snow 0xfffafa
1070 #define _css_springgreen 0x00ff7f
1071 #define _css_steelblue 0x4682b4
1072 #define _css_tan 0xd2b48c
1073 #define _css_teal 0x008080
1074 #define _css_thistle 0xd8bfd8
1075 #define _css_tomato 0xff6347
1076 #define _css_turquoise 0x40e0d0
1077 #define _css_violet 0xee82ee
1078 #define _css_wheat 0xf5deb3
1079 #define _css_white 0xffffff
1080 #define _css_whitesmoke 0xf5f5f5
1081 #define _css_yellow 0xffff00
1082 #define _css_yellowgreen 0x9acd32
1083
1084
1085
1086 // #define dbg(level,...) { fprintf(stderr , __VA_ARGS__); }
1087
1088
1089

   
Visit the ZANavi Wiki