diff --git a/xml_converter/src/packaging_protobin.cpp b/xml_converter/src/packaging_protobin.cpp index bd3a38d6..45033a01 100644 --- a/xml_converter/src/packaging_protobin.cpp +++ b/xml_converter/src/packaging_protobin.cpp @@ -148,14 +148,7 @@ MaybeCategory build_category_objects( return return_value; } -void write_protobuf_file( - const string &filepath, - const StringHierarchy &category_filter, - const map* marker_categories, - const vector* parsed_pois -) { - // TODO: call _write_protobuf_file -} + void _write_protobuf_file( const string &filepath, @@ -189,6 +182,37 @@ void _write_protobuf_file( outfile.close(); } +void write_protobuf_file( + const string &filepath, + const StringHierarchy &category_filter, + const map* marker_categories, + const vector* parsed_pois +) { + std::map> category_to_pois; + + for (size_t i = 0; i < parsed_pois->size(); i++) { + Parseable* parsed_poi = (*parsed_pois)[i]; + if (parsed_poi->classname() == "POI") { + Icon* icon = dynamic_cast(parsed_poi); + category_to_pois[icon->category.category].push_back(parsed_poi); + } + else if (parsed_poi->classname() == "Trail") { + Trail* trail = dynamic_cast(parsed_poi); + category_to_pois[trail->category.category].push_back(parsed_poi); + } + else { + std::cout << "Unknown type" << std::endl; + } + } + + _write_protobuf_file( + filepath, + category_filter, + marker_categories, + category_to_pois + ); +} + // Write protobuf per map id void write_protobuf_file_per_map_id( const string &proto_directory,