Skip to content

Commit ff5bc3d

Browse files
committed
Correct radiansToDegrees
Signed-off-by: Daniel Kastl <[email protected]>
1 parent 4c708b7 commit ff5bc3d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/components/gtt-client.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,22 @@ export class GttClient {
335335
this.toolbar.addControl(maximizeCtrl)
336336

337337
// Map rotation
338+
function radiansToDegrees(radians:number) {
339+
let degrees = radians * (180 / Math.PI)
340+
degrees = (degrees % 360 + 360) % 360
341+
return degrees
342+
}
343+
344+
function degreesToRadians(degrees:number) {
345+
return degrees * (Math.PI / 180)
346+
}
347+
338348
const rotation_field = document.querySelector('#settings_project_map_rotation')
339349
if (rotation_field !== null) {
340350
this.map.getView().on('change:rotation', (evt) => {
341-
const degrees = evt.target.getRotation() * 180 / Math.PI
342351
rotation_field.setAttribute(
343352
'value',
344-
String(Math.round(degrees % 360))
353+
String(Math.round(radiansToDegrees(evt.target.getRotation())))
345354
)
346355
})
347356
}

0 commit comments

Comments
 (0)