private IEnumerable <BoundingBox3D> ConvertToBoundingBox3D(IEnumerable <IGeoCell> cells) { foreach (var geoCellTuple in cells) { IndexBoundingBox timeBB = timeAxisBBcalc.GetBoundingBox(geoCellTuple.Time); IndexBoundingBox latBB = latAxisBBcalc.GetBoundingBox(geoCellTuple.LatMin, geoCellTuple.LatMax); IndexBoundingBox lonBB = lonAxisBBcalc.GetBoundingBox(geoCellTuple.LonMin, geoCellTuple.LonMax); yield return(new BoundingBox3D(timeBB, latBB, lonBB)); } }
protected DataDomain CalcDataDomain(ICellRequest[] cells, ITimeAxisBoundingBoxCalculator timeBBcalc, ISpatGridBoundingBoxCalculator latBBcalc, ISpatGridBoundingBoxCalculator lonBBcalc) { if (cells.Length == 0) { throw new ArgumentException("cells array must contain elements"); } string variable = cells[0].VariableName; //calculating bounding box IndexBoundingBox timeBB = new IndexBoundingBox(); IndexBoundingBox latBB = new IndexBoundingBox(); IndexBoundingBox lonBB = new IndexBoundingBox(); Stopwatch bbCalc = Stopwatch.StartNew(); ts.TraceEvent(TraceEventType.Start, 1, "Calculating bounding box"); var cellArray = cells.ToArray(); foreach (var geoCellTuple in cellArray) { IndexBoundingBox timeBB2 = timeBBcalc.GetBoundingBox(geoCellTuple.Time); IndexBoundingBox latBB2 = latBBcalc.GetBoundingBox(geoCellTuple.LatMin, geoCellTuple.LatMax); IndexBoundingBox lonBB2 = lonBBcalc.GetBoundingBox(geoCellTuple.LonMin, geoCellTuple.LonMax); timeBB = IndexBoundingBox.Union(timeBB, timeBB2); latBB = IndexBoundingBox.Union(latBB, latBB2); lonBB = IndexBoundingBox.Union(lonBB, lonBB2); } bbCalc.Stop(); ts.TraceEvent(TraceEventType.Stop, 1, string.Format("Bounding box calculated in {0}", bbCalc.Elapsed)); if (timeBB.IsSingular || latBB.IsSingular || lonBB.IsSingular) { ts.TraceEvent(TraceEventType.Information, 4, "Bounding box is singular. (all cells are out of the data) Returning NoData"); return(null); } else { ts.TraceEvent(TraceEventType.Information, 5, string.Format("{0} elements in bounding box", (timeBB.last - timeBB.first + 1) * (latBB.last - latBB.first + 1) * (lonBB.last - lonBB.first + 1))); } var dataDomain = ConstructDataDomain(variable, metadata, lonBB, latBB, timeBB); return(dataDomain); }