34 int32_t
getIndexByAngle(int32_t angle,
const type_angle2id& angle2id, int32_t& closestMatchingAngle) {
35 int32_t wangle = (360 + angle) % 360;
37 if (angle2id.size() == 0) {
40 if (angle2id.size() == 1) {
41 closestMatchingAngle = angle2id.begin()->first;
42 return angle2id.begin()->second;
45 type_angle2id::const_iterator u(angle2id.upper_bound(wangle));
46 type_angle2id::const_iterator tmp;
49 if (u == angle2id.end()) {
50 int32_t ud = wangle - (--u)->first;
51 int32_t ld = 360 - wangle + angle2id.begin()->first;
54 closestMatchingAngle = angle2id.begin()->first;
55 return angle2id.begin()->second;
58 closestMatchingAngle = u->first;
63 if (u == angle2id.begin()) {
66 int32_t ld = u->first - wangle;
67 int32_t ud = 360 - tmp->first + wangle;
70 closestMatchingAngle = angle2id.begin()->first;
71 return angle2id.begin()->second;
74 closestMatchingAngle = tmp->first;
79 int32_t ud = u->first - wangle;
80 int32_t ucm = u->first;
81 int32_t ui = u->second;
83 int32_t ld = wangle - u->first;
84 int32_t lcm = u->first;
85 int32_t li = u->second;
88 closestMatchingAngle = ucm;
91 closestMatchingAngle = lcm;