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
5 changes: 5 additions & 0 deletions internal/hub/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,11 @@ func (s *Service) processDerivedLocation(ctx context.Context, location gen.Locat
if err := s.publishFenceEvents(ctx, location); err != nil {
return err
}
if emit && s.cfg.KalmanFilterEnabled {
if _, err := s.publishTrackableMotionsForLocation(ctx, location, view.NativeScope()); err != nil {
return err
}
}
switch view.NativeScope() {
case ScopeLocal:
wgs84Location, ok, err := view.WGS84(ctx)
Expand Down
40 changes: 40 additions & 0 deletions internal/hub/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,46 @@ func TestProcessDerivedLocationForWGS84PublishesOnlyLocalVariant(t *testing.T) {
}
}

func TestProcessDerivedLocationPublishesNativeMotionWhenKalmanEnabled(t *testing.T) {
t.Parallel()

bus := NewEventBus()
ch, unsubscribe := bus.Subscribe(8)
defer unsubscribe()
zone := georeferencedZoneFixture(t, 47.3744, 8.5411)
crs := "EPSG:4326"
location := testLocationWithCoordinates(t, &crs, zone.Id.String(), [2]float32{8.5412, 47.3745})
trackables := []string{"trackable-a"}
location.Trackables = &trackables

service := &Service{
bus: bus,
cfg: Config{KalmanFilterEnabled: true},
metadata: &MetadataCache{snapshot: newMetadataSnapshot([]zoneRecord{{Zone: zone, Signature: "zone"}}, nil, nil, nil)},
crsTransformer: transform.NewCRSTransformer(),
transformCache: transform.NewCache(),
logger: zapTestLogger(t),
}

if err := service.processDerivedLocation(context.Background(), location, true); err != nil {
t.Fatalf("processDerivedLocation failed: %v", err)
}

events := collectEvents(ch, 3)
var nativeMotionSeen bool
for _, event := range events {
if event.Kind == EventTrackableMotion && event.Scope == ScopeEPSG4326 {
motion := decodeEventMotion(t, event)
if motion.Location.Crs != nil && *motion.Location.Crs == "EPSG:4326" {
nativeMotionSeen = true
}
}
}
if !nativeMotionSeen {
t.Fatalf("expected Kalman-derived native CRS trackable motion, got %+v", events)
}
}

func TestProcessDerivedLocationForLocalPublishesOnlyWGS84Variant(t *testing.T) {
t.Parallel()

Expand Down