@@ -75,7 +75,7 @@ public List<VoiceHint> process(List<VoiceHint> inputs) {
7575
7676 float turnAngle = input .goodWay .turnangle ;
7777 if (hintIdx != 0 ) distance += input .goodWay .linkdist ;
78- // System.out.println("range " + distance);
78+
7979 int currentPrio = input .goodWay .getPrio ();
8080 int oldPrio = input .oldWay .getPrio ();
8181 int minPrio = Math .min (oldPrio , currentPrio );
@@ -102,6 +102,7 @@ public List<VoiceHint> process(List<VoiceHint> inputs) {
102102 if (!badWay .isBadOneway () &&
103103 badWay .isGoodForCars ()) {
104104 isExit = true ;
105+ break ;
105106 }
106107 }
107108 }
@@ -111,8 +112,6 @@ public List<VoiceHint> process(List<VoiceHint> inputs) {
111112 continue ;
112113 }
113114 if (roundaboutExit > 0 ) {
114- //roundAboutTurnAngle += sumNonConsumedWithinCatchingRange(inputs, hintIdx);
115- //double startTurn = (roundaboudStartIdx != -1 ? inputs.get(roundaboudStartIdx + 1).goodWay.turnangle : turnAngle);
116115 input .angle = roundAboutTurnAngle ;
117116 input .goodWay .turnangle = roundAboutTurnAngle ;
118117 input .distanceToNext = distance ;
@@ -147,6 +146,9 @@ public List<VoiceHint> process(List<VoiceHint> inputs) {
147146 roundaboudStartIdx = -1 ;
148147 continue ;
149148 }
149+
150+ VoiceHint inputNext = hintIdx +1 < inputs .size () ? inputs .get (hintIdx +1 ) : null ;
151+
150152 int maxPrioAll = -1 ; // max prio of all detours
151153 int maxPrioCandidates = -1 ; // max prio of real candidates
152154
@@ -170,26 +172,26 @@ public List<VoiceHint> process(List<VoiceHint> inputs) {
170172 input .maxBadPrio = Math .max (input .maxBadPrio , badPrio );
171173 }
172174
175+ if (badWay .costfactor < 20.f && Math .abs (badTurn ) < minAbsAngeRaw ) {
176+ minAbsAngeRaw = Math .abs (badTurn );
177+ }
178+
173179 if (badPrio < minPrio ) {
174180 continue ; // ignore low prio ways
175181 }
176182
177183 if (badWay .isBadOneway ()) {
178184 if (minAbsAngeRaw == 180f )
179- minAbsAngeRaw = turnAngle ; // disable hasSomethingMoreStraight
185+ minAbsAngeRaw = Math . abs ( turnAngle ) ; // disable hasSomethingMoreStraight
180186 continue ; // ignore wrong oneways
181187 }
182188
183189 if (Math .abs (badTurn ) - Math .abs (turnAngle ) > 80.f ) {
184190 if (minAbsAngeRaw == 180f )
185- minAbsAngeRaw = turnAngle ; // disable hasSomethingMoreStraight
191+ minAbsAngeRaw = Math . abs ( turnAngle ) ; // disable hasSomethingMoreStraight
186192 continue ; // ways from the back should not trigger a slight turn
187193 }
188194
189- if (badWay .costfactor < 20.f && Math .abs (badTurn ) < minAbsAngeRaw ) {
190- minAbsAngeRaw = Math .abs (badTurn );
191- }
192-
193195 if (badPrio > maxPrioCandidates ) {
194196 maxPrioCandidates = badPrio ;
195197 input .maxBadPrio = Math .max (input .maxBadPrio , badPrio );
@@ -203,18 +205,53 @@ public List<VoiceHint> process(List<VoiceHint> inputs) {
203205 }
204206 }
205207
206- // boolean hasSomethingMoreStraight = (Math.abs(turnAngle) - minAbsAngeRaw) > 20.;
207- boolean hasSomethingMoreStraight = (Math .abs (turnAngle ) - minAbsAngeRaw ) > 20. && input .badWays != null ; // && !ignoreBadway;
208+ // has a significant angle and one or more bad ways around
209+ // https://brouter.de/brouter-test/#map=17/53.07509/-0.95780/standard&lonlats=-0.95757,53.073428;-0.95727,53.076064&profile=car-eco
210+ boolean hasSomethingMoreStraight = (Math .abs (turnAngle ) > 35f ) && input .badWays != null ;
211+
212+ // bad way has more prio, but is not a link
213+ //
214+ boolean noLinkButBadWayPrio = (maxPrioAll > minPrio && !isLink2Highway );
215+
216+ // bad way has more prio
217+ //
218+ boolean badWayHasPrio = (maxPrioCandidates > currentPrio );
219+
220+ // is a u-turn - same way back
221+ // https://brouter.de/brouter-test/#map=16/51.0608/13.7707/standard&lonlats=13.7658,51.060989;13.767893,51.061628;13.765273,51.062953&pois=13.76739,51.061609,Biergarten2956
222+ boolean isUTurn = VoiceHint .is180DegAngle (turnAngle );
223+
224+ // way has prio, but also has an angle
225+ // https://brouter.de/brouter-test/#map=15/47.7925/16.2582/standard&lonlats=16.24952,47.785458;16.269679,47.794653&profile=car-eco
226+ boolean isBadWayLinkButNoLink = (!isHighway2Link && isBadwayLink && Math .abs (turnAngle ) > 5.f );
227+
228+ //
229+ // https://brouter.de/brouter-test/#map=14/47.7927/16.2848/standard&lonlats=16.267617,47.795275;16.286438,47.787354&profile=car-eco
230+ boolean isLinkButNoBadWayLink = (isHighway2Link && !isBadwayLink && Math .abs (turnAngle ) < 5.f );
231+
232+ // way has same prio, but bad way has smaller angle
233+ // small: https://brouter.de/brouter-test/#map=17/49.40750/8.69257/standard&lonlats=8.692461,49.407997;8.694028,49.408478&profile=car-eco
234+ // high: https://brouter.de/brouter-test/#map=14/52.9951/-0.5786/standard&lonlats=-0.59261,52.991576;-0.583606,52.998947&profile=car-eco
235+ boolean samePrioSmallBadAngle = (currentPrio == oldPrio ) && minAbsAngeRaw != 180f && minAbsAngeRaw < 35f ;
236+
237+ // way has prio, but has to give way
238+ // https://brouter.de/brouter-test/#map=15/54.1344/-4.6015/standard&lonlats=-4.605432,54.136747;-4.609336,54.130058&profile=car-eco
239+ boolean mustGiveWay = transportMode != VoiceHintList .TRANS_MODE_FOOT &&
240+ input .badWays != null &&
241+ !badWayHasPrio &&
242+ (input .hasGiveWay () || (inputNext != null && inputNext .hasGiveWay ()));
208243
209244 // unconditional triggers are all junctions with
210245 // - higher detour prios than the minimum route prio (except link->highway junctions)
211246 // - or candidate detours with higher prio then the route exit leg
212247 boolean unconditionalTrigger = hasSomethingMoreStraight ||
213- (maxPrioAll > minPrio && !isLink2Highway ) ||
214- (maxPrioCandidates > currentPrio ) ||
215- VoiceHint .is180DegAngle (turnAngle ) ||
216- (!isHighway2Link && isBadwayLink && Math .abs (turnAngle ) > 5.f ) ||
217- (isHighway2Link && !isBadwayLink && Math .abs (turnAngle ) < 5.f );
248+ noLinkButBadWayPrio ||
249+ badWayHasPrio ||
250+ isUTurn ||
251+ isBadWayLinkButNoLink ||
252+ isLinkButNoBadWayLink ||
253+ samePrioSmallBadAngle ||
254+ mustGiveWay ;
218255
219256 // conditional triggers (=real turning angle required) are junctions
220257 // with candidate detours equal in priority than the route exit leg
@@ -293,7 +330,6 @@ public List<VoiceHint> process(List<VoiceHint> inputs) {
293330
294331 public List <VoiceHint > postProcess (List <VoiceHint > inputs , double catchingRange , double minRange ) {
295332 List <VoiceHint > results = new ArrayList <>();
296- double distance = 0 ;
297333 VoiceHint inputLast = null ;
298334 VoiceHint inputLastSaved = null ;
299335 for (int hintIdx = 0 ; hintIdx < inputs .size (); hintIdx ++) {
@@ -315,13 +351,7 @@ public List<VoiceHint> postProcess(List<VoiceHint> inputs, double catchingRange,
315351 input .cmd == VoiceHint .KR ||
316352 input .cmd == VoiceHint .KL )
317353 && !input .goodWay .isLinktType ()) {
318- if (
319- ((Math .abs (input .lowerBadWayAngle ) < 35.f ||
320- input .higherBadWayAngle < 35.f )
321- || input .goodWay .getPrio () < input .maxBadPrio )
322- && (inputLastSaved != null && inputLastSaved .distanceToNext > minRange )
323- && (input .distanceToNext > minRange )
324- ) {
354+ if (checkStraightHold (input , inputLastSaved , minRange )) {
325355 results .add (input );
326356 } else {
327357 if (inputLast != null ) { // when drop add distance to last
@@ -338,11 +368,7 @@ public List<VoiceHint> postProcess(List<VoiceHint> inputs, double catchingRange,
338368 input .cmd == VoiceHint .KR ||
339369 input .cmd == VoiceHint .KL )
340370 && !input .goodWay .isLinktType ()) {
341- if (((Math .abs (input .lowerBadWayAngle ) < 35.f ||
342- input .higherBadWayAngle < 35.f )
343- || input .goodWay .getPrio () < input .maxBadPrio )
344- && (inputLastSaved != null && inputLastSaved .distanceToNext > minRange )
345- && (input .distanceToNext > minRange )) {
371+ if (checkStraightHold (input , inputLastSaved , minRange )) {
346372 // add only on prio
347373 results .add (input );
348374 inputLastSaved = input ;
@@ -381,7 +407,6 @@ public List<VoiceHint> postProcess(List<VoiceHint> inputs, double catchingRange,
381407 } else if (input .distanceToNext < catchingRange ) {
382408 double dist = input .distanceToNext ;
383409 float angles = input .angle ;
384- int i = 1 ;
385410 boolean save = false ;
386411
387412 dist += nextInput .distanceToNext ;
@@ -444,9 +469,8 @@ public List<VoiceHint> postProcess(List<VoiceHint> inputs, double catchingRange,
444469 // save = true;
445470 } else {
446471 // otherwise ignore but add distance to next
447- if (nextInput != null ) { // when drop add distance to last
448- nextInput .distanceToNext += input .distanceToNext ;
449- }
472+ // when drop add distance to last
473+ nextInput .distanceToNext += input .distanceToNext ;
450474 save = false ;
451475 }
452476
@@ -478,5 +502,17 @@ boolean checkForNextNoneMotorway(List<VoiceHint> inputs, int offset, int testsiz
478502 return false ;
479503 }
480504
505+ boolean checkStraightHold (VoiceHint input , VoiceHint inputLastSaved , double minRange ) {
506+ if (input .indexInTrack == 0 ) return false ;
507+
508+ return
509+ ((Math .abs (input .lowerBadWayAngle ) < 35.f || input .higherBadWayAngle < 35.f )
510+ || input .goodWay .getPrio () < input .maxBadPrio
511+ || input .goodWay .getPrio () > input .oldWay .getPrio ())
512+ && (inputLastSaved == null || inputLastSaved .distanceToNext > minRange )
513+ && (input .distanceToNext > minRange )
514+ ;
515+ }
516+
481517
482518}
0 commit comments