/// <summary> /// Initializes a new instance of the Grib2Manager from a grib file /// </summary> /// <param gridTemplateName="pInMemoryProcessing">Process the grib2-File in memory. This is significantly faster, but consumes more ressources</param> public Grib2Manager(bool pInMemoryProcessing) { _inMemoryProcessing = pInMemoryProcessing; _StreamDictionary = new Dictionary<int, Stream>(); _Grib2Inputs = new Dictionary<int, Grib2Input>(); _grib2Inventory = new Inventory(new List<InventoryItem>() { }); }
/// <summary> /// Loads and inventarizes a grib2-File /// </summary> /// <param gridTemplateName="pFileName">GridTemplateName of the file that should be loaded</param> public void LoadGrib2File(string pFileName) { Stream _sourceStream; if (_inMemoryProcessing) { using (FileStream fs = new System.IO.FileStream(pFileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { _sourceStream = new MemoryStream(); copyStream(fs, _sourceStream); _sourceStream.Position = 0; } } else { _sourceStream = new System.IO.FileStream(pFileName, FileMode.Open, FileAccess.Read, FileShare.Read); } Grib2Input g2i = new Grib2Input(_sourceStream); g2i.scan(true, false); _StreamDictionary.Add(sourcecount, _sourceStream); _Grib2Inputs.Add(sourcecount, g2i); // RebuildInventory _grib2Inventory = new Inventory(inventarize()); sourcecount++; }