min packet thresh

This commit is contained in:
ajvpot
2025-09-18 01:58:48 +02:00
parent 4faa6491c2
commit f34836763c
3 changed files with 42 additions and 2 deletions

View File

@@ -165,6 +165,37 @@ export default function MapLayerSettingsComponent({ onSettingsChange }: MapLayer
</span>
</label>
{/* Minimum packet count - indented sub-option */}
<div className="ml-6 mb-3">
<label className={`block text-sm ${
settings.showAllNeighbors
? 'text-gray-700 dark:text-gray-300'
: 'text-gray-400 dark:text-gray-500'
} mb-1`}>
Min packet count threshold
</label>
<input
type="number"
min="1"
step="1"
value={settings.minPacketCount}
onChange={(e) => updateSetting('minPacketCount', Math.max(1, parseInt(e.target.value) || 1))}
disabled={!settings.showAllNeighbors}
className={`w-full p-2 border border-gray-300 dark:border-neutral-600 rounded text-sm ${
settings.showAllNeighbors
? 'bg-white dark:bg-neutral-800 text-gray-700 dark:text-gray-300'
: 'bg-gray-100 dark:bg-neutral-700 text-gray-400 dark:text-gray-500 cursor-not-allowed'
}`}
/>
<p className={`text-xs mt-1 ${
settings.showAllNeighbors
? 'text-gray-500 dark:text-gray-400'
: 'text-gray-400 dark:text-gray-500'
}`}>
Only show path neighbors with at least this many packets
</p>
</div>
{/* Tile layer */}
<div className="mb-3">
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">

View File

@@ -367,11 +367,13 @@ function NeighborLines({
function AllNeighborLines({
connections,
nodes,
useColors = true
useColors = true,
minPacketCount = 1
}: {
connections: AllNeighborsConnection[];
nodes: NodePosition[];
useColors?: boolean;
minPacketCount?: number;
}) {
if (connections.length === 0) return null;
@@ -379,8 +381,11 @@ function AllNeighborLines({
const visibleNodeIds = new Set(nodes.map(node => node.node_id));
// Filter connections to only show lines between nodes that are visible on the map
// and meet the minimum packet count threshold
const visibleConnections = connections.filter(connection =>
visibleNodeIds.has(connection.source_node) && visibleNodeIds.has(connection.target_node)
visibleNodeIds.has(connection.source_node) &&
visibleNodeIds.has(connection.target_node) &&
connection.packet_count >= minPacketCount
);
// Calculate logarithmic thresholds based on packet counts for path connections
@@ -492,6 +497,7 @@ export default function MapView({ target = '_self' }: MapViewProps = {}) {
useColors: true,
nodeTypes: ["meshcore"],
showMeshcoreCoverageOverlay: false,
minPacketCount: 1,
});
// Use query params to persist map position
@@ -811,6 +817,7 @@ export default function MapView({ target = '_self' }: MapViewProps = {}) {
connections={allNeighborConnections}
nodes={nodePositions}
useColors={mapLayerSettings.useColors}
minPacketCount={mapLayerSettings.minPacketCount}
/>
)}
</MapContainer>

View File

@@ -12,6 +12,7 @@ export interface MapLayerSettings {
useColors: boolean;
nodeTypes: NodeType[];
showMeshcoreCoverageOverlay: boolean;
minPacketCount: number;
}
const DEFAULT_MAP_LAYER_SETTINGS: MapLayerSettings = {
@@ -23,6 +24,7 @@ const DEFAULT_MAP_LAYER_SETTINGS: MapLayerSettings = {
useColors: true,
nodeTypes: ["meshcore"],
showMeshcoreCoverageOverlay: false,
minPacketCount: 1,
};
export function useMapLayerSettings() {