Ejemplo n.º 1
0
        private void GetProjection(byte[] bytes)
        {
            byte[] tbytes = new byte[2];
            if (_productType == 1)    //Get grid/projection parameters
            {
                Array.Copy(bytes, 58, tbytes, 0, 2);
                int channel = BitConverter.ToInt16(tbytes, 0);
                Array.Copy(bytes, 60, tbytes, 0, 2);
                int projType = BitConverter.ToInt16(tbytes, 0);
                Array.Copy(bytes, 62, tbytes, 0, 2);
                _width = BitConverter.ToInt16(tbytes, 0);
                Array.Copy(bytes, 64, tbytes, 0, 2);
                _height = BitConverter.ToInt16(tbytes, 0);
                Array.Copy(bytes, 66, tbytes, 0, 2);
                int ulLineNum = BitConverter.ToInt16(tbytes, 0);
                Array.Copy(bytes, 68, tbytes, 0, 2);
                int ulPixelNum = BitConverter.ToInt16(tbytes, 0);
                Array.Copy(bytes, 70, tbytes, 0, 2);
                int ratio = BitConverter.ToInt16(tbytes, 0);
                Array.Copy(bytes, 72, tbytes, 0, 2);
                _ulLatitude = BitConverter.ToInt16(tbytes, 0);
                _ulLatitude = _ulLatitude / 100;
                Array.Copy(bytes, 74, tbytes, 0, 2);
                _lrLatitude = BitConverter.ToInt16(tbytes, 0);
                _lrLatitude = _lrLatitude / 100;
                Array.Copy(bytes, 76, tbytes, 0, 2);
                _ulLongitude = BitConverter.ToInt16(tbytes, 0);
                _ulLongitude = _ulLongitude / 100;
                Array.Copy(bytes, 78, tbytes, 0, 2);
                _lrLongitude = BitConverter.ToInt16(tbytes, 0);
                _lrLongitude = _lrLongitude / 100;
                Array.Copy(bytes, 80, tbytes, 0, 2);
                _latCenter = BitConverter.ToInt16(tbytes, 0);
                _latCenter = _latCenter / 100;
                Array.Copy(bytes, 82, tbytes, 0, 2);
                _lonCenter = BitConverter.ToInt16(tbytes, 0);
                _lonCenter = _lonCenter / 100;
                Array.Copy(bytes, 84, tbytes, 0, 2);
                float lat1 = BitConverter.ToInt16(tbytes, 0);
                lat1 = lat1 / 100;
                Array.Copy(bytes, 86, tbytes, 0, 2);
                float lat2 = BitConverter.ToInt16(tbytes, 0);
                lat2 = lat2 / 100;
                Array.Copy(bytes, 88, tbytes, 0, 2);
                _xDelt = BitConverter.ToInt16(tbytes, 0);
                _xDelt = _xDelt / 100;
                Array.Copy(bytes, 90, tbytes, 0, 2);
                _yDelt = BitConverter.ToInt16(tbytes, 0);
                _yDelt = _yDelt / 100;
                Array.Copy(bytes, 92, tbytes, 0, 2);
                int hasGeoGrid = BitConverter.ToInt16(tbytes, 0);
                Array.Copy(bytes, 94, tbytes, 0, 2);
                int geoGridValue = BitConverter.ToInt16(tbytes, 0);
                Array.Copy(bytes, 96, tbytes, 0, 2);
                int lenPallate = BitConverter.ToInt16(tbytes, 0);
                Array.Copy(bytes, 98, tbytes, 0, 2);
                int lenVef = BitConverter.ToInt16(tbytes, 0);
                Array.Copy(bytes, 100, tbytes, 0, 2);
                int lenGeo = BitConverter.ToInt16(tbytes, 0);

                string projStr = this.ProjectionInfo.ToProj4String();
                switch (projType)
                {
                case 0:        //未投影(卫星投影)

                    break;

                case 1:        //兰勃托投影
                    projStr = "+proj=lcc" +
                              "+lon_0=" + _lonCenter.ToString() +
                              "+lat_0=" + _latCenter.ToString() +
                              "+lat_1=" + lat1.ToString() +
                              "+lat_2=" + lat2.ToString();
                    break;

                case 2:        //麦卡托投影
                    projStr = "+proj=merc" +
                              "+lon_0=" + _lonCenter.ToString() +
                              "+lat_ts=" + lat1.ToString();
                    break;

                case 3:        //极射投影
                    projStr = "+proj=stere" +
                              "+lat_0=" + _latCenter.ToString() +
                              "+lon_0=" + _lonCenter.ToString();
                    double k0 = Proj.CalScaleFactorFromStandardParallel(lat1);
                    projStr += "+k=" + k0.ToString();
                    break;

                case 4:        //等经纬度投影

                    break;

                case 5:        //等面积投影

                    break;
                }

                if (projStr != this.ProjectionInfo.ToProj4String())
                {
                    this.ProjectionInfo = new ProjectionInfo(projStr);
                }

                CalCoordinate_1(projType);
            }
        }