/// <summary> /// Parses the grid table data /// </summary> /// <param name="table">The table to fill</param> /// <returns>true if the data could be read.</returns> internal override bool ReadData(GridTable table) { using (var s = OpenGridTableStream()) { s.Seek(_dataOffset + 176, SeekOrigin.Current); using (var br = new BinaryReader(s)) { var numPhis = table.NumPhis; var coeffs = new PhiLambda[numPhis][]; var numLambdas = table.NumLambdas; for (var row = 0; row < numPhis; row++) { coeffs[row] = new PhiLambda[numLambdas]; // NTV order is flipped compared with a normal CVS table for (var col = numLambdas - 1; col >= 0; col--) { // shift values are given in "arc-seconds" and need to be converted to radians. coeffs[row][col] = PhiLambda.ArcSecondsToRadians( ReadBigEndianDouble(br), ReadBigEndianDouble(br)); } } } } return(true); }
/// <summary> /// Parses the grid table data /// </summary> /// <param name="table">The table to fill</param> /// <returns>true if the data could be read.</returns> internal override bool ReadData(GridTable table) { using (var brLos = new BinaryReader(OpenGridTableStream())) using (var brLas = new BinaryReader(OpenLasStream())) { var numPhis = table.NumPhis; var coeffs = new PhiLambda[numPhis][]; var numLambdas = table.NumLambdas; //position the stream var offset = sizeof(float) * (numLambdas + 1); brLas.BaseStream.Seek(offset, SeekOrigin.Current); brLos.BaseStream.Seek(offset, SeekOrigin.Current); for (var i = 0; i < numPhis; i++) { //Skip first 'zero' value brLas.ReadBytes(sizeof(float)); brLos.ReadBytes(sizeof(float)); coeffs[i] = new PhiLambda[numLambdas]; coeffs[i][0] = PhiLambda.ArcSecondsToRadians(brLas.ReadSingle(), brLos.ReadSingle()); for (var j = 1; j < numLambdas; j++) { coeffs[i][j] = coeffs[i][j - 1] + PhiLambda.ArcSecondsToRadians(brLas.ReadSingle(), brLos.ReadSingle()); } table.Coefficients = coeffs; } return(true); } }