private void ReadGPCRow() { FileStream fsStream = null; BinaryReader binrayReader = null; try { fsStream = new FileStream(_fileName, FileMode.Open, FileAccess.Read); binrayReader = new BinaryReader(fsStream); _gcpRows = new GCPRow[67]; for (int i = 0; i < 67; i++) //总共67行数据 { GCPRow row = new GCPRow(); row.Profix = binrayReader.ReadBytes(130); //每行的前缀 byte[][] cellValues = new byte[99][]; for (int j = 0; j < 99; j++) //99个Cell { cellValues[j] = binrayReader.ReadBytes(130); //每个Cell130个值 } row.GridCell = cellValues; _gcpRows[i] = row; } } finally { if (binrayReader != null) { binrayReader.Dispose(); } if (fsStream != null) { fsStream.Dispose(); } } }
private void EQ2SQLUT(GCPRow[] EQMAP, out int[] cellIndex, out int[] rowIndex) { int[] equalLatLon = new int[MAXLAT * MAXLON]; List <int> lstcellIndex = new List <int>(); List <int> lstrowIndex = new List <int>(); byte[][] rowdata = new byte[99][]; int i, j, jlon, lonSQ; int lonIdxBegin, lonIdxend, latIdx; for (i = 0; i < EQMAP.Length; i++) //总共67行数据 { GCPRow row = EQMAP[i]; rowdata = row.GridCell; for (j = 0; j < rowdata.Length; j++) { latIdx = rowdata[j][1]; lonIdxBegin = rowdata[j][2]; lonIdxend = rowdata[j][3]; for (jlon = lonIdxBegin; jlon <= lonIdxend; jlon++) { lonSQ = jlon + MAXLON / 2; if (lonSQ > MAXLON) { lonSQ -= MAXLON; } lstcellIndex.Add(lonSQ); lstrowIndex.Add(latIdx); } } } cellIndex = lstcellIndex.ToArray(); rowIndex = lstrowIndex.ToArray(); }
private void EQ2SQLUT(GCPRow[] EQMAP, out int[] cellIndexs, out int[] rowIndexs) { cellIndexs = new int[MAXLAT * MAXLON]; rowIndexs = new int[MAXLAT * MAXLON]; int[] equalLatLon = new int[MAXLAT * MAXLON]; List <int> lstcellIndex = new List <int>(); List <int> lstrowIndex = new List <int>(); byte[][] rowdata = new byte[99][]; int i, j, jlon; int lonIdxBegin, lonIdxend, latIdx; for (i = 0; i < EQMAP.Length; i++) //总共67行数据 { GCPRow row = EQMAP[i]; rowdata = row.GridCell; for (j = 0; j < rowdata.Length; j++) { latIdx = rowdata[j][0];//Latitude index(equal-area and equal-angle),1-72 if (latIdx <= 72) { latIdx = 72 - latIdx; lonIdxBegin = rowdata[j][2]; //Western-most longitude index(equal-angle),1-144 lonIdxend = rowdata[j][3]; //Eastern-most longitude index(equal-angle),1-144 for (jlon = lonIdxBegin; jlon <= lonIdxend; jlon++) //1-144 { int lonidx = 0; if (jlon > 72) { lonidx = jlon - 72; } else { lonidx = jlon + 72; } cellIndexs[(latIdx) * MAXLON + lonidx - 1] = j;//90~-90, rowIndexs[(latIdx) * MAXLON + lonidx - 1] = i; } } } } }