Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: represent bearing as geographic terms #1009

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/pages/components/map-related/MapLayers/BusToolTip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@
.finally(() => setIsLoading(false))
}, [position])

function getDirectionFromAngle(angle: number): string {
// Normalize the angle to the range 0-360
angle = ((angle % 360) + 360) % 360;

Check failure on line 38 in src/pages/components/map-related/MapLayers/BusToolTip.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`

Check failure on line 39 in src/pages/components/map-related/MapLayers/BusToolTip.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `··`
// Define the cardinal directions in clockwise order
const directions: string[] = [
"North", "Northeast", "East", "Southeast",

Check failure on line 42 in src/pages/components/map-related/MapLayers/BusToolTip.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Replace `"North",·"Northeast",·"East",·"Southeast"` with `'North',⏎······'Northeast',⏎······'East',⏎······'Southeast'`
"South", "Southwest", "West", "Northwest"

Check failure on line 43 in src/pages/components/map-related/MapLayers/BusToolTip.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Replace `"South",·"Southwest",·"West",·"Northwest"` with `'South',⏎······'Southwest',⏎······'West',⏎······'Northwest',`
];

Check failure on line 44 in src/pages/components/map-related/MapLayers/BusToolTip.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`

Check failure on line 45 in src/pages/components/map-related/MapLayers/BusToolTip.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `··`
// Divide the angle into 8 equal sections (45 degrees each)
const index: number = Math.round(angle / 45) % 8;

Check failure on line 47 in src/pages/components/map-related/MapLayers/BusToolTip.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`

Check failure on line 48 in src/pages/components/map-related/MapLayers/BusToolTip.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `··`
return directions[index];

Check failure on line 49 in src/pages/components/map-related/MapLayers/BusToolTip.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `;`
}

Check failure on line 50 in src/pages/components/map-related/MapLayers/BusToolTip.tsx

View workflow job for this annotation

GitHub Actions / local-tests

Delete `·⏎`


return (
<div className={cn('bus-tooltip', { hebrew: i18n.language === 'he' })}>
{isLoading || !siriRide ? (
Expand Down Expand Up @@ -83,7 +100,8 @@
<li>
{`${t('drive_direction')}: `}
<span>
({position.point?.bearing} {t('bearing')})
{/* ({position.point?.bearing} {t('bearing')}) */}
{position.point?.bearing} {t('bearing')} ({position.point?.bearing !== undefined ? getDirectionFromAngle(position.point.bearing) : t('unknown', { defaultValue: 'unknown' })})
</span>
</li>
<li>
Expand Down
Loading