Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
e95eae5
change declination calculation to use aircraft loc
red-one1 Nov 25, 2025
332b3a0
added flagon back in! need more boeings.
red-one1 Nov 26, 2025
741e416
fixed braa declination
red-one1 Nov 26, 2025
18993d4
Revert "fixed braa declination"
red-one1 Nov 26, 2025
a59d3ee
.
red-one1 Nov 26, 2025
83f75ab
a
red-one1 Nov 26, 2025
98b1911
w
red-one1 Nov 26, 2025
9e30deb
s
red-one1 Nov 26, 2025
2271daf
Revert "added flagon back in! need more boeings."
red-one1 Nov 26, 2025
7bb970c
Revert "added flagon back in! need more boeings."
red-one1 Nov 26, 2025
f66eb91
adding debug logs to bogeydope controller
red-one1 Nov 29, 2025
6d0b6f2
yes
red-one1 Nov 29, 2025
71ee6bb
more .
red-one1 Nov 29, 2025
7581fce
asdf
red-one1 Nov 29, 2025
42dbfcc
declination debugging
red-one1 Nov 29, 2025
2a274cc
added declination debugging
red-one1 Nov 29, 2025
a20f39f
declination2
red-one1 Nov 29, 2025
146b6e4
swapped lat and lon around
red-one1 Nov 29, 2025
b550bc1
asdf
red-one1 Nov 29, 2025
e9fbede
toDegrees
red-one1 Nov 29, 2025
0d7f1db
latnlong
red-one1 Nov 29, 2025
64671a9
%f
red-one1 Nov 29, 2025
5cd8901
grp latlong
red-one1 Nov 29, 2025
08c2bae
asdf
red-one1 Nov 29, 2025
db2c9db
asdf
red-one1 Nov 29, 2025
ac3e237
asdf
red-one1 Nov 29, 2025
52143b4
asdf
red-one1 Nov 29, 2025
0666135
asdf
red-one1 Nov 29, 2025
a332ccd
asdf
red-one1 Nov 29, 2025
9fb2ac2
asdf
red-one1 Nov 29, 2025
34eac8b
asdf
red-one1 Nov 29, 2025
f304f86
GCtoplanar
red-one1 Nov 29, 2025
17144b7
asdf
red-one1 Nov 30, 2025
f05f129
asdf
red-one1 Nov 30, 2025
002dd5a
test
red-one1 Nov 30, 2025
d96dc84
asdf
red-one1 Nov 30, 2025
2147cd9
Remove .Opposite() from Picture scope to display all coalition groups
red-one1 Nov 30, 2025
7fdc82a
Remove .Opposite() from coalition in broadcastPicture to display all …
red-one1 Nov 30, 2025
21cc36d
Update origin to use opposite coalition in Picture function; adjust d…
red-one1 Nov 30, 2025
ef6d3fb
Fix typo in debug log for coalition in Picture function
red-one1 Nov 30, 2025
0166b26
Add debug logging for group and coalition information in radar functions
red-one1 Nov 30, 2025
3c88ff2
Add debug logging for group and coalition information in radar functions
red-one1 Nov 30, 2025
81b02d3
Revert "GCtoplanar"
red-one1 Nov 30, 2025
6555fd1
Add planar bearing calculation functions to spatial package
red-one1 Nov 30, 2025
0922fc2
Update dependencies and enhance spatial calculations with UTM project…
red-one1 Dec 2, 2025
5cf4764
Merge branch 'declination&newaircraft' of https://github.com/red-one1…
red-one1 Dec 2, 2025
5b024e1
Add newline for code formatting consistency in spatial.go
red-one1 Dec 2, 2025
852e2a0
Fix declination calculation in FindNearestGroupWithBRAA function
red-one1 Dec 2, 2025
48fb343
Update bearing calculation to use magnetic declination in HandleDecla…
red-one1 Dec 2, 2025
6f3b22d
Update bearing calculation to use true bearing in HandleDeclare function
red-one1 Dec 2, 2025
9ac6ca1
Refactor distance calculation to return meters directly in CalculateD…
red-one1 Dec 2, 2025
9a2a67a
Refactor distance calculation to return meters directly and add PROJ …
red-one1 Dec 2, 2025
ef69100
Update TestTrueBearing with new test cases and adjust expected values
red-one1 Dec 3, 2025
31f5789
Update TestDistance to include specific test case and remove redundan…
red-one1 Dec 3, 2025
969868d
Update TestDistance to assert using NauticalMiles instead of Kilometers
red-one1 Dec 3, 2025
41ee8be
Fix TestDistance point coordinates for accurate distance calculation
red-one1 Dec 3, 2025
b231fa9
Update TestDistance to allow a tolerance of 5 nautical miles in asser…
red-one1 Dec 3, 2025
b7e8aa4
Fix TestTrueBearing point coordinates for accurate bearing calculation
red-one1 Dec 3, 2025
cc56882
Update spatial tests with new test cases and adjust expected values f…
red-one1 Dec 3, 2025
e096891
Add TestBullseye function to spatial tests for bearing and distance c…
red-one1 Dec 3, 2025
7678b65
Update Makefile to include 'proj' library for static linking on Windows
red-one1 Dec 4, 2025
c18e51f
Enhance spatial calculations with new projection functions and update…
red-one1 Dec 4, 2025
060a247
Add Flagon aircraft data and variants to the encyclopedia
red-one1 Dec 4, 2025
14ba75c
Log automatic picture status in broadcastAutomaticPicture function
red-one1 Dec 4, 2025
28a1411
Fix log message format in broadcastAutomaticPicture function
red-one1 Dec 4, 2025
4cc21aa
Log automatic picture status during controller initialization
red-one1 Dec 4, 2025
6fce33c
Rename CLI flag for controller callsign to avoid conflicts
red-one1 Dec 4, 2025
508eb4a
asdf
red-one1 Dec 4, 2025
cb05bab
Log point of interest location and range in HandleDeclare function
red-one1 Dec 4, 2025
6b0770c
Comment out debug log statements for automatic picture status
red-one1 Dec 4, 2025
b3daa2e
Add duplicate entry for Tu-126 aircraft with ACMIShortName and tags
red-one1 Dec 4, 2025
98db507
Update README to include TODOs and remove details
red-one1 Dec 4, 2025
3fced34
Refactor bearing and declination calculations; remove unused test files
red-one1 Dec 4, 2025
3cd44d2
this should work
red-one1 Dec 4, 2025
678861c
Update issue templates
red-one1 Dec 5, 2025
cbd44cb
Refactor trackfile handling in Radar; improve test coverage for neare…
red-one1 Dec 7, 2025
8577d3b
Add PROJ build configuration and dependencies to Makefile; update .gi…
red-one1 Dec 7, 2025
4e5d1fe
Merge branch 'dharmab:main' into main
red-one1 Dec 7, 2025
bdc2139
Merge branch 'main' into declination&newaircraft
red-one1 Dec 7, 2025
802bad6
Add terrain detection and handling for multiple terrains; update test…
red-one1 Dec 7, 2025
31e5492
Refactor terrain detection logic and update related tests; improve te…
red-one1 Dec 7, 2025
551267d
Enhance terrain detection from bullseyes; add error logging for detec…
red-one1 Dec 7, 2025
d520b8e
Add bullseyeInsideBounds function for improved terrain detection; ref…
red-one1 Dec 7, 2025
d6c8868
more fixes
red-one1 Dec 7, 2025
dbe2d83
more terrain detection fixes
red-one1 Dec 7, 2025
a97b0a2
log spam!
red-one1 Dec 7, 2025
0ada0cd
Terrain detection now requires all known bullseyes (per source/coali…
red-one1 Dec 7, 2025
f4db177
Made terrain detection require all bullseyes (per source/coalition) t…
red-one1 Dec 7, 2025
6e8fddd
Made terrain detection require all bullseyes (per source/coalition) t…
red-one1 Dec 7, 2025
490291a
Terrain detection now emits just a single log when the terrain actual…
red-one1 Dec 7, 2025
b9b4faa
Filtered duplicate terrain logs: detection now returns “changed” only…
red-one1 Dec 7, 2025
33e26be
stupidness
red-one1 Dec 7, 2025
ee24bec
Added a debug log when the projection actually changes (setCurrentTer…
red-one1 Dec 7, 2025
fed2301
removed custom aircraft
red-one1 Dec 7, 2025
becc26a
3rd party README
red-one1 Dec 7, 2025
7e19b94
Added bullseye checks to spatial tests: each terrain now validates si…
red-one1 Dec 8, 2025
ddae1e5
Merge pull request #15 from red-one1:main
red-one1 Dec 8, 2025
1f8a7e3
comments cleanups
red-one1 Dec 8, 2025
ea82a5b
Merge branch 'UTM' of https://github.com/red-one1/skyeye into UTM
red-one1 Dec 8, 2025
2b372a1
parallel tests
red-one1 Dec 8, 2025
1bc1387
Bug Report:
red-one1 Dec 8, 2025
ca53280
Bug Report: coalition.Opposite()
red-one1 Dec 8, 2025
2af6152
removed parallel tests that break terrains
red-one1 Dec 8, 2025
eb9f025
fixing dockerfile
red-one1 Dec 8, 2025
666642c
Set PKG_CONFIG_PATH explicitly in Dockerfile
red-one1 Dec 8, 2025
50f827d
Added CMake to the Windows CI setup so the proj build can run
red-one1 Dec 8, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/skyeye.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ jobs:
install: |
base-devel
git
mingw-w64-ucrt-x86_64-cmake
mingw-w64-ucrt-x86_64-gcc
mingw-w64-ucrt-x86_64-toolchain
mingw-w64-ucrt-x86_64-opus
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,8 @@ dev/
.vscode/settings.json

*.zip

# PROJ build artifacts (downloaded source, build, and install trees)
third_party/proj-*/
third_party/proj-install/
third_party/proj-*.tar.gz
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [


]
}
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ RUN apt-get update && apt-get install -y \
make \
lsb-release \
gcc \
pkg-config \
libopus-dev \
libproj-dev \
libsoxr-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /skyeye
Expand All @@ -18,13 +20,15 @@ RUN go mod download -x
COPY cmd cmd
COPY internal internal
COPY pkg pkg
ENV PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig
RUN make skyeye
RUN make skyeye-scaler

FROM debian:bookworm-slim AS base
RUN apt-get update && apt-get install -y \
ca-certificates \
libopus0 \
libproj25 \
libsoxr0 \
&& rm -rf /var/lib/apt/lists/*

Expand Down
66 changes: 58 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ WHISPER_CPP_REPO = https://github.com/dharmab/whisper.cpp.git
WHISPER_CPP_VERSION = v1.7.2-windows-fix
WHISPER_CPP_BUILD_ENV =

# PROJ (built from source for static linking on Windows)
PROJ_VERSION = 9.4.1
PROJ_TARBALL = third_party/proj-$(PROJ_VERSION).tar.gz
PROJ_SRC_DIR = third_party/proj-$(PROJ_VERSION)
PROJ_PREFIX = $(abspath third_party/proj-install)
PROJ_LIB = $(PROJ_PREFIX)/lib/libproj.a
PROJ_PC_PATH = $(PROJ_PREFIX)/lib/pkgconfig
PROJ_DEP =
PROJ_CMAKE_FLAGS =

# Compiler variables and flags
GOBUILDVARS = GOARCH=$(GOARCH)
ABS_WHISPER_CPP_PATH = $(abspath $(WHISPER_CPP_PATH))
Expand Down Expand Up @@ -63,11 +73,15 @@ SKYEYE_SCALER_BIN = skyeye-scaler.exe
GO = /ucrt64/bin/go
GOBUILDVARS += GOROOT="/ucrt64/lib/go" GOPATH="/ucrt64"
# Static linking on Windows to avoid MSYS2 dependency at runtime
LIBRARIES = opus soxr
CFLAGS = $(shell pkg-config $(LIBRARIES) --cflags --static)
BUILD_VARS += CFLAGS='$(CFLAGS)'
EXTLDFLAGS = $(shell pkg-config $(LIBRARIES) --libs --static)
LIBRARIES = opus soxr proj
PKG_CONFIG_ENV = PKG_CONFIG_PATH="$(PROJ_PC_PATH):$${PKG_CONFIG_PATH}"
CFLAGS = $(shell $(PKG_CONFIG_ENV) pkg-config $(LIBRARIES) --cflags --static)
BUILD_VARS += CFLAGS='$(CFLAGS)' PKG_CONFIG_PATH="$(PROJ_PC_PATH):$${PKG_CONFIG_PATH}"
EXTLDFLAGS = $(shell $(PKG_CONFIG_ENV) pkg-config $(LIBRARIES) --libs --static)
LDFLAGS += -linkmode external -extldflags "$(EXTLDFLAGS) -static"
PROJ_DEP = $(PROJ_LIB)
# MinGW builds of PROJ 9.4.1 miss <cstdint> in filemanager.cpp; force-include to fix.
PROJ_CMAKE_FLAGS += -DCMAKE_CXX_FLAGS="-include cstdint"
endif

BUILD_VARS += LDFLAGS='$(LDFLAGS)'
Expand All @@ -84,6 +98,8 @@ install-msys2-dependencies:
base-devel \
$(MINGW_PACKAGE_PREFIX)-toolchain \
$(MINGW_PACKAGE_PREFIX)-go \
$(MINGW_PACKAGE_PREFIX)-cmake \
$(MINGW_PACKAGE_PREFIX)-sqlite3 \
$(MINGW_PACKAGE_PREFIX)-opus \
$(MINGW_PACKAGE_PREFIX)-libsoxr

Expand All @@ -93,6 +109,7 @@ install-arch-linux-dependencies:
git \
base-devel \
go \
proj \
opus \
libsoxr

Expand All @@ -103,6 +120,7 @@ install-debian-dependencies:
git \
build-essential \
golang-go \
libproj-dev \
libopus-dev \
libopus0 \
libsoxr-dev \
Expand All @@ -115,6 +133,7 @@ install-fedora-dependencies:
development-tools \
c-development \
golang \
proj-devel \
opus-devel \
opus \
soxr-devel \
Expand All @@ -128,6 +147,7 @@ install-macos-dependencies:
llvm \
pkg-config \
go \
proj \
libsoxr \
opus

Expand All @@ -139,17 +159,47 @@ $(LIBWHISPER_PATH) $(WHISPER_H_PATH):
if [ ! -f $(LIBWHISPER_PATH) -o ! -f $(WHISPER_H_PATH) ]; then git -C "$(WHISPER_CPP_PATH)" checkout --quiet $(WHISPER_CPP_VERSION) || git clone --depth 1 --branch $(WHISPER_CPP_VERSION) -c advice.detachedHead=false "$(WHISPER_CPP_REPO)" "$(WHISPER_CPP_PATH)" && $(WHISPER_CPP_BUILD_ENV) make -C $(WHISPER_CPP_PATH)/bindings/go whisper; fi
if [ -f third_party/whisper.cpp/whisper.a ] && [ ! -f $(LIBWHISPER_PATH) ]; then cp third_party/whisper.cpp/whisper.a $(LIBWHISPER_PATH); fi

.PHONY: proj
proj: $(PROJ_LIB)

$(PROJ_TARBALL):
curl -L -o $(PROJ_TARBALL) https://download.osgeo.org/proj/proj-$(PROJ_VERSION).tar.gz

$(PROJ_LIB): $(PROJ_TARBALL)
rm -rf "$(PROJ_SRC_DIR)" "$(PROJ_PREFIX)"
tar -xzf "$(PROJ_TARBALL)" -C third_party
cmake -S "$(PROJ_SRC_DIR)" -B "$(PROJ_SRC_DIR)/build" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="$(PROJ_PREFIX)" \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_APPS=OFF \
-DBUILD_PROJSYNC=OFF \
-DBUILD_CS2CS=OFF \
-DBUILD_GIE=OFF \
-DBUILD_GEOD=OFF \
-DBUILD_PROJ=OFF \
-DBUILD_PROJINFO=OFF \
-DBUILD_CCT=OFF \
-DENABLE_CURL=OFF \
-DENABLE_TIFF=OFF \
-DENABLE_PROJSYNC=OFF \
-DENABLE_CCT=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_EXAMPLES=OFF \
$(PROJ_CMAKE_FLAGS)
cmake --build "$(PROJ_SRC_DIR)/build" --target install --config Release

.PHONY: whisper
whisper: $(LIBWHISPER_PATH) $(WHISPER_H_PATH)

.PHONY: generate
generate:
generate: $(PROJ_DEP)
$(BUILD_VARS) $(GO) generate $(BUILD_FLAGS) ./...

$(SKYEYE_BIN): generate $(SKYEYE_SOURCES) $(LIBWHISPER_PATH) $(WHISPER_H_PATH)
$(SKYEYE_BIN): generate $(SKYEYE_SOURCES) $(LIBWHISPER_PATH) $(WHISPER_H_PATH) $(PROJ_DEP)
$(BUILD_VARS) $(GO) build $(BUILD_FLAGS) ./cmd/skyeye/

$(SKYEYE_SCALER_BIN): generate $(SKYEYE_SOURCES)
$(SKYEYE_SCALER_BIN): generate $(SKYEYE_SOURCES) $(PROJ_DEP)
$(BUILD_VARS) $(GO) build $(BUILD_FLAGS) ./cmd/skyeye-scaler/

.PHONY: run
Expand Down Expand Up @@ -187,4 +237,4 @@ mostlyclean:

.PHONY: clean
clean: mostlyclean
rm -rf "$(WHISPER_CPP_PATH)"
rm -rf "$(WHISPER_CPP_PATH)" "$(PROJ_SRC_DIR)" "$(PROJ_PREFIX)" "$(PROJ_TARBALL)"
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/jba/omap v0.1.0
github.com/lithammer/shortuuid/v3 v3.0.7
github.com/martinlindhe/unit v0.0.0-20230420213220-4adfd7d0a0d6
github.com/michiho/go-proj/v10 v10.5.11
github.com/nabbl/piper v0.0.0-20240819160100-e51f2288a5c0
github.com/openai/openai-go v0.1.0-alpha.41
github.com/pasztorpisti/go-crc v1.0.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0j
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mgechev/revive v1.13.0 h1:yFbEVliCVKRXY8UgwEO7EOYNopvjb1BFbmYqm9hZjBM=
github.com/mgechev/revive v1.13.0/go.mod h1:efJfeBVCX2JUumNQ7dtOLDja+QKj9mYGgEZA7rt5u+0=
github.com/michiho/go-proj/v10 v10.5.11 h1:CDZYhc19W730k8L1x9ColP0wrjfQ1JV9hpYfC3FFqzY=
github.com/michiho/go-proj/v10 v10.5.11/go.mod h1:eYkLt9XqKpy/r/Y3hGo+rLk6UXA9vNZ6n7vxnuVRIUE=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
Expand Down
4 changes: 4 additions & 0 deletions internal/application/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/dharmab/skyeye/pkg/sim"
"github.com/dharmab/skyeye/pkg/simpleradio"
srs "github.com/dharmab/skyeye/pkg/simpleradio/types"
"github.com/dharmab/skyeye/pkg/spatial"
"github.com/dharmab/skyeye/pkg/synthesizer/speakers"
"github.com/dharmab/skyeye/pkg/telemetry"
"github.com/dharmab/skyeye/pkg/traces"
Expand Down Expand Up @@ -385,6 +386,9 @@ func (a *Application) updateBullseyes() {
log.Warn().Err(err).Msg("error reading bullseye")
} else {
a.radar.SetBullseye(bullseye, coalition)
if name, changed := spatial.DetectTerrainFromBullseye(coalition.String(), bullseye); changed {
log.Debug().Str("terrain", name).Msg("terrain detected from bullseyes")
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/bearings/true.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type True struct {

var _ Bearing = True{}

// NewTrueBearing creates a new bearing from the given value.
// NewTrueBearing creates a new bearing from the given value, relative to true north.
func NewTrueBearing(value unit.Angle) True {
return True{θ: normalize(value)}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func New(
threatMonitoringCooldown time.Duration,
threatMonitoringRequiresSRS bool,
) *Controller {
//log.Debug().Msgf("enableAutomaticPicture is %v", enableAutomaticPicture)
return &Controller{
coalition: coalition,
scope: rdr,
Expand Down
1 change: 1 addition & 0 deletions pkg/radar/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (g *group) Bullseye() *brevity.Bullseye {
}

declination, err := bearings.Declination(*g.bullseye, g.missionTime())

if err != nil {
log.Error().Err(err).Stringer("group", g).Msg("failed to get declination for group")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/radar/nearest.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func (r *Radar) FindNearestGroupWithBRAA(
if grp == nil {
return nil
}

declination := r.Declination(origin)
log.Debug().Any("target latlong", grp).Msgf("target latlong lat %f lon %f", grp.point().Lat(), grp.point().Lon())
declination := r.Declination(trackfile.LastKnown().Point)
bearing := spatial.TrueBearing(origin, grp.point()).Magnetic(declination)
_range := spatial.Distance(origin, grp.point())
aspect := brevity.AspectFromAngle(bearing, trackfile.Course())
Expand Down
110 changes: 110 additions & 0 deletions pkg/radar/nearest_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package radar

import (
"context"
"sync"
"testing"
"time"

"github.com/dharmab/skyeye/pkg/coalitions"
"github.com/dharmab/skyeye/pkg/sim"
"github.com/dharmab/skyeye/pkg/trackfiles"
"github.com/martinlindhe/unit"
"github.com/paulmach/orb"
"github.com/stretchr/testify/assert"
)

func TestNearest(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
origin orb.Point
pointA orb.Point
pointB orb.Point
expectedID uint64
}{
{
name: "finds nearest Red aircraft to origin",
origin: orb.Point{33.405794, 69.047461},
pointA: orb.Point{33.405794, 69.047461},
pointB: orb.Point{24.973478, 70.068836},
expectedID: 2,
},
}

for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
starts := make(chan sim.Started, 10)
updates := make(chan sim.Updated, 10)
fades := make(chan sim.Faded, 10)
rdr := New(coalitions.Blue, starts, updates, fades, 20*unit.NauticalMile)
rdr.SetMissionTime(time.Date(1999, 06, 11, 12, 0, 0, 0, time.UTC))
rdr.SetBullseye(orb.Point{22.867128, 69.047461}, coalitions.Blue)

// Start the radar to process updates
ctx, cancel := context.WithCancel(context.Background())
wg := &sync.WaitGroup{}
go rdr.Run(ctx, wg)

// Add trackfiles to radar via updates channel
updates <- sim.Updated{
Labels: trackfiles.Labels{
ID: 1,
ACMIName: "F-15C",
Name: "Eagle 1",
Coalition: coalitions.Blue,
},
Frame: trackfiles.Frame{
Time: time.Date(1999, 06, 11, 12, 0, 0, 0, time.UTC),
Point: test.pointA,
Altitude: 30000 * unit.Foot,
AGL: func() *unit.Length {
agl := 30000 * unit.Foot
return &agl
}(),
Heading: 90 * unit.Degree,
},
}
updates <- sim.Updated{
Labels: trackfiles.Labels{
ID: 2,
ACMIName: "F-15C",
Name: "Eagle 2",
Coalition: coalitions.Red,
},
Frame: trackfiles.Frame{
Time: time.Date(1999, 06, 11, 12, 0, 0, 0, time.UTC),
Point: test.pointB,
Altitude: 30000 * unit.Foot,
AGL: func() *unit.Length {
agl := 30000 * unit.Foot
return &agl
}(),
Heading: 90 * unit.Degree,
},
}

// Wait for updates to be processed
time.Sleep(100 * time.Millisecond)

group := rdr.FindNearestGroupWithBRAA(
test.origin,
0*unit.NauticalMile,
100000*unit.Foot,
300*unit.NauticalMile,
coalitions.Red,
0,
)

assert.NotNil(t, group)
if group != nil {
ids := group.ObjectIDs()
assert.Contains(t, ids, test.expectedID)
}

// Clean up
cancel()
})
}
}
1 change: 1 addition & 0 deletions pkg/radar/picture.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func (r *Radar) Picture(radius unit.Length, coalition coalitions.Coalition, filt
if spatial.IsZero(origin) {
log.Warn().Msg("center point is not set yet, using bullseye")
origin = r.Bullseye(coalition)
log.Debug().Any("origin", origin).Msgf("using bullseye point for picture, lat %f, lon %f", origin.Lat(), origin.Lon())
if spatial.IsZero(origin) {
log.Warn().Msg("bullseye point is not yet set, picture will be incoherent")
}
Expand Down
Loading
Loading