I have a List, and I would like to compute a double[360] containing the maximum range along each bearing (to the nearest degree). One hitch is that the chart plotting software I'm using requires each degree to be populated with no holes. I'm aware of the MoreLinq Batch extension, though not quite sure how to use it...
Heres the code I have so far:-
List<PolarCoords> plots = ...;
double chartVals = new double[360]; // unused degrees will be zero
double MaxRangesByDegree = from polar in plots let angle = RadToDeg(polar.Bearing)
group plot by angle into degreeBuckets
orderby degreeBuckets
select MaxRange = (from polar2 in degreeBuckets select polar2.SlantRange).Max().ToArray()
// somehow merge chartVals and MaxRangesByDegree so no holes
I'm probably trying to bite off too much with a single query, and could certainly do it with a simple for loop, but it's a good exercise for learning LINQ:-) At the moment the code is throwing a SystemException: At least one object must implement IComparable...