Check and clamp bearing range each time it's set (#248)
This commit is contained in:
parent
bf8f0745a6
commit
f6dbeba3d8
@ -90,7 +90,7 @@ public class MapPosition {
|
||||
}
|
||||
|
||||
public MapPosition setBearing(float bearing) {
|
||||
this.bearing = bearing;
|
||||
this.bearing = clampBearing(bearing);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -149,14 +149,17 @@ public class MapPosition {
|
||||
this.y = y;
|
||||
this.scale = scale;
|
||||
|
||||
this.bearing = clampBearing(bearing);
|
||||
this.tilt = tilt;
|
||||
this.zoomLevel = FastMath.log2((int) scale);
|
||||
}
|
||||
|
||||
private static float clampBearing(float bearing) {
|
||||
while (bearing > 180)
|
||||
bearing -= 360;
|
||||
while (bearing < -180)
|
||||
bearing += 360;
|
||||
this.bearing = bearing;
|
||||
|
||||
this.tilt = tilt;
|
||||
this.zoomLevel = FastMath.log2((int) scale);
|
||||
return bearing;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user