diff --git a/sample_data/belgium_by_region_since_1995/belgium_population_by_region_2022.csv b/sample_data/belgium_by_region_since_1995/belgium_population_by_region_2022.csv index bb275034..5b876339 100644 --- a/sample_data/belgium_by_region_since_1995/belgium_population_by_region_2022.csv +++ b/sample_data/belgium_by_region_since_1995/belgium_population_by_region_2022.csv @@ -1,4 +1,4 @@ shapeName,Population (people),Color,Inset,Label -Brussels-Capital,1222637,#fbb4ae,, -Flanders,6698876,#b3cde3,, +Brussels-Capital,1222637,,, +Flanders,6698876,,, Wallonia,3662495,#ccebc5,, diff --git a/src/cartogram_info/cartogram_info.cpp b/src/cartogram_info/cartogram_info.cpp index 08762d12..c95c11ff 100644 --- a/src/cartogram_info/cartogram_info.cpp +++ b/src/cartogram_info/cartogram_info.cpp @@ -448,7 +448,12 @@ void CartogramInfo::write_svg(const std::string &suffix) for (const InsetState &inset_state : inset_states_) { inset_names += inset_state.pos(); } - insets_combined.write_map( - map_name_ + "_" + inset_names + "_" + suffix, - false); + // Only attach inset names to filename if there's more than one inset + if (n_insets() > 1) { + insets_combined.write_map( + map_name_ + "_" + inset_names + "_" + suffix, + false); + } else { + insets_combined.write_map(map_name_ + "_" + suffix, false); + } } \ No newline at end of file diff --git a/src/inset_state/auto_color.cpp b/src/inset_state/auto_color.cpp index 6a9558d5..87ec5e64 100644 --- a/src/inset_state/auto_color.cpp +++ b/src/inset_state/auto_color.cpp @@ -11,18 +11,12 @@ void InsetState::auto_color() std::vector palette; if (colors_.size() > 0) { - // If some colors are already provided, use a different palette - // From https://colorbrewer2.org/#type=qualitative&scheme=Dark2&n=8 - std::cerr << "Some but not all colors provided, using Dark color palette." + // If some but not all of the GeoDivs are colored, use only #f2f2f2 (light + // gray) to color the rest + std::cerr << "Some but not all colors provided, assigning #f2f2f2 (light " + "gray) to uncolored GeoDivs." << std::endl; - palette.emplace_back("#1b9e77"); // aqua green - palette.emplace_back("#d95f02"); // dark orange - palette.emplace_back("#7570b3"); // purple - palette.emplace_back("#e7298a"); // dark pink - palette.emplace_back("#66a61e"); // olive green - palette.emplace_back("#e6ab02"); // dark yellow - palette.emplace_back("#a6761d"); // brown - palette.emplace_back("#666666"); // dark grey + palette.emplace_back("#f2f2f2"); // light gray } else { // Using default palette for now // TODO: Accept palette from user @@ -48,6 +42,13 @@ void InsetState::auto_color() if (color_found(gd.id())) continue; + // If there's only one color in palette, color the div with it without + // checking for color adjacency + if (palette.size() == 1) { + insert_color(gd.id(), palette[0]); + continue; + } + for (unsigned int i = 0; i < palette.size(); ++i) { const Color c = palette[i]; bool shared_color = false;