Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 public/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,23 @@
},
"slope": "Neigung",
"azimuth": "Azimuth",
"yieldPerYear": "Ertrag pro Jahr"
"yieldPerYear": "Ertrag pro Jahr",
"cardinal": {
"N": "Nord",
"NNE": "NNO",
"NE": "NO",
"ENE": "ONO",
"E": "Ost",
"ESE": "OSO",
"SE": "SO",
"SSE": "SSO",
"S": "Süd",
"SSW": "SSW",
"SW": "SW",
"WSW": "WSW",
"W": "West",
"WNW": "WNW",
"NW": "NW",
"NNW": "NNW"
}
}
20 changes: 19 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,23 @@
},
"slope": "Slope",
"azimuth": "Azimuth",
"yieldPerYear": "Yield per year"
"yieldPerYear": "Yield per year",
"cardinal": {
"N": "North",
"NNE": "NNE",
"NE": "NE",
"ENE": "ENE",
"E": "East",
"ESE": "ESE",
"SE": "SE",
"SSE": "SSE",
"S": "South",
"SSW": "SSW",
"SW": "SW",
"WSW": "WSW",
"W": "West",
"WNW": "WNW",
"NW": "NW",
"NNW": "NNW"
}
}
31 changes: 30 additions & 1 deletion src/features/three-viewer/components/MouseHoverInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@ import { useContext } from 'react'
import { useTranslation } from 'react-i18next'
import { SceneContext } from '@/features/three-viewer/context/SceneContext'

const CARDINAL_DIRECTIONS = [
'N',
'NNE',
'NE',
'ENE',
'E',
'ESE',
'SE',
'SSE',
'S',
'SSW',
'SW',
'WSW',
'W',
'WNW',
'NW',
'NNW',
]

function azimuthToCardinal(azimuth) {
const index = Math.round(azimuth / 22.5) % 16
return CARDINAL_DIRECTIONS[index]
}

/**
* Displays mouse hover information for slope, azimuth, and yield.
* Only shown on non-touch devices.
Expand All @@ -10,11 +34,16 @@ export const MouseHoverInfo = () => {
const { t } = useTranslation()
const { slope, azimuth, yieldPerKWP } = useContext(SceneContext)

const cardinalDirection =
azimuth !== null && azimuth !== undefined
? t(`cardinal.${azimuthToCardinal(azimuth)}`)
: null

return (
<div className='attribution' id='footer-on-hover'>
{t('slope')}: {slope}°
<br />
{t('azimuth')}: {azimuth}°
{t('azimuth')}: {cardinalDirection}
{yieldPerKWP ? (
<p>
{t('yieldPerYear')}: {Math.round(yieldPerKWP / 100) * 100} kWh/kWp
Expand Down