/// <summary>
        /// Get projection info
        /// </summary>
        /// <returns>projection info</returns>
        public ProjectionInfo GetProjectionInfo()
        {
            ProjectionInfo aProjInfo = new ProjectionInfo();
            string         projStr   = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";

            switch (GridType)
            {
            case 0:        // Standard Lat/Lon grid, no rotation
            case 4:        //Gaussian Lat/Lon grid
            case 10:       // Rotated Lat/Lon grid
            case 201:      //Arkawa semi-staggered E-grid on rotated lat/lon grid
            case 202:      //Arakawa filled E -grid on rotated lat/lon grid
                projStr = KnownCoordinateSystems.Geographic.World.WGS1984.ToProj4String();
                break;

            case 1:        //Mercator projection
                if (Latin1 == 0)
                {
                    projStr = "+proj=merc+lon_0=" + GRIBData.GetMeanLongitude(Lon1, Lon2).ToString();
                }
                else        //Transverse_Mercator
                {
                    projStr = "+proj=tmerc+lon_0=" + GRIBData.GetMeanLongitude(Lon1, Lon2).ToString() +
                              "+lat_0=" + Latin1.ToString();
                }
                break;

            case 3:        //Lambert projection
                projStr = "+proj=lcc+lon_0=" + Lov.ToString() +
                          "+lat_1=" + Latin1.ToString() +
                          "+lat_2=" + Latin2.ToString();
                break;

            case 5:        //Polar stereographic projection
            case 87:
                double lat0 = 90;
                if ((Proj_Center & 128) != 0)
                {
                    lat0 = -90;
                }
                projStr = "+proj=stere+lon_0=" + Lov.ToString() +
                          "+lat_0=" + lat0.ToString();
                break;

            default:
                return(null);
            }

            aProjInfo = new ProjectionInfo(projStr);
            return(aProjInfo);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="br">binary reader</param>
        public GRIB2Message(BinaryReader br)
        {
            GribINS = new GRIB2IndicatorSection(br);
            GribIDS = new GRIB2IdentificationSection(br);
            int sectionNum = GRIBData.ReadSectionNumber(br);

            if (sectionNum == 2)
            {
                GribLUS = new GRIB2LocalUseSection(br);
            }

            GribGDS = new GRIB2GridDefinitionSection(br);
            GribPDS = new GRIB2ProductDefinitionSection(br);
            GribDRS = new GRIB2DataRepresentationSection(br);
            GribBMS = new GRIB2BitMapSection(br);
            GribDS  = new GRIB2DataSection(br, GribGDS, GribDRS, GribBMS);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="br">binary reader</param>
        /// <param name="startSection">start section</param>
        /// <param name="startPos">start position</param>
        public GRIB2Message(BinaryReader br, int startSection, long startPos)
        {
            GribINS = new GRIB2IndicatorSection(br);
            GribIDS = new GRIB2IdentificationSection(br);
            if (startSection == 2)
            {
                br.BaseStream.Position = startPos;
                GribLUS = new GRIB2LocalUseSection(br);
                GribGDS = new GRIB2GridDefinitionSection(br);
                GribPDS = new GRIB2ProductDefinitionSection(br);
                GribDRS = new GRIB2DataRepresentationSection(br);
                GribBMS = new GRIB2BitMapSection(br);
                GribDS  = new GRIB2DataSection(br, GribGDS, GribDRS, GribBMS);
            }
            else
            {
                int sectionNum = GRIBData.ReadSectionNumber(br);
                if (sectionNum == 2)
                {
                    GribLUS = new GRIB2LocalUseSection(br);
                }

                switch (startSection)
                {
                case 3:
                    br.BaseStream.Position = startPos;
                    GribGDS = new GRIB2GridDefinitionSection(br);
                    GribPDS = new GRIB2ProductDefinitionSection(br);
                    GribDRS = new GRIB2DataRepresentationSection(br);
                    GribBMS = new GRIB2BitMapSection(br);
                    GribDS  = new GRIB2DataSection(br, GribGDS, GribDRS, GribBMS);
                    break;

                case 4:
                    GribGDS = new GRIB2GridDefinitionSection(br);
                    br.BaseStream.Position = startPos;
                    GribPDS = new GRIB2ProductDefinitionSection(br);
                    GribDRS = new GRIB2DataRepresentationSection(br);
                    GribBMS = new GRIB2BitMapSection(br);
                    GribDS  = new GRIB2DataSection(br, GribGDS, GribDRS, GribBMS);
                    break;
                }
            }
        }
        /// <summary>
        /// Get projection info
        /// </summary>
        /// <returns>projection info</returns>
        public ProjectionInfo GetProjectionInfo()
        {
            ProjectionInfo aProjInfo = new ProjectionInfo();
            string         projStr   = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";

            switch (TemplateNum)
            {  // Grid Definition Template Number
            case 0:
            case 1:
            case 2:
            case 3:           // Latitude/Longitude Grid
                projStr = KnownCoordinateSystems.Geographic.World.WGS1984.ToProj4String();
                break;

            case 10:      // Mercator
                if (lad == 0)
                {
                    projStr = "+proj=merc+lon_0=" + GRIBData.GetMeanLongitude(lo1, lo2).ToString();
                }
                else        //Transverse_Mercator
                {
                    projStr = "+proj=tmerc+lon_0=" + GRIBData.GetMeanLongitude(lo1, lo2).ToString() +
                              "+lat_0=" + lad.ToString();
                }
                break;

            case 20:      // Polar stereographic projection
                double lat0 = 90;
                if ((projectionCenter & 128) != 0)
                {
                    lat0 = -90;
                }
                projStr = "+proj=stere+lon_0=" + lov.ToString() +
                          "+lat_0=" + lat0.ToString();
                break;

            case 30:      // Lambert Conformal
                projStr = "+proj=lcc+lon_0=" + lov.ToString() +
                          "+lat_0=" + lad.ToString() +
                          "+lat_1=" + latin1.ToString() +
                          "+lat_2=" + latin2.ToString();
                break;

            case 31:      // Albers Equal Area


                break;

            case 40:
            case 41:
            case 42:
            case 43:      // Gaussian latitude/longitude
                projStr = KnownCoordinateSystems.Geographic.World.WGS1984.ToProj4String();
                break;

            case 50:
            case 51:
            case 52:
            case 53:                         // Spherical harmonic coefficients


                break;

            case 90:      // Space view perspective or orthographic
                projStr = "+proj=ortho+lon_0=" + lop.ToString() +
                          "+lat_0=" + lap.ToString();

                //if (isOrtho)
                //    projStr = "+proj=ortho+lon_0=" + lop.ToString() +
                //        "+lat_0=" + lap.ToString();
                //else
                //    projStr = "+proj=geos+lon_0=" + lop.ToString() +
                //        "+h=" + altitude.ToString();
                break;

            case 100:      // Triangular grid based on an icosahedron


                break;

            case 110:      // Equatorial azimuthal equidistant projection


                break;

            case 120:      // Azimuth-range Projection


                break;

            case 204:      // Curvilinear orthographic

                break;

            default:
                return(null);
            }

            aProjInfo = new ProjectionInfo(projStr);
            return(aProjInfo);
        }