Debian Codegraph @

src/uk/me/parabola/imgfmt/app/net/AngleChecker.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2015
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 or
6 * version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 */
13 package uk.me.parabola.imgfmt.app.net;
14
15 import java.util.ArrayList;
16 import java.util.Iterator;
17 import java.util.List;
18 import java.util.Map;
19
20 import uk.me.parabola.log.Logger;
21 import uk.me.parabola.util.EnhancedProperties;
22 import uk.me.parabola.mkgmap.reader.osm.FakeIdGenerator;
23
24 /**
25 * Find sharp angles at junctions. The Garmin routing algorithm doesn't
26 * like to route on roads building a sharp angle. It adds a time penalty
27 * from 30 to 150 seconds and often prefers small detours instead.
28 * The penalty depends on the road speed and the vehicle, for pedestrian
29 * mode it is zero, for bicycles it is rather small, for cars it is high.
30 * The sharp angles typically don't exist in the real world, they are
31 * caused by the simplifications done by mappers.
32 *
33 * Maps created for cyclists typically "abuse" the car routing for racing
34 * bikes, but in this scenario the time penalties are much too high,
35 * and detours are likely.
36 *
37 * This method tries to modify the initial heading values of the arcs
38 * which are used to calculate the angles. Where possible, the values are
39 * changed so that angles appear larger.
40 *
41 * @author Gerd Petermann
42 *
43 * Somehow these penalties are also applied to "shortest" routing,
44 * often resulting in something that is definitely not the shortest
45 * route.
46 *
47 * Possibly a more significant problem is the very low cost Garmin
48 * gives to a minor road crossing a more major road - much less than
49 * the "against driving-side" turn onto the major road. If there is a
50 * small block/triangle of roads on the other side, the routing
51 * algorithm might prefer crossing the major road then multiple
52 * driving-side turns rather than the correct single turn.
53 *
54 * I haven't found a way of preventing this.
55 *
56 * Ticker Berkin
57 *
58 * This code has two other functions:
59 *
60 * When increasing a sharp angle, try to trigger better turn-instructions by the
61 * choice of which arcs to adjust.
62 *
63 * Use compactDir format (4bits) rather than 8bits for initial heading representaton
64 * when this will give a space saving and not compromise the turn-instructions.
65 */
66 public class AngleChecker {
67 private static final Logger log = Logger.getLogger(AngleChecker.class);
68
69 private boolean ignoreSharpAngles;
70 private boolean cycleMap;
71
72 // Generally it is safe to use compactDirs when there are no arcs in consecutive
73 // 22.5 degree sectors and this is guaranteed if the minumum angle is >= 45 degrees.
74 private static final float COMPACT_DIR_DEGREES = 45+1; // +bit for 360>256 conversion rounding
75 // If this is >= above, then compactDirs will be used unless other, non-vehicle access angles are sharp
76 private static final float SHARP_DEGREES = COMPACT_DIR_DEGREES;
77 // Experimentation found no benefit in increasing angle beyond 2 "sectors"
78 private static final float MIN_ANGLE = 23f; // don't reduce angles to less than this (1 sector + bit)
79 private static final float STRAIGHT_EPSILON = 3f; // for angle.straightEnough()
80
81 // helper class to collect multiple arcs with (nearly) the same initial headings
82 private class ArcGroup {
83 float initialHeading;
84 int isOneWayTrueCount;
85 int isForwardTrueCount;
86 int maxRoadSpeed;
87 int maxRoadClass;
88 byte orAccessMask;
89 List<RouteArc> arcs = new ArrayList<>();
90
91 public void addArc(RouteArc arc) {
92 arcs.add(arc);
93 if (arc.getRoadDef().isOneway())
94 isOneWayTrueCount++;
95 if (arc.isForward())
96 isForwardTrueCount++;
97 if (arc.getRoadDef().getRoadSpeed() > maxRoadSpeed)
98 maxRoadSpeed = arc.getRoadDef().getRoadSpeed();
99 if (arc.getRoadDef().getRoadClass() > maxRoadClass)
100 maxRoadClass = arc.getRoadDef().getRoadClass();
101 orAccessMask |= arc.getRoadDef().getAccess();
102 }
103
104 public float getInitialHeading() {
105 return initialHeading;
106 }
107
108 public boolean isOneway() {
109 // ??? ignore for pedestrian only group members
110 return isOneWayTrueCount == arcs.size();
111 }
112
113 public boolean isForward() {
114 return isForwardTrueCount == arcs.size();
115 }
116
117 public boolean sameWay(ArcGroup other) {
118 for (RouteArc thisArc : arcs)
119 for (RouteArc otherArc : other.arcs) {
120 // same roadDefs have same wayIds. WayIds are unique, so this is OK
121 if (thisArc.getRoadDef() == otherArc.getRoadDef())
122 return true;
123 }
124 return false;
125 }
126
127 public boolean sameName(ArcGroup other) {
128 for (RouteArc thisArc : arcs) {
129 String thisName = thisArc.getRoadDef().getName();
130 // RoadDefs also have 4 labels, but not bothering to check them
131 if (thisName != null)
132 for (RouteArc otherArc : other.arcs)
133 if (thisName.equals(otherArc.getRoadDef().getName()))
134 return true;
135 }
136 return false;
137 }
138
139 public void modInitialHeading(float modIH) {
140 initialHeading += modIH;
141 if (initialHeading >= 180)
142 initialHeading -= 360;
143 else if (initialHeading < -180)
144 initialHeading += 360;
145 log.info("modInitialHeading arc from", arcs.get(0).getInitialHeading(), "by", modIH, "to", initialHeading);
146
147 for (RouteArc arc : arcs) {
148 arc.modInitialHeading(modIH);
149 }
150 }
151
152 public String toString() {
153 return arcs.get(0).toString();
154 }
155 }
156
157 public void config(EnhancedProperties props) {
158 // undocumented option - usually used for debugging only
159 ignoreSharpAngles = props.getProperty("ignore-sharp-angles", false);
160 cycleMap = props.getProperty("cycle-map", false);
161 }
162
163 public void check(Map<Integer, RouteNode> nodes) {
164 if (!ignoreSharpAngles){
165 /*
166 I don't understand the original setting and logic for sharpAnglesCheckMask.
167
168 If it is a cycle-map, sharpAnglesCheckMask is set to all but ACCESS...FOOT,
169 so that, if the common access of the arcs is FOOT only, the sharp angle won't
170 be increased as if for vehicles, but there is logic to do this anyway.
171
172 If not a cycle-map, it was set to ACCESS...BIKE,
173 so that, if BIKE access isn't common to both arcs, the sharp angle won't
174 be increased, so motor vehicles, allowed to turn here, might suffer
175 a time penalty.
176
177 I've left the cycle-map value untouched but changed the other value so that
178 angle expansion is handled as normal
179
180 Ticker Berkin 23-Aug-2024
181
182 byte sharpAnglesCheckMask = cycleMap ? (byte) (0xff & ~AccessTagsAndBits.FOOT) : AccessTagsAndBits.BIKE;
183 */
184 byte sharpAnglesCheckMask = cycleMap ? (byte) (0xff & ~AccessTagsAndBits.FOOT) : (byte) 0xff;
185 for (RouteNode node : nodes.values()){
186 fixSharpAngles(node, sharpAnglesCheckMask);
187 }
188 }
189 }
190
191 public void fixSharpAngles(RouteNode node, byte sharpAnglesCheckMask) {
192
193 List<RouteArc> arcs = node.getArcs();
194 if (arcs.size() <= 1) // nothing to do - maybe an edge. Will use 8bit dirs if there is an arc
195 return;
196 // RouteNode default is setUseCompactDirs(false);
197 node.setUseCompactDirs(true); // assume algo will do enough to make this OK
198 if (arcs.size() == 2) { // common case where two roads join but isn't a junction
199 doSimpleJoin(node, arcs);
200 return;
201 }
202
203 // Combine arcs with nearly the same initial heading.
204
205 // first get direct arcs leaving the node
206 List<RouteArc> directArcs = new ArrayList<>();
207 for (RouteArc arc : arcs) {
208 if (arc.isDirect())
209 directArcs.add(arc);
210 else
211 // AngleChecker runs before addArcsToMajorRoads so there shouldn't be any indirect arcs yet.
212 // If this changes, extra care needs to be taken check they are positioned correctly in the list
213 // of arcs or that their heading is kept consistent with changes to their direct base arc.
214 log.warn("Unexpected indirect arc", arc, "from", node);
215 }
216 if (directArcs.size() <= 1)
217 return; // should not happen
218
219 // sort the arcs by initial heading
220 directArcs.sort((ra1,ra2) -> {
221 int d = Float.compare(ra1.getInitialHeading(), ra2.getInitialHeading());
222 if (d != 0)
223 return d;
224 d = Integer.compare(ra1.getPointsHash(), ra2.getPointsHash());
225 if (d != 0)
226 return d;
227 return Long.compare(ra1.getRoadDef().getId() , ra2.getRoadDef().getId());
228 });
229
230 // now combine into groups
231 // also calculate minimum angle between arcs for quick decision if more needs to be done
232 List<ArcGroup> arcGroups = new ArrayList<>();
233 Iterator<RouteArc> iter = directArcs.listIterator();
234 RouteArc arc1 = iter.next();
235 boolean addArc1 = false;
236 float smallestAngle = 180;
237 while (iter.hasNext() || addArc1) {
238 ArcGroup ag = new ArcGroup();
239 ag.initialHeading = arc1.getInitialHeading();
240 ag.addArc(arc1);
241 arcGroups.add(ag);
242 addArc1 = false;
243 while (iter.hasNext()) {
244 RouteArc arc2 = iter.next();
245 float angleBetween = arc2.getInitialHeading() - ag.initialHeading;
246 if (angleBetween < 1) {
247 if (arc1.getDest() != arc2.getDest() && arc1.getRoadDef().getId() != arc2.getRoadDef().getId())
248 log.warn("sharp angle < 1° at", node.getCoord(), ",maybe duplicated OSM way with bearing", getCompassBearing(arc1.getInitialHeading()));
249 ag.addArc(arc2);
250 } else {
251 if (angleBetween < smallestAngle)
252 smallestAngle = angleBetween;
253 arc1 = arc2;
254 if (!iter.hasNext())
255 addArc1 = true;
256 break;
257 }
258 }
259 }
260 // handle the last > first groups
261 int lastInx = arcGroups.size()-1;
262 if (lastInx > 0) {
263 float angleBetween = arcGroups.get(0).initialHeading - arcGroups.get(lastInx).initialHeading + 360;
264 if (angleBetween < 1) {
265 for (RouteArc arc : arcGroups.get(lastInx).arcs)
266 arcGroups.get(0).addArc(arc);
267 arcGroups.remove(lastInx);
268 } else if (angleBetween < smallestAngle) {
269 smallestAngle = angleBetween;
270 }
271 }
272
273 if (smallestAngle >= SHARP_DEGREES && arcGroups.size() == arcs.size()) // show diags if real groups
274 return;
275
276 if (log.isInfoEnabled()) {
277 log.info("fixSharpAngles at", node.getCoord(),
278 "mask", String.format("0x%02x", sharpAnglesCheckMask),
279 "nArcs", arcs.size(),
280 // "nDirectArcs", directArcs.size(), // already warned
281 arcGroups.size() < arcs.size() ? "nGroups " + arcGroups.size() : "",
282 "smallestAngle", smallestAngle);
283 float lastHeading = directArcs.get(directArcs.size()-1).getInitialHeading() - 360;
284 for (RouteArc arc : directArcs) {
285 RoadDef rd = arc.getRoadDef();
286 log.info("Arc", /*arc,*/
287 "heading", arc.getInitialHeading(), getCompassBearing(arc.getInitialHeading()),
288 "angToPrev", arc.getInitialHeading() - lastHeading,
289 "class", rd.getRoadClass(),
290 "speed", rd.getRoadSpeed(),
291 // "rdDef", System.identityHashCode(rd),
292 "way", rd.getId(), "isFake", FakeIdGenerator.isFakeId(rd.getId()),
293 "name", rd.getName(),
294 "access", String.format("0x%02x", rd.getAccess()),
295 "oneway", rd.isOneway(),
296 "forward", arc.isForward(),
297 "paved", rd.paved()
298 );
299 lastHeading = arc.getInitialHeading();
300 }
301 }
302
303 if (arcGroups.size() == 1) { // 1 set of close but possibly different headings, use 8bit dirs
304 node.setUseCompactDirs(false);
305 return;
306 } else if (smallestAngle >= SHARP_DEGREES)
307 return;
308
309 final int n = arcGroups.size();
310 // scan the angles and see what needs attention
311 // Note: This algorithm won't spot and fix a sharp angle where there is a 'no-access' arc between
312 // but, because no-access angles are widend (if possible) to 23 degrees, there should
313 // be 46 degrees between the two roads either side
314
315 class AngleAttr {
316 float angle;
317 float minAngle;
318
319 private boolean straightEnough() {
320 return angle > 180-STRAIGHT_EPSILON && angle < 180+STRAIGHT_EPSILON;
321 }
322
323 }
324
325 boolean someNeedIncrease = false;
326 AngleAttr[] angles = new AngleAttr[n];
327 for (int i = 0; i < n; i++){
328 ArcGroup ag1 = arcGroups.get(i);
329 ArcGroup ag2 = arcGroups.get(i+1 < n ? i+1 : 0);
330 AngleAttr aa = new AngleAttr();
331 angles[i] = aa;
332 aa.angle = ag2.getInitialHeading() - ag1.getInitialHeading();
333 if (i+1 >= n)
334 aa.angle += 360;
335
336 // int sumSpeeds = ag1.maxRoadSpeed + ag2.maxRoadSpeed;
337 // the Garmin algorithm sees rounded values, so the thresholds are probably
338 // near 22.5 (0x10), 45(0x20), 67.5 (0x30), 90, 112.5 (0x40)
339
340 // the following code doesn't seem to improve anything, I leave it as comment
341 // for further experiments.
342 // if (cycleMap){
343 // if (sumSpeeds >= 14)
344 // maskedMinAngle = 0x80;
345 // if (sumSpeeds >= 12)
346 // maskedMinAngle = 0x70;
347 // if (sumSpeeds >= 10)
348 // maskedMinAngle = 0x60;
349 // if (sumSpeeds >= 8)
350 // maskedMinAngle = 0x50;
351 // else if (sumSpeeds >= 6)
352 // maskedMinAngle = 0x40;
353 // else if (sumSpeeds >= 4)
354 // maskedMinAngle = 0x30;
355 // }
356 // With changes to switch compactDirs and working in degrees rather than masked sectors,
357 // the above variables are wrong, but the idea holds
358
359 aa.minAngle = MIN_ANGLE;
360 String minimalReason = null;
361 byte pathAccessMask = (byte) (ag1.orAccessMask & ag2.orAccessMask);
362 if (pathAccessMask == 0)
363 minimalReason = "no common vehicle allowed on both arcs";
364 else if (pathAccessMask == AccessTagsAndBits.FOOT)
365 minimalReason = "only pedestrians - sharp angle not a problem";
366 else if ((pathAccessMask & sharpAnglesCheckMask) == 0) // see comment in check(...) above
367 minimalReason = "because it can not be used by bike";
368 else if (Math.min(ag1.maxRoadSpeed, ag2.maxRoadSpeed) == 0)
369 minimalReason = "eg service/parking where sharp angle probably indicates shouldn't turn here";
370 else if (ag1.isOneway() && ag2.isOneway()) {
371 if (!ag1.isForward() && !ag2.isForward()) {
372 minimalReason = "two one-ways merge";
373 if (aa.angle < MIN_ANGLE)
374 aa.minAngle = aa.angle; // don't expand. compactDir format no problem
375 } else if (ag1.isForward() && ag2.isForward()) {
376 minimalReason = "two one-ways split";
377 if (aa.angle < MIN_ANGLE && n == 3 && ag1.maxRoadClass == ag2.maxRoadClass && ag1.sameName(ag2)) {
378 // maybe this is a major road split and don't want to encourage a turn-instruction
379 ArcGroup ag3 = arcGroups.get(i+2 < n ? i+2 : i+2-n);
380 if (ag3.isOneway() && ag3.maxRoadClass == ag1.maxRoadClass) {
381 minimalReason = "major road split";
382 aa.minAngle = aa.angle; // don't expand
383 node.setUseCompactDirs(false); // use 8bit dirs
384 }
385 }
386 } /* else if (n == 3) {
387 // both arcs are one-ways in opposite directions (ie continuous)
388 // could check that the one-way directions correspond to the driving side
389 minimalReason = "because it seems to be a flare road";
390 // it could also be a sharp turn, so best to let it expand. Flare angles
391 // are typically 30-45 degrees so expanding to SHARP_DEGREES won't be significant
392 } */
393 } /* else if (ag1.sameWay(ag2)) {
394 // I don't think this is a good reason to ignore the sharp angle
395 // however all the cases I've found are where there is a flair road with
396 // an extra track that stops the above test working
397 minimalReason = "because both arcs belong to the same road";
398 } */
399 if (minimalReason != null) {
400 if (log.isInfoEnabled()) {
401 log.info(aa.angle < aa.minAngle ? "minAngleSharp" : "minAngleOK", aa.angle,
402 "minAngle", aa.minAngle,
403 "reason", minimalReason);
404 }
405 } else
406 aa.minAngle = SHARP_DEGREES;
407 if (aa.angle < aa.minAngle)
408 someNeedIncrease = true;
409 }
410
411 if (!someNeedIncrease)
412 return;
413
414 // go through the angles again and try to increase any that are less than minAngle
415 for (int i = 0; i < n; i++){
416 AngleAttr aa = angles[i];
417 float wantedIncrement = aa.minAngle - aa.angle;
418 if (wantedIncrement <= 0)
419 continue;
420 float oldAngle = aa.angle;
421 ArcGroup ag1 = arcGroups.get(i);
422 ArcGroup ag2 = arcGroups.get(i+1 < n ? i+1 : 0);
423
424 // XXX restrictions ?
425 AngleAttr predAA = angles[i == 0 ? n - 1 : i - 1];
426 AngleAttr nextAA = angles[i >= n - 1 ? 0 : i + 1];
427
428 // we can increase the angle by changing the heading values of one or both arcs
429 // How much we can encroach on the adjacent angles
430 float deltaPred = predAA.angle - predAA.minAngle;
431 float deltaNext = nextAA.angle - nextAA.minAngle;
432
433 if (log.isInfoEnabled()) {
434 log.info("Angle", aa.angle,
435 "between", ag1.getInitialHeading(),
436 "and", ag2.getInitialHeading(),
437 "minAngle", aa.minAngle,
438 "wantedInc", wantedIncrement,
439 "deltaPred", deltaPred,
440 "deltaNext", deltaNext);
441 }
442
443 if (deltaNext > 0 && deltaPred > 0) { // can take from both
444 ArcGroup ag0 = null;
445 ArcGroup ag3 = null;
446 int chooseWhich = 0; // -ve to take from prev, +ve take from next
447 // To influence possible turn-instructions look at the information
448 // easily available to prefer altering one arc instead of both.
449 // If both are altered this can make turn-instructions even more likely
450 // to be wrong because the adjustment is in proportion to the space
451 // available.
452 // The order of {road_class, sameWay, straightness, roadName, road_speed}
453 // clauses can adjusted for priority.
454 // Hoping sameWay before road_class fixes more problems than it might cause
455
456 if (chooseWhich == 0) {
457 // if the two arcs either side of the sharp angle belong to the same
458 // way then change the arc on the other side
459 ag0 = arcGroups.get(i > 0 ? i-1 : n-1);
460 ag3 = n == 3 ? ag0 : arcGroups.get(i+2 < n ? i+2 : i+2-n);
461 if (ag2.sameWay(ag3))
462 chooseWhich = -1;
463 else if (ag1.sameWay(ag0))
464 chooseWhich = +1;
465 }
466 if (chooseWhich == 0)
467 // adjust the lower class road
468 chooseWhich = ag1.maxRoadClass - ag2.maxRoadClass;
469 if (chooseWhich == 0) {
470 // where there is a straight road with a sharp turn-off then just adjust the turn-off
471 if (nextAA.straightEnough())
472 chooseWhich = -1;
473 else if (predAA.straightEnough())
474 chooseWhich = +1;
475 }
476 if (chooseWhich == 0) {
477 // NB set ag0 & 3 if move this before sameWay()
478 // Way might have changed but could still be the same road by name or ref
479 // This is best after straightEnough.
480 if (ag2.sameName(ag3))
481 chooseWhich = -1;
482 else if (ag1.sameName(ag0))
483 chooseWhich = +1;
484 }
485 if (chooseWhich == 0)
486 // adjust the slower road
487 chooseWhich = ag1.maxRoadSpeed - ag2.maxRoadSpeed;
488
489 if (chooseWhich == 0 ) { // take from both in ratio to available
490 deltaNext = Math.min(deltaNext, wantedIncrement * deltaNext / (deltaNext + deltaPred));
491 deltaPred = Math.min(deltaPred, wantedIncrement - deltaNext);
492 } else if (chooseWhich > 0) { // take as much as poss from next
493 if (deltaNext >= wantedIncrement) {
494 deltaNext = wantedIncrement;
495 deltaPred = 0;
496 } else {
497 deltaPred = Math.min(deltaPred, wantedIncrement - deltaNext);
498 }
499 } else { // take as much as possible from pred
500 if (deltaPred >= wantedIncrement) {
501 deltaPred = wantedIncrement;
502 deltaNext = 0;
503 } else {
504 deltaNext = Math.min(deltaNext, wantedIncrement - deltaPred);
505 }
506 }
507 } else if (deltaNext > 0) {
508 if (deltaNext > wantedIncrement)
509 deltaNext = wantedIncrement;
510 } else {
511 if (deltaPred > wantedIncrement)
512 deltaPred = wantedIncrement;
513 }
514
515 if (deltaNext > 0) { // can take some from the following angle
516 log.info("increasing arc with heading", getCompassBearing(ag2.getInitialHeading()), "by", deltaNext);
517 ag2.modInitialHeading(deltaNext);
518 aa.angle += deltaNext;
519 nextAA.angle -= deltaNext;
520 wantedIncrement -= deltaNext;
521 }
522 if (deltaPred > 0) { // and some from the previous angle
523 log.info("decreasing arc with heading", getCompassBearing(ag1.getInitialHeading()), "by", deltaPred);
524 ag1.modInitialHeading(-deltaPred);
525 aa.angle += deltaPred;
526 predAA.angle -= deltaPred;
527 wantedIncrement -= deltaPred;
528 }
529
530 if (wantedIncrement > 0) {
531 node.setUseCompactDirs(false); // angle might be wide enough in 8bit dirs
532 if (aa.angle == oldAngle)
533 log.info("don't know how to fix it", wantedIncrement);
534 else
535 log.info("don't know how to enlarge it further", wantedIncrement);
536 }
537 }
538
539 }
540
541
542 /**
543 * Called when there are exactly 2 arcs on the routing node.
544 * This is a common case where a road changes speed/name/class.
545 * It just checks for the angle of the 2 roads and increases it if sharp to reduce any potential
546 * excessive cost for the section so it won't be avoided unneccessarily by routing decisions elsewhere.
547 * Could check that both arcs usable by vehicles and do nothing if not, but hardly worth the bother.
548 *
549 * @param node
550 * @param arcs
551 */
552 private static void doSimpleJoin(RouteNode node, List<RouteArc> arcs) {
553 RouteArc arc1 = arcs.get(0);
554 RouteArc arc2 = arcs.get(1);
555 float angle = arc1.getInitialHeading() - arc2.getInitialHeading();
556 float extra = 0; // signed amount where +ve increases arc1 & decreases arc2
557 if (angle > 360 - SHARP_DEGREES) // crosses -180
558 extra = 360 - angle - SHARP_DEGREES;
559 else if (angle < SHARP_DEGREES - 360) // ditto the other way
560 extra = SHARP_DEGREES - angle - 360;
561 else if (angle > 0) {
562 if (angle < SHARP_DEGREES)
563 extra = SHARP_DEGREES - angle;
564 } else if (angle < 0) {
565 if (angle > -SHARP_DEGREES)
566 extra = -angle - SHARP_DEGREES;
567 } // else angle == 0 and can't widen as don't know which way around to do it
568 if (extra != 0) {
569 if (log.isInfoEnabled())
570 log.info("join angle", angle, "° at", node.getCoord(), "increased by", extra);
571 arc1.modInitialHeading(+extra/2);
572 arc2.modInitialHeading(-extra/2);
573 }
574 }
575
576
577 /**
578 * for log messages
579 */
580 private static String getCompassBearing (float bearing){
581 float cb = (bearing + 360) % 360;
582 return Math.round(cb) + "°";
583 }
584
585 }