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

Function MapPredefinedColor

libs/kml/color_parser.cpp:106–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104auto const kRGBAToPredefined = buildRGBAToPredefined();
105
106PredefinedColor MapPredefinedColor(uint32_t rgba)
107{
108 auto closestColor = kRGBAToPredefined[0].predefinedColor;
109 auto minDistance = std::numeric_limits<int>::max();
110 for (auto const & [rgbaGarmin, color] : kRGBAToPredefined)
111 {
112 auto const distance = ColorDistance(rgba, rgbaGarmin);
113
114 if (distance == 0)
115 return color; // Exact match.
116
117 if (distance < minDistance)
118 {
119 minDistance = distance;
120 closestColor = color;
121 }
122 }
123 return closestColor;
124}
125
126// Garmin extensions spec: https://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd
127// Color mapping: https://help.locusmap.eu/topic/extend-garmin-gpx-compatibilty

Callers 1

MakeValidMethod · 0.85

Calls 1

ColorDistanceFunction · 0.85

Tested by

no test coverage detected