コード例 #1
0
        private void SetOtherAttribute(FileStream fs)
        {
            if (_gridType != 50)
            {
                // Nx - 沿x轴的点数量
                _nx = GribNumberHelper.Int2(fs);
                _nx = (_nx == -1) ? 1 : _nx;

                // Ny - 沿y轴的点数量
                _ny            = GribNumberHelper.Int2(fs);
                _ny            = (_ny == -1) ? 1 : _ny;
                _latFirstPoint = GribNumberHelper.Int3(fs) / 1000.0; // La1 - 第一个格网点的纬度
                _lonFirstPoint = GribNumberHelper.Int3(fs) / 1000.0; // Lo1 - 第一个格网点的经度
                _resolution    = fs.ReadByte();                      //分辨率和组件标识
            }
            switch (_gridType)
            {
            //  Latitude/Longitude  grids,Arakawa semi-staggered e-grid rotated
            //  Arakawa filled e-grid rotated

            case 0:                                               // Latitude/longitude grid
            case 4:                                               //Gaussian latitude/longitude grid
            case 40:
            case 201:
            case 202:
            {
                _latEndPoint = GribNumberHelper.Int3(fs) / 1000.0;          // La2 - 最后的格网点的纬度
                _lonEndPoint = GribNumberHelper.Int3(fs) / 1000.0;          // Lo2 - 最后的格网点的经度
                _dx          = GribNumberHelper.Int2(fs) / 1000.0;          // Dx - 经度方向增加量
                if (_gridType == 4)
                {
                    _np = GribNumberHelper.Int2(fs);                        // Np-极点与赤道间的平行线
                }
                else
                {
                    _dy = GribNumberHelper.Int2(fs) / 1000.0; // Dy - 纬度方向增加量
                }
                _scanMode = fs.ReadByte();                    //扫描模式
                //29-32 reserved
                fs.Seek(4, SeekOrigin.Current);
                if (_sectionLength > 32)
                {
                    // Vertical coordinates (NV) and thinned grids (PL) not supported - skip this
                    fs.Seek(_sectionLength - 32, SeekOrigin.Current);
                }
                break;
            }

            //Mercator projection
            case 1:
                _latEndPoint = GribNumberHelper.Int3(fs) / 1000.0; // La2 - 最后格网点的纬度
                _lonEndPoint = GribNumberHelper.Int3(fs) / 1000.0; // Lo2 - 最后格网点的经度
                // octets 24-26 (Latin - latitude where cylinder intersects the earth
                _latin1 = GribNumberHelper.Int3(fs) / 1000.0;      //  Latin -圆柱体与地球相交处的高程
                fs.ReadByte();
                _scanMode = fs.ReadByte();                         //扫描模式
                _dx       = GribNumberHelper.Int3(fs);             // Dx - 经度方向增加量
                _dy       = GribNumberHelper.Int3(fs);             //  Dy - 纬度方向增加量
                fs.Seek(4, SeekOrigin.Current);
                if (_sectionLength > 42)
                {
                    // Vertical coordinates (NV) and thinned grids (PL) not supported - skip this
                    fs.Seek(_sectionLength - 42, SeekOrigin.Current);
                }
                break;

            //Lambert conformal, secant or tangent, conic or bi-polar, projection
            case 3:
                // Lov - Orientation of the grid - east lon parallel to y axis)
                _lov          = GribNumberHelper.Int3(fs) / 1000.0;
                _dx           = GribNumberHelper.Int3(fs); // Dx - X方向格网长度
                _dy           = GribNumberHelper.Int3(fs); // Dy - Y方向格网长度
                _projetcenter = fs.ReadByte();             //投影中心标识
                _scanMode     = fs.ReadByte();             //扫描模式
                // Latin1 - first lat where secant cone cuts spherical earth
                _latin1 = GribNumberHelper.Int3(fs) / 1000.0;
                // Latin2 - second lat where secant cone cuts spherical earth)
                _latin2 = GribNumberHelper.Int3(fs) / 1000.0;
                _latsp  = GribNumberHelper.Int3(fs) / 1000.0;   //南极点纬度
                _lonsp  = GribNumberHelper.Int3(fs) / 1000.0;   //南极点经度
                fs.Seek(2, SeekOrigin.Current);
                if (_sectionLength > 42)
                {
                    // Vertical coordinates (NV) and thinned grids (PL) not supported - skip this
                    fs.Seek(_sectionLength - 42, SeekOrigin.Current);
                }

                break;

            case 5:
                // Lov - Orientation of the grid - east lon parallel to y axis)
                _lov          = GribNumberHelper.Int3(fs) / 1000.0;
                _dx           = GribNumberHelper.Int3(fs); // Dx - 经度方向增加量
                _dy           = GribNumberHelper.Int3(fs); // Dy - 纬度方向增加量
                _projetcenter = fs.ReadByte();             //投影中心标识
                _scanMode     = fs.ReadByte();             //扫描模式
                fs.Seek(4, SeekOrigin.Current);
                if (_sectionLength > 32)
                {
                    // Vertical coordinates (NV) and thinned grids (PL) not supported - skip this
                    fs.Seek(_sectionLength - 32, SeekOrigin.Current);
                }
                break;

            default:
                break;
            }
            if ((_scanMode & 63) != 0)
            {
                throw new Exception("GDS: This scanning mode (" + _scanMode + ") is not supported.");
            }
        }