package radarfetch // PlanWindQuery marks clusters as eligible or not based on params and // returns a flattened list of sample points for eligible clusters. func PlanWindQuery(clusters []Cluster, params QueryParams) ([]Cluster, []QueryCandidate) { if params.MinAreaPx <= 0 { params.MinAreaPx = 9 } if params.StrongDBZOverride <= 0 { params.StrongDBZOverride = 50 } if params.MaxSamplesPerCluster <= 0 { params.MaxSamplesPerCluster = 5 } if params.MaxCandidatesTotal <= 0 { params.MaxCandidatesTotal = 25 } out := make([]QueryCandidate, 0, len(clusters)*2) for i := range clusters { cl := &clusters[i] eligible := cl.AreaPx >= params.MinAreaPx || cl.MaxDBZ >= params.StrongDBZOverride if !eligible { cl.EligibleForQuery = false cl.SkipReason = "too_small_and_weak" continue } cl.EligibleForQuery = true cl.SkipReason = "" // choose up to MaxSamplesPerCluster from samples (prefer center first) if len(cl.Samples) == 0 { continue } // order: center first, then others as-is picked := 0 // ensure center first if exists for _, s := range cl.Samples { if s.Role == "center" { out = append(out, QueryCandidate{ClusterID: cl.ID, Role: s.Role, Lon: s.Lon, Lat: s.Lat}) picked++ break } } for _, s := range cl.Samples { if picked >= params.MaxSamplesPerCluster { break } if s.Role == "center" { continue } out = append(out, QueryCandidate{ClusterID: cl.ID, Role: s.Role, Lon: s.Lon, Lat: s.Lat}) picked++ } if picked == 0 { // fallback: take first s := cl.Samples[0] out = append(out, QueryCandidate{ClusterID: cl.ID, Role: s.Role, Lon: s.Lon, Lat: s.Lat}) } } // cap total if len(out) > params.MaxCandidatesTotal { out = out[:params.MaxCandidatesTotal] } return clusters, out }