Skip to content

Analysis Map: multi-source selection shows fewer neighbor links than individual sources (intersection instead of union) #3792

Description

@Yeraze

Bug: Analysis Map Shows Fewer Neighbor Links When Multiple Sources Selected

Summary

When selecting multiple sources (e.g. LoRa + MQTT) on the Analysis Map, fewer neighbor info links are displayed than when viewing either source individually. The combined view should show the union of all links, but it instead silently drops cross-source edges.

Root Cause

File: src/components/MapAnalysis/layers/NeighborLinksLayer.tsx (~lines 80–100)

The layer builds a position lookup map keyed by "${sourceId}:${nodeNum}". When rendering edges, it resolves both endpoint positions using only the edge's own sourceId:

const aKey = `${e.sourceId}:${Number(e.nodeNum)}`;
const bKey = `${e.sourceId}:${Number(e.neighborNum)}`;
const a = positionByKey.get(aKey);
const b = positionByKey.get(bKey);
if (!a || !b) continue;   // silently drops the edge

A neighbor edge carries a single sourceId — the source on which the reporting node's packet arrived. But the neighbor node's position may only be recorded under a different source.

Example:

  • Edge reported on source B → looks up B:neighborNodeNum
  • Neighbor node only has a known position under A:neighborNodeNum
  • Lookup returns undefined → edge is silently skipped

Result: only edges where both endpoints have a position on the same source as the reporting node survive — effectively an intersection, not a union.

Scope

The API is correct: src/db/repositories/analysis.ts getNeighbors() uses inArray(neighbors.sourceId, args.sourceIds) and returns the full union across all selected sources. The bug is entirely in frontend rendering.

Proposed Fix

In NeighborLinksLayer.tsx, replace the strict source-scoped lookup with a fallback: first try ${e.sourceId}:${nodeNum}, then fall back to any key matching nodeNum across all sources present in the position map. Cross-source edges will then render correctly as long as both endpoints have a known position on any selected source.

Reproduction

  1. Open Analysis Map with at least two sources configured (e.g. LoRa + MQTT)
  2. Select only Source A — note the neighbor links visible
  3. Select only Source B — note the neighbor links visible
  4. Select both sources — observe fewer links than either individual view

Authored by NodeZero 0️⃣

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions