diff options
author | Stefan Wildemann <gta04@metalstrolche.de> | 2019-08-01 00:32:04 +0200 |
---|---|---|
committer | Stefan Wildemann <gta04@metalstrolche.de> | 2019-08-01 00:32:04 +0200 |
commit | fa45f14cde72efe75a2c43cccbcb773e8fd3f2cc (patch) | |
tree | 02fc1dce710110cc211254891add79b42309b92e | |
parent | 8061e9b1e4a82368d8acf626179f9e657fea4664 (diff) | |
download | navit-fa45f14cde72efe75a2c43cccbcb773e8fd3f2cc.tar.gz |
Move multipolygons to own tempfile, simplify filtering
Note: the simpler filtering results in bigger disk space required.
But we cannot filter unknown streets early anymore, as they may be
required for polygon processing
-rw-r--r-- | navit/item.h | 2 | ||||
-rw-r--r-- | navit/maptool/maptool.c | 18 | ||||
-rw-r--r-- | navit/maptool/misc.c | 12 | ||||
-rw-r--r-- | navit/maptool/osm.c | 31 |
4 files changed, 41 insertions, 22 deletions
diff --git a/navit/item.h b/navit/item.h index c3b17bdb8..0d0e84c7f 100644 --- a/navit/item.h +++ b/navit/item.h @@ -50,7 +50,7 @@ extern int default_flags[]; #define item_type_is_area(type) ((type) >= type_area) #define item_is_town(item) ((item).type >= type_town_label && (item).type <= type_district_label_1e7) #define item_is_district(item) ((item).type >= type_district_label && (item).type <= type_district_label_1e7) -#define item_is_poly_place(item) ((item).type >= type_poly_place && (item).type <= type_poly_place6) +#define item_is_poly_place(item) ((item).type >= type_poly_place1 && (item).type <= type_poly_place6) #define item_is_point(item) ((item).type < type_line) #define item_is_custom_poi(item) ((item).type >= type_poi_customg && (item).type < type_line) #define item_is_street(item) (((item).type >= type_street_nopass && (item).type <= type_roundabout) \ diff --git a/navit/maptool/maptool.c b/navit/maptool/maptool.c index b785d14f4..4594c4528 100644 --- a/navit/maptool/maptool.c +++ b/navit/maptool/maptool.c @@ -731,14 +731,18 @@ static void osm_process_multipolygons(struct maptool_params *p, char *suffix) { p->osm.multipolygons=tempfile(suffix,"multipolygons",0); if(!p->osm.multipolygons) return; - relations=tempfile(suffix,"relations", 1); + relations=tempfile(suffix,"multipolygons_out", 1); coords=fopen("coords.tmp", "rb"); ways_split=tempfile(suffix,"ways_split",0); ways_split_index=tempfile(suffix,"ways_split_index",0); process_multipolygons(p->osm.multipolygons,coords,ways_split,ways_split_index,relations); + fclose(ways_split_index); + fclose(ways_split); fclose(coords); fclose(relations); fclose(p->osm.multipolygons); + if(!p->keep_tmpfiles) + tempfile_unlink(suffix,"multipolygons"); } static void maptool_dump(struct maptool_params *p, char *suffix) { @@ -748,8 +752,10 @@ static void maptool_dump(struct maptool_params *p, char *suffix) { files[files_count++]="nodes"; if (p->process_ways) files[files_count++]="ways_split"; - if (p->process_relations) + if (p->process_relations) { files[files_count++]="relations"; + files[files_count++]="multipolygons_out"; + } for (i = 0 ; i < files_count ; i++) { FILE *f=tempfile(suffix,files[i],0); if (f) { @@ -833,6 +839,7 @@ static void maptool_assemble_map(struct maptool_params *p, char *suffix, char ** } if(!p->keep_tmpfiles) { tempfile_unlink(suffix,"relations"); + tempfile_unlink(suffix,"multipolygons_out"); tempfile_unlink(suffix,"nodes"); tempfile_unlink(suffix,"ways_split"); tempfile_unlink(suffix,"poly2poi_resolved"); @@ -1024,14 +1031,15 @@ int main(int argc, char **argv) { if (p.process_relations) { osm_process_turn_restrictions(&p, suffix); } - if(!p.keep_tmpfiles) - tempfile_unlink(suffix,"ways_split_index"); } if (start_phase(&p,"generating multipolygons")) { if(p.process_relations) { osm_process_multipolygons(&p, suffix); } } + if(!p.keep_tmpfiles) + tempfile_unlink(suffix,"ways_split_index"); + if (p.process_relations && p.process_ways && p.process_nodes && start_phase(&p,"processing associated street relations")) { struct files_relation_processing *files_relproc = files_relation_processing_new(p.osm.line2poi, suffix); @@ -1068,6 +1076,8 @@ int main(int argc, char **argv) { exit(0); } if (p.process_relations) { + filenames[filename_count]="multipolygons_out"; + referencenames[filename_count++]=NULL; filenames[filename_count]="relations"; referencenames[filename_count++]=NULL; filenames[filename_count]="towns_poly"; diff --git a/navit/maptool/misc.c b/navit/maptool/misc.c index 1c30b94f7..9b1c72da2 100644 --- a/navit/maptool/misc.c +++ b/navit/maptool/misc.c @@ -213,12 +213,20 @@ int item_order_by_type(enum item_type type) { return max; } +static inline int filter_unknown(struct item_bin * ib) { + if(ignore_unknown && (ib->type==type_point_unkn || ib->type==type_street_unkn || ib->type==type_none)) + return 1; + return 0; +} + static void phase34_process_file(struct tile_info *info, FILE *in, FILE *reference) { struct item_bin *ib; struct attr_bin *a; int max; while ((ib=read_item(in))) { + if(filter_unknown(ib)) + continue; if (ib->type < 0x80000000) processed_nodes++; else @@ -239,6 +247,8 @@ static void phase34_process_file_range(struct tile_info *info, FILE *in, FILE *r int min,max; while ((ib=read_item_range(in, &min, &max))) { + if(filter_unknown(ib)) + continue; if (ib->type < 0x80000000) processed_nodes++; else @@ -278,6 +288,8 @@ static int phase34(struct tile_info *info, struct zip_info *zip_info, FILE **in, void dump(FILE *in) { struct item_bin *ib; while ((ib=read_item(in))) { + if(filter_unknown(ib)) + continue; dump_itembin(ib); } } diff --git a/navit/maptool/osm.c b/navit/maptool/osm.c index 6eab6a903..fa5bde9b1 100644 --- a/navit/maptool/osm.c +++ b/navit/maptool/osm.c @@ -1615,27 +1615,28 @@ void osm_end_relation(struct maptool_osm *osm) { in_relation=0; - if(attr_longest_match(attr_mapping_rel2poly_place, attr_mapping_rel2poly_place_count, &type, 1)) { - tmp_item_bin->type=type; + fprintf(stderr,"relation_type=%s\n", relation_type); + if((!g_strcmp0(relation_type, "multipolygon")) && (!boundary)) { + if(attr_longest_match(attr_mapping_way, attr_mapping_way_count, &type, 1)) { + tmp_item_bin->type = type; + } else { + type=type_none; + tmp_item_bin->type=type; + } } else { - type=type_none; - tmp_item_bin->type=type; + if(attr_longest_match(attr_mapping_rel2poly_place, attr_mapping_rel2poly_place_count, &type, 1)) { + tmp_item_bin->type=type; + } else { + type=type_none; + tmp_item_bin->type=type; + } } - fprintf(stderr,"relation_type=%s\n", relation_type); if ((!g_strcmp0(relation_type, "multipolygon")) && (!boundary)) { item_bin_add_attr_string(tmp_item_bin, attr_label, attr_strings[attr_string_label]); item_bin_write(tmp_item_bin, osm->multipolygons); } - /*TODO: check if this was a bug: Previously attr_longest_match always failed, because - * item_is_poly_place never matched causing attr_mapping_rel2poly_place to be empty. - * Since I don't know what happenes if type suddenly is != type_none, I force the - * old behaviour here */ - type=type_none; - tmp_item_bin->type=type; - - if ((!g_strcmp0(relation_type, "multipolygon") || !g_strcmp0(relation_type, "boundary")) && (boundary || type!=type_none)) { item_bin_write(tmp_item_bin, osm->boundaries); @@ -1758,8 +1759,6 @@ void osm_end_way(struct maptool_osm *osm) { add_flags=0; if (types[i] == type_none) continue; - if (ignore_unknown && (types[i] == type_street_unkn || types[i] == type_point_unkn)) - continue; if (types[i] != type_street_unkn) { if(types[i]<type_area) count_lines++; @@ -1849,8 +1848,6 @@ void osm_end_node(struct maptool_osm *osm) { for (i = 0 ; i < count ; i++) { if (types[i] == type_none) continue; - if (ignore_unknown && (types[i] == type_street_unkn || types[i] == type_point_unkn)) - continue; item_bin=init_item(types[i]); if (item_is_town(*item_bin) && attr_strings[attr_string_population]) item_bin_set_type_by_population(item_bin, atoi(attr_strings[attr_string_population])); |