@@ -33,6 +33,26 @@ export function BusToolTip({ position, icon, children }: BusToolTipProps) {
33
33
. finally ( ( ) => setIsLoading ( false ) )
34
34
} , [ position ] )
35
35
36
+ function getDirectionFromAngle ( angle : number ) : string {
37
+ // Normalize the angle to the range 0-360
38
+ angle = ( ( angle % 360 ) + 360 ) % 360
39
+ // Define the cardinal directions in clockwise order
40
+ const directions : string [ ] = [
41
+ t ( 'directions.North' , { defaultValue : 'North' } ) ,
42
+ t ( 'directions.Northeast' , { defaultValue : 'Northeast' } ) ,
43
+ t ( 'directions.East' , { defaultValue : 'East' } ) ,
44
+ t ( 'directions.Southeast' , { defaultValue : 'Southeast' } ) ,
45
+ t ( 'directions.South' , { defaultValue : 'South' } ) ,
46
+ t ( 'directions.Southwest' , { defaultValue : 'Southwest' } ) ,
47
+ t ( 'directions.West' , { defaultValue : 'West' } ) ,
48
+ t ( 'directions.Northwest' , { defaultValue : 'Northwest' } ) ,
49
+ ]
50
+ // Divide the angle into 8 equal sections (45 degrees each)
51
+ const index : number = Math . round ( angle / 45 ) % 8
52
+
53
+ return directions [ index ]
54
+ }
55
+
36
56
return (
37
57
< div className = { cn ( 'bus-tooltip' , { hebrew : i18n . language === 'he' } ) } >
38
58
{ isLoading || ! siriRide ? (
@@ -56,6 +76,7 @@ export function BusToolTip({ position, icon, children }: BusToolTipProps) {
56
76
< div className = "content" >
57
77
< ul >
58
78
< li >
79
+ { ' ' }
59
80
{ `${ t ( 'from' ) } : ` }
60
81
< span > { siriRide . gtfsRouteRouteLongName ?. split ( '<->' ) [ 0 ] } </ span >
61
82
</ li >
@@ -83,7 +104,12 @@ export function BusToolTip({ position, icon, children }: BusToolTipProps) {
83
104
< li >
84
105
{ `${ t ( 'drive_direction' ) } : ` }
85
106
< span >
86
- ({ position . point ?. bearing } { t ( 'bearing' ) } )
107
+ { /* ({position.point?.bearing} {t('bearing')}) */ }
108
+ { position . point ?. bearing } { t ( 'bearing' ) } (
109
+ { position . point ?. bearing !== undefined
110
+ ? getDirectionFromAngle ( position . point . bearing )
111
+ : t ( 'unknown' , { defaultValue : 'unknown' } ) }
112
+ )
87
113
</ span >
88
114
</ li >
89
115
< li >
0 commit comments