… | |
… | |
30 | #define LONGLONG_FMT "%I64d" |
30 | #define LONGLONG_FMT "%I64d" |
31 | #else |
31 | #else |
32 | #define LONGLONG_FMT "%lld" |
32 | #define LONGLONG_FMT "%lld" |
33 | #endif |
33 | #endif |
34 | |
34 | |
|
|
35 | |
|
|
36 | #define sq(x) ((double)(x)*(x)) |
|
|
37 | |
|
|
38 | |
35 | #define BUFFER_SIZE 1280 |
39 | #define BUFFER_SIZE 1280 |
36 | |
40 | |
37 | #define debug_tile(x) 0 |
41 | #define debug_tile(x) 0 |
38 | #define debug_itembin(x) 0 |
42 | #define debug_itembin(x) 0 |
39 | |
43 | |
… | |
… | |
96 | struct item_bin_sink { |
100 | struct item_bin_sink { |
97 | void *priv_data[8]; |
101 | void *priv_data[8]; |
98 | GList *sink_funcs; |
102 | GList *sink_funcs; |
99 | }; |
103 | }; |
100 | |
104 | |
|
|
105 | struct node_item { |
|
|
106 | int id; |
|
|
107 | char ref_node; |
|
|
108 | char ref_way; |
|
|
109 | char ref_ref; |
|
|
110 | char dummy; |
|
|
111 | struct coord c; |
|
|
112 | }; |
|
|
113 | |
101 | struct zip_info; |
114 | struct zip_info; |
|
|
115 | struct country_table; |
102 | |
116 | |
103 | /* boundaries.c */ |
117 | /* boundaries.c */ |
|
|
118 | struct boundary { |
|
|
119 | struct item_bin *ib; |
|
|
120 | struct country_table *country; |
|
|
121 | char *iso2; |
|
|
122 | GList *segments,*sorted_segments; |
|
|
123 | GList *children; |
|
|
124 | struct rect r; |
|
|
125 | }; |
104 | |
126 | |
|
|
127 | char *osm_tag_value(struct item_bin *ib, char *key); |
|
|
128 | long long *boundary_relid(struct boundary *b); |
105 | int process_boundaries(FILE *boundaries, FILE *ways); |
129 | GList *process_boundaries(FILE *boundaries, FILE *ways); |
|
|
130 | GList *boundary_find_matches(GList *bl, struct coord *c); |
106 | |
131 | |
107 | /* buffer.c */ |
132 | /* buffer.c */ |
108 | struct buffer { |
133 | struct buffer { |
109 | int malloced_step; |
134 | int malloced_step; |
110 | long long malloced; |
135 | long long malloced; |
… | |
… | |
172 | void *item_bin_get_attr(struct item_bin *ib, enum attr_type type, void *last); |
197 | 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); |
198 | 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); |
199 | 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); |
200 | 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); |
201 | void item_bin_add_attr_range(struct item_bin *ib, enum attr_type type, short min, short max); |
|
|
202 | void item_bin_remove_attr(struct item_bin *ib, void *ptr); |
177 | void item_bin_write(struct item_bin *ib, FILE *out); |
203 | void item_bin_write(struct item_bin *ib, FILE *out); |
178 | struct item_bin *item_bin_dup(struct item_bin *ib); |
204 | 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); |
205 | 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); |
206 | 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); |
207 | void item_bin_dump(struct item_bin *ib, FILE *out); |
182 | void dump_itembin(struct item_bin *ib); |
208 | void dump_itembin(struct item_bin *ib); |
183 | void item_bin_set_type_by_population(struct item_bin *ib, int population); |
209 | 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); |
210 | void item_bin_write_match(struct item_bin *ib, enum attr_type type, enum attr_type match, FILE *out); |
|
|
211 | 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); |
212 | int item_bin_sort_file(char *in_file, char *out_file, struct rect *r, int *size); |
186 | |
213 | |
187 | /* itembin_buffer.c */ |
214 | /* itembin_buffer.c */ |
|
|
215 | struct node_item *read_node_item(FILE *in); |
188 | struct item_bin *read_item(FILE *in); |
216 | struct item_bin *read_item(FILE *in); |
189 | struct item_bin *read_item_range(FILE *in, int *min, int *max); |
217 | struct item_bin *read_item_range(FILE *in, int *min, int *max); |
190 | struct item_bin *init_item(enum item_type type); |
218 | struct item_bin *init_item(enum item_type type); |
191 | |
219 | |
192 | /* maptool.c */ |
220 | /* maptool.c */ |
… | |
… | |
201 | extern struct buffer node_buffer; |
229 | extern struct buffer node_buffer; |
202 | extern int processed_nodes, processed_nodes_out, processed_ways, processed_relations, processed_tiles; |
230 | extern int processed_nodes, processed_nodes_out, processed_ways, processed_relations, processed_tiles; |
203 | extern struct item_bin *item_bin; |
231 | extern struct item_bin *item_bin; |
204 | extern int bytes_read; |
232 | extern int bytes_read; |
205 | extern int overlap; |
233 | extern int overlap; |
|
|
234 | extern int experimental; |
|
|
235 | extern int use_global_fixed_country_id; |
|
|
236 | extern int global_fixed_country_id; |
|
|
237 | extern int unknown_country; |
206 | void sig_alrm(int sig); |
238 | void sig_alrm(int sig); |
207 | void sig_alrm_end(void); |
239 | void sig_alrm_end(void); |
|
|
240 | extern int border_only_map; |
|
|
241 | extern int coastline_only_map; |
208 | |
242 | |
209 | /* misc.c */ |
243 | /* misc.c */ |
210 | extern struct rect world_bbox; |
244 | extern struct rect world_bbox; |
211 | |
245 | |
212 | |
246 | |
… | |
… | |
226 | |
260 | |
227 | |
261 | |
228 | /* osm.c */ |
262 | /* osm.c */ |
229 | typedef long int osmid; |
263 | typedef long int osmid; |
230 | |
264 | |
|
|
265 | struct maptool_osm { |
|
|
266 | FILE *boundaries; |
|
|
267 | FILE *turn_restrictions; |
|
|
268 | FILE *nodes; |
|
|
269 | FILE *ways; |
|
|
270 | FILE *line2poi; |
|
|
271 | FILE *poly2poi; |
|
|
272 | FILE *towns; |
|
|
273 | }; |
|
|
274 | |
|
|
275 | |
|
|
276 | void osm_warning(char *type, long long id, int cont, char *fmt, ...); |
231 | void osm_add_tag(char *k, char *v); |
277 | void osm_add_tag(char *k, char *v); |
232 | void osm_add_node(osmid id, double lat, double lon); |
278 | void osm_add_node(osmid id, double lat, double lon); |
233 | void osm_add_way(osmid id); |
279 | void osm_add_way(osmid id); |
234 | void osm_add_relation(osmid id); |
280 | void osm_add_relation(osmid id); |
235 | void osm_end_relation(FILE *turn_restrictions, FILE *boundaries); |
281 | void osm_end_relation(struct maptool_osm *osm); |
236 | void osm_add_member(int type, osmid ref, char *role); |
282 | void osm_add_member(int type, osmid ref, char *role); |
237 | void osm_end_way(FILE *out); |
283 | void osm_end_way(struct maptool_osm *osm); |
238 | void osm_end_node(FILE *out); |
284 | void osm_end_node(struct maptool_osm *osm); |
239 | void osm_add_nd(osmid ref); |
285 | void osm_add_nd(osmid ref); |
240 | long long item_bin_get_id(struct item_bin *ib); |
286 | long long item_bin_get_id(struct item_bin *ib); |
241 | void flush_nodes(int final); |
287 | void flush_nodes(int final); |
242 | void sort_countries(int keep_tmpfiles); |
288 | void sort_countries(int keep_tmpfiles); |
243 | void process_turn_restrictions(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out); |
289 | void process_turn_restrictions(FILE *in, FILE *coords, FILE *ways, FILE *ways_index, FILE *out); |
|
|
290 | void clear_node_item_buffer(void); |
|
|
291 | void ref_ways(FILE *in); |
244 | int resolve_ways(FILE *in, FILE *out); |
292 | void resolve_ways(FILE *in, FILE *out); |
|
|
293 | long long item_bin_get_nodeid(struct item_bin *ib); |
|
|
294 | long long item_bin_get_wayid(struct item_bin *ib); |
|
|
295 | long long item_bin_get_relationid(struct item_bin *ib); |
|
|
296 | FILE *resolve_ways_file(FILE *in, char *suffix, char *filename); |
|
|
297 | 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); |
298 | int map_find_intersections(FILE *in, FILE *out, FILE *out_index, FILE *out_graph, FILE *out_coastline, int final); |
246 | void write_countrydir(struct zip_info *zip_info); |
299 | void write_countrydir(struct zip_info *zip_info); |
|
|
300 | void osm_process_towns(FILE *in, FILE *boundaries, FILE *ways); |
|
|
301 | void load_countries(void); |
247 | void remove_countryfiles(void); |
302 | void remove_countryfiles(void); |
|
|
303 | struct country_table * country_from_iso2(char *iso); |
248 | void osm_init(FILE*); |
304 | void osm_init(FILE*); |
249 | |
305 | |
250 | /* osm_psql.c */ |
306 | /* 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); |
307 | int map_collect_data_osm_db(char *dbstr, struct maptool_osm *osm); |
252 | |
308 | |
253 | /* osm_protobuf.c */ |
309 | /* 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); |
310 | int map_collect_data_osm_protobuf(FILE *in, struct maptool_osm *osm); |
255 | int osm_protobufdb_load(FILE *in, char *dir); |
311 | int osm_protobufdb_load(FILE *in, char *dir); |
|
|
312 | |
|
|
313 | |
|
|
314 | /* osm_relations.c */ |
|
|
315 | struct relations * relations_new(void); |
|
|
316 | struct relations_func *relations_func_new(void (*func)(void *func_priv, void *relation_priv, struct item_bin *member, void *member_priv), void *func_priv); |
|
|
317 | void relations_add_func(struct relations *rel, struct relations_func *func, void *relation_priv, void *member_priv, int type, osmid id); |
|
|
318 | void relations_process(struct relations *rel, FILE *nodes, FILE *ways, FILE *relations); |
256 | |
319 | |
257 | /* osm_xml.c */ |
320 | /* osm_xml.c */ |
258 | int osm_xml_get_attribute(char *xml, char *attribute, char *buffer, int buffer_size); |
321 | int osm_xml_get_attribute(char *xml, char *attribute, char *buffer, int buffer_size); |
259 | void osm_xml_decode_entities(char *buffer); |
322 | 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); |
323 | int map_collect_data_osm(FILE *in, struct maptool_osm *osm); |
261 | |
324 | |
262 | |
325 | |
263 | /* sourcesink.c */ |
326 | /* sourcesink.c */ |
264 | |
327 | |
265 | struct item_bin_sink *item_bin_sink_new(void); |
328 | struct item_bin_sink *item_bin_sink_new(void); |