differentiate aprs symbol rotation

* rotate based on symbol graphics alignment
* inspired by @luarvique
* references #352
This commit is contained in:
Jakob Ketterl 2023-08-30 19:25:51 +02:00
parent feb309054a
commit 03306baad1

View file

@ -2,6 +2,18 @@ function AprsMarker() {}
AprsMarker.prototype = new google.maps.OverlayView();
AprsMarker.prototype.isFacingEast = function(symbol) {
var candidates = ''
if (symbol.table === '/') {
// primary table
candidates = '(*<=>CFPUXYabefghjkpsuv[';
} else {
// alternate table
candidates = 'hkluv';
}
return candidates.includes(symbol.symbol);
};
AprsMarker.prototype.draw = function() {
var div = this.div;
var overlay = this.overlay;
@ -16,9 +28,15 @@ AprsMarker.prototype.draw = function() {
}
if (this.course) {
if (this.course > 180) {
if (this.symbol && !this.isFacingEast(this.symbol)) {
// assume symbol points to the north
div.style.transform = 'rotate(' + this.course + ' deg)';
} else if (this.course > 180) {
// symbol is pointing east
// don't rotate more than 180 degrees, rather mirror
div.style.transform = 'scalex(-1) rotate(' + (270 - this.course) + 'deg)'
} else {
// symbol is pointing east
div.style.transform = 'rotate(' + (this.course - 90) + 'deg)';
}
} else {