|
|
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 | |
|
|
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 |
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-------- |
|
|
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 | |
40 | struct rect { |
247 | struct rect |
|
|
248 | { |
41 | struct coord l,h; |
249 | struct coord l, h; |
42 | }; |
250 | }; |
43 | |
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 | |
44 | struct tile_data { |
267 | struct 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 | |
51 | struct tile_parameter { |
275 | struct 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 | |
57 | struct tile_info { |
282 | struct 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 | |
65 | extern struct tile_head { |
291 | extern 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 | |
|
|
79 | struct item_bin { |
304 | struct 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 | |
85 | struct attr_bin { |
311 | struct attr_bin |
|
|
312 | { |
86 | int len; |
313 | int len; |
87 | enum attr_type type; |
314 | enum attr_type type; |
88 | }; |
315 | }; |
89 | |
316 | |
90 | |
|
|
91 | struct item_bin_sink_func { |
317 | struct 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 | |
96 | struct item_bin_sink { |
323 | struct 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 | |
|
|
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 | |
101 | struct zip_info; |
352 | struct zip_info; |
|
|
353 | struct country_table; |
102 | |
354 | |
103 | /* boundaries.c */ |
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 | }; |
104 | |
365 | |
|
|
366 | char *osm_tag_value(struct item_bin *ib, char *key); |
|
|
367 | long long *boundary_relid(struct boundary *b); |
105 | int process_boundaries(FILE *boundaries, FILE *ways); |
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); |
106 | |
374 | |
107 | /* buffer.c */ |
375 | /* buffer.c */ |
108 | struct buffer { |
376 | struct 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 | |
125 | void process_coastlines(FILE *in, FILE *out); |
394 | void process_coastlines(FILE *in, FILE *out); |
126 | |
395 | |
127 | /* geom.c */ |
396 | /* geom.c */ |
128 | |
397 | |
129 | enum geom_poly_segment_type { |
398 | enum 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 | |
139 | struct geom_poly_segment { |
404 | struct 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 | |
144 | void geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse); |
410 | void geom_coord_copy(struct coord *from, struct coord *to, int count, int reverse); |
145 | void geom_coord_revert(struct coord *c, int count); |
411 | void geom_coord_revert(struct coord *c, int count); |
146 | long long geom_poly_area(struct coord *c, int count); |
412 | long long geom_poly_area(struct coord *c, int count); |
… | |
… | |
151 | GList *geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type); |
417 | GList *geom_poly_segments_sort(GList *in, enum geom_poly_segment_type type); |
152 | struct geom_poly_segment *item_bin_to_poly_segment(struct item_bin *ib, int type); |
418 | struct geom_poly_segment *item_bin_to_poly_segment(struct item_bin *ib, int type); |
153 | int geom_poly_segments_point_inside(GList *in, struct coord *c); |
419 | int geom_poly_segments_point_inside(GList *in, struct coord *c); |
154 | void clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out); |
420 | void clip_line(struct item_bin *ib, struct rect *r, struct tile_parameter *param, struct item_bin_sink *out); |
155 | void clip_polygon(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); |
156 | |
423 | |
157 | /* itembin.c */ |
424 | /* itembin.c */ |
158 | |
425 | |
159 | int item_bin_read(struct item_bin *ib, FILE *in); |
426 | int item_bin_read(struct item_bin *ib, FILE *in); |
160 | void item_bin_set_type(struct item_bin *ib, enum item_type type); |
427 | void item_bin_set_type(struct item_bin *ib, enum item_type type); |
… | |
… | |
172 | void *item_bin_get_attr(struct item_bin *ib, enum attr_type type, void *last); |
439 | void *item_bin_get_attr(struct item_bin *ib, enum attr_type type, void *last); |
173 | struct attr_bin * item_bin_get_attr_bin_last(struct item_bin *ib); |
440 | struct attr_bin * item_bin_get_attr_bin_last(struct item_bin *ib); |
174 | void item_bin_add_attr_longlong(struct item_bin *ib, enum attr_type type, long long val); |
441 | void item_bin_add_attr_longlong(struct item_bin *ib, enum attr_type type, long long val); |
175 | void item_bin_add_attr_string(struct item_bin *ib, enum attr_type type, char *str); |
442 | void item_bin_add_attr_string(struct item_bin *ib, enum attr_type type, char *str); |
176 | void item_bin_add_attr_range(struct item_bin *ib, enum attr_type type, short min, short max); |
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); |
177 | void item_bin_write(struct item_bin *ib, FILE *out); |
445 | void item_bin_write(struct item_bin *ib, FILE *out); |
|
|
446 | void item_bin_write_xml(struct item_bin *ib, char *filename); |
178 | struct item_bin *item_bin_dup(struct item_bin *ib); |
447 | struct item_bin *item_bin_dup(struct item_bin *ib); |
179 | void item_bin_write_range(struct item_bin *ib, FILE *out, int min, int max); |
448 | void item_bin_write_range(struct item_bin *ib, FILE *out, int min, int max); |
180 | void item_bin_write_clipped(struct item_bin *ib, struct tile_parameter *param, struct item_bin_sink *out); |
449 | void item_bin_write_clipped(struct item_bin *ib, struct tile_parameter *param, struct item_bin_sink *out); |
181 | void item_bin_dump(struct item_bin *ib, FILE *out); |
450 | void item_bin_dump(struct item_bin *ib, FILE *out); |
182 | void dump_itembin(struct item_bin *ib); |
451 | void dump_itembin(struct item_bin *ib); |
183 | void item_bin_set_type_by_population(struct item_bin *ib, int population); |
452 | void item_bin_set_type_by_population(struct item_bin *ib, int population); |
184 | void item_bin_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, FILE *out); |
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); |
185 | int item_bin_sort_file(char *in_file, char *out_file, struct rect *r, int *size); |
455 | int 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 */ |
|
|
458 | struct node_item *read_node_item(FILE *in, int local_thread_num); |
188 | struct item_bin *read_item(FILE *in); |
459 | struct item_bin *read_item(FILE *in, int local_thread_num); |
189 | struct item_bin *read_item_range(FILE *in, int *min, int *max); |
460 | struct item_bin *read_item_range(FILE *in, int *min, int *max, int local_thread_num); |
190 | struct item_bin *init_item(enum item_type type); |
461 | struct item_bin *init_item(enum item_type type, int local_thread_num); |
191 | |
462 | |
192 | /* maptool.c */ |
463 | /* maptool.c */ |
193 | |
464 | |
194 | extern long long slice_size; |
465 | extern long long slice_size; |
195 | extern int attr_debug_level; |
466 | extern int attr_debug_level; |
196 | extern char *suffix; |
467 | extern char *suffix; |
197 | extern int ignore_unkown; |
468 | extern int ignore_unkown; |
198 | extern GHashTable *dedupe_ways_hash; |
469 | // extern GHashTable *dedupe_ways_hash; |
199 | extern int phase; |
470 | extern int phase; |
200 | extern int slices; |
471 | extern int slices; |
|
|
472 | |
|
|
473 | #define MAX_THREADS 8 |
|
|
474 | |
|
|
475 | extern struct buffer node_buffer[MAX_THREADS]; |
201 | extern struct buffer node_buffer; |
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 | |
202 | extern int processed_nodes, processed_nodes_out, processed_ways, processed_relations, processed_tiles; |
483 | extern int processed_nodes, processed_nodes_out, processed_ways, processed_relations, processed_tiles; |
203 | extern struct item_bin *item_bin; |
484 | extern struct item_bin *item_bin; |
204 | extern int bytes_read; |
485 | extern int bytes_read; |
205 | extern int overlap; |
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; |
206 | void sig_alrm(int sig); |
491 | void sig_alrm(int sig); |
207 | void sig_alrm_end(void); |
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 | |
208 | |
558 | |
209 | /* misc.c */ |
559 | /* misc.c */ |
210 | extern struct rect world_bbox; |
560 | extern struct rect world_bbox; |
211 | |
|
|
212 | |
561 | |
213 | void bbox_extend(struct coord *c, struct rect *r); |
562 | void bbox_extend(struct coord *c, struct rect *r); |
214 | void bbox(struct coord *c, int count, struct rect *r); |
563 | void bbox(struct coord *c, int count, struct rect *r); |
215 | int contains_bbox(int xl, int yl, int xh, int yh, struct rect *r); |
564 | int contains_bbox(int xl, int yl, int xh, int yh, struct rect *r); |
216 | int bbox_contains_coord(struct rect *r, struct coord *c); |
565 | int bbox_contains_coord(struct rect *r, struct coord *c); |
… | |
… | |
222 | int phase5(FILE **in, FILE **references, int in_count, int with_range, char *suffix, 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); |
223 | void process_binfile(FILE *in, FILE *out); |
572 | void process_binfile(FILE *in, FILE *out); |
224 | void add_aux_tiles(char *name, struct zip_info *info); |
573 | void add_aux_tiles(char *name, struct zip_info *info); |
225 | void cat(FILE *in, FILE *out); |
574 | void cat(FILE *in, FILE *out); |
226 | |
575 | |
227 | |
|
|
228 | /* osm.c */ |
576 | /* osm.c */ |
229 | typedef long int osmid; |
577 | typedef long int osmid; |
230 | |
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, ...); |
231 | void osm_add_tag(char *k, char *v); |
594 | void osm_add_tag(char *k, char *v); |
232 | void osm_add_node(osmid id, double lat, double lon); |
595 | void osm_add_node(osmid id, double lat, double lon); |
233 | void osm_add_way(osmid id); |
596 | void osm_add_way(osmid id); |
234 | void osm_add_relation(osmid id); |
597 | void osm_add_relation(osmid id); |
235 | void osm_end_relation(FILE *turn_restrictions, FILE *boundaries); |
598 | void osm_end_relation(struct maptool_osm *osm); |
236 | void osm_add_member(int type, osmid ref, char *role); |
599 | void osm_add_member(int type, osmid ref, char *role); |
237 | void osm_end_way(FILE *out); |
600 | void osm_end_way(struct maptool_osm *osm); |
238 | void osm_end_node(FILE *out); |
601 | void osm_end_node(struct maptool_osm *osm); |
239 | void osm_add_nd(osmid ref); |
602 | void osm_add_nd(osmid ref); |
240 | long long item_bin_get_id(struct item_bin *ib); |
603 | long long item_bin_get_id(struct item_bin *ib); |
241 | void flush_nodes(int final); |
604 | void flush_nodes(int final, int local_thread_num); |
242 | void sort_countries(int keep_tmpfiles); |
605 | void sort_countries(int keep_tmpfiles); |
243 | void process_turn_restrictions(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out); |
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); |
244 | int resolve_ways(FILE *in, FILE *out); |
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); |
245 | int map_find_intersections(FILE *in, FILE *out, FILE *out_index, FILE *out_graph, FILE *out_coastline, int final); |
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); |
246 | void write_countrydir(struct zip_info *zip_info); |
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); |
247 | void remove_countryfiles(void); |
620 | void remove_countryfiles(void); |
|
|
621 | struct country_table * country_from_iso2(char *iso); |
248 | void osm_init(FILE*); |
622 | void osm_init(FILE*); |
249 | |
623 | |
|
|
624 | extern struct item_bin *item_bin_2; |
|
|
625 | |
250 | /* osm_psql.c */ |
626 | /* osm_psql.c */ |
251 | int map_collect_data_osm_db(char *dbstr, FILE *out_ways, FILE *out_nodes, FILE *out_turn_restrictions, FILE *out_boundaries); |
627 | int map_collect_data_osm_db(char *dbstr, struct maptool_osm *osm); |
252 | |
628 | |
253 | /* osm_protobuf.c */ |
629 | /* osm_protobuf.c */ |
254 | int 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); |
255 | int osm_protobufdb_load(FILE *in, char *dir); |
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); |
256 | |
638 | |
257 | /* osm_xml.c */ |
639 | /* osm_xml.c */ |
258 | int osm_xml_get_attribute(char *xml, char *attribute, char *buffer, int buffer_size); |
640 | int osm_xml_get_attribute(char *xml, char *attribute, char *buffer, int buffer_size); |
259 | void osm_xml_decode_entities(char *buffer); |
641 | void osm_xml_decode_entities(char *buffer); |
260 | int map_collect_data_osm(FILE *in, FILE *out_ways, FILE *out_nodes, FILE *out_turn_restrictions, FILE *out_boundaries); |
642 | int map_collect_data_osm(FILE *in, struct maptool_osm *osm); |
261 | |
|
|
262 | |
643 | |
263 | /* sourcesink.c */ |
644 | /* sourcesink.c */ |
264 | |
645 | |
265 | struct item_bin_sink *item_bin_sink_new(void); |
646 | struct item_bin_sink *item_bin_sink_new(void); |
266 | 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)); |
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)); |
267 | void item_bin_sink_func_destroy(struct item_bin_sink_func *func); |
648 | void item_bin_sink_func_destroy(struct item_bin_sink_func *func); |
268 | void item_bin_sink_add_func(struct item_bin_sink *sink, struct item_bin_sink_func *func); |
649 | void item_bin_sink_add_func(struct item_bin_sink *sink, struct item_bin_sink_func *func); |
269 | void item_bin_sink_destroy(struct item_bin_sink *sink); |
650 | void item_bin_sink_destroy(struct item_bin_sink *sink); |
270 | int item_bin_write_to_sink(struct item_bin *ib, struct item_bin_sink *sink, struct tile_data *tile_data); |
651 | int item_bin_write_to_sink(struct item_bin *ib, struct item_bin_sink *sink, struct tile_data *tile_data); |
271 | struct item_bin_sink *file_reader_new(FILE *in, int limit, int offset); |
652 | struct item_bin_sink *file_reader_new(FILE *in, int limit, int offset); |
… | |
… | |
282 | FILE *tempfile(char *suffix, char *name, int mode); |
663 | FILE *tempfile(char *suffix, char *name, int mode); |
283 | void tempfile_unlink(char *suffix, char *name); |
664 | void tempfile_unlink(char *suffix, char *name); |
284 | void tempfile_rename(char *suffix, char *from, char *to); |
665 | void tempfile_rename(char *suffix, char *from, char *to); |
285 | |
666 | |
286 | /* tile.c */ |
667 | /* tile.c */ |
287 | extern GHashTable *tile_hash,*tile_hash2; |
668 | extern GHashTable *tile_hash, *tile_hash2; |
288 | |
669 | |
289 | struct aux_tile { |
670 | struct 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 | |
… | |
… | |
326 | FILE *zip_get_index(struct zip_info *info); |
708 | FILE *zip_get_index(struct zip_info *info); |
327 | int zip_get_zipnum(struct zip_info *info); |
709 | int zip_get_zipnum(struct zip_info *info); |
328 | void zip_set_zipnum(struct zip_info *info, int num); |
710 | void zip_set_zipnum(struct zip_info *info, int num); |
329 | void zip_close(struct zip_info *info); |
711 | void zip_close(struct zip_info *info); |
330 | void zip_destroy(struct zip_info *info); |
712 | void zip_destroy(struct zip_info *info); |
|
|
713 | |