MCPcopy Create free account
hub / github.com/comaps/comaps / MapGarminColor

Function MapGarminColor

libs/kml/color_parser.cpp:70–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68 {0xffffffff, "White"}});
69
70std::string_view MapGarminColor(uint32_t rgba)
71{
72 std::string_view closestColor = kRGBAToGarmin[0].color;
73 auto minDistance = std::numeric_limits<int>::max();
74 for (auto const & [rgbaGarmin, color] : kRGBAToGarmin)
75 {
76 auto const distance = ColorDistance(rgba, rgbaGarmin);
77
78 if (distance == 0)
79 return color; // Exact match.
80
81 if (distance < minDistance)
82 {
83 minDistance = distance;
84 closestColor = color;
85 }
86 }
87 return closestColor;
88}
89
90struct RGBAToPredefined
91{

Callers 2

SaveTrackDataFunction · 0.85
UNIT_TESTFunction · 0.85

Calls 1

ColorDistanceFunction · 0.85

Tested by 1

UNIT_TESTFunction · 0.68