@@ -44,6 +44,8 @@ public class BikeFlagEncoder extends AbstractFlagEncoder
44
44
private HashSet <String > wheeler = new HashSet <String >();
45
45
private HashSet <String > intended = new HashSet <String >();
46
46
private HashSet <String > oppositeLanes = new HashSet <String >();
47
+
48
+ private int maxcyclespeed = 30 ;
47
49
48
50
/**
49
51
* Should be only instantied via EncodingManager
@@ -95,8 +97,9 @@ public int defineBits( int index, int shift )
95
97
{
96
98
// first two bits are reserved for route handling in superclass
97
99
shift = super .defineBits (index , shift );
100
+ maxcyclespeed =relationWeightCodeToSpeed (20 , relationMapCode .OUTSTANDING_NICE .getValue ());
98
101
99
- speedEncoder = new EncodedValue ("Speed" , shift , 4 , 2 , HIGHWAY_SPEED .get ("cycleway" ), relationWeightCodeToSpeed ( 20 , relationMapCode . OUTSTANDING_NICE . getValue ()) );
102
+ speedEncoder = new EncodedValue ("Speed" , shift , 4 , 2 , HIGHWAY_SPEED .get ("cycleway" ), maxcyclespeed );
100
103
101
104
shift += 4 ;
102
105
@@ -206,7 +209,14 @@ private int relationWeightCodeToSpeed(int highwayspeed, int relationweightcode)
206
209
else
207
210
speed =highwayspeed ;
208
211
// Add or remove 3km/h per every relation weight boost point
209
- return speed + 3 * (relationweightcode -unspecifiedRelationWeight );
212
+ speed = speed + 3 * (relationweightcode -unspecifiedRelationWeight );
213
+ // Make sure that we do not eceed the limits:
214
+ if (speed > maxcyclespeed )
215
+ speed = maxcyclespeed ;
216
+ else
217
+ if (speed <0 )
218
+ speed = 0 ;
219
+ return speed ;
210
220
}
211
221
212
222
@ Override
0 commit comments