Exemple #1
0
        private unsafe void UpdateGeo()
        {
            ReadImgInfo(_img, ref _width, ref _height, ref _bands, ref _bitsPerPixel);
            ReadImgDataType(_img, ref _dataType);
            //--georef
            double[] padf = new double[6];
            fixed(void *p = padf)
            {
                double *ptr = (double *)p;

                ReadImgGeoInfo(_img, ref _psjDesp, ptr);
            }

            _minX = padf[0];
            _maxX = _minX + padf[1] * _width;
            _minY = padf[3] + padf[5] * _height;
            _maxY = padf[3];

            _colCount = (int)Math.Ceiling((double)_width / 512);
            _rowCount = (int)Math.Ceiling((double)_height / 512);

            _levels = 1;
            int nTileX = ColCount;
            int nTileY = RowCount;

            while (nTileX > 1 && nTileY > 1)
            {
                nTileX = (nTileX + 1) >> 1;
                nTileY = (nTileY + 1) >> 1;
                _levels++;
            }
            ;

            CurGeoRegion = new GeoRegion(MinX, MaxX, MinY, MaxY);

            if (MaxY > 91 || _minY < -91 || _maxX > 181 || MinX < -181 || (CurGeoRegion.LatitudeSpan < float.Epsilon && CurGeoRegion.MaxLat < float.Epsilon))
            {
                if (ProjectDescription != "")
                {
                    IsProjected = true;
                    double minx = 0, miny = 0, maxx = 0, maxy = 0;
                    TranslateToGeoLatLon(ProjectDescription, _minX,
                                         _maxY, ref minx, ref maxy);
                    TranslateToGeoLatLon(ProjectDescription, _maxX,
                                         _minY, ref maxx, ref miny);//--如果异常情况,或者投影参数错误,添加处理方法
                    CurGeoRegion = new GeoRegion(minx, maxx, miny, maxy);
                }
                else
                {
                    _minX        = 0;
                    _maxX        = 1;
                    _minY        = 0;
                    _maxY        = (double)Height / Width;
                    CurGeoRegion = new GeoRegion(MinX, MaxX, MinY, MaxY);
                }
            }

            _resX = (_maxX - _minX) / _width;
            _rexY = (_maxY - _minY) / _height;
        }
Exemple #2
0
        public static double CalAltFromGeoRegion(GeoRegion region)
        {
            double span = region.LatitudeSpan > region.LongitudeSpan ? region.LatitudeSpan : region.LongitudeSpan;

            double alt = Radius * Math.Abs(Math.Sin(Angle.DegreeToRadians * span));

            return(alt);
        }
Exemple #3
0
 public bool Contain(GeoRegion r)
 {
     if (MaxLon >= r.MaxLon &&
         MinLon <= r.MinLon &&
         MaxLat >= r.MaxLat &&
         MinLat <= r.MinLat)
     {
         return(true);
     }
     return(false);
 }
Exemple #4
0
 public bool Intersect(GeoRegion r)
 {
     if (MaxLon <= r.MinLon ||
         MinLon >= r.MaxLon ||
         MaxLat <= r.MinLat ||
         MinLat >= r.MaxLat)
     {
         return(false);
     }
     return(true);
 }
Exemple #5
0
        public virtual string Open(string path)
        {
            try
            {
                fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                br = new BinaryReader(fs);

                MinLevel = br.ReadInt32();
                MaxLevel = br.ReadInt32();

                MinRow         = br.ReadInt32();
                MaxRow         = br.ReadInt32();
                MinCol         = br.ReadInt32();
                MaxCol         = br.ReadInt32();
                outFormat      = (LCompressFormat)(br.ReadInt32());
                _region        = new GeoRegion();
                _region.MinLon = br.ReadDouble();
                _region.MaxLon = br.ReadDouble();
                _region.MinLat = br.ReadDouble();
                _region.MaxLat = br.ReadDouble();
                this.CFormat   = outFormat;
                int dt = br.ReadInt32();

                DataType = (LDataType)dt;

                _bitsPerPixel = br.ReadInt32() * 8;
                CurGeoRegion  = _region;

                MinX         = CurGeoRegion.MinLon;
                MaxX         = CurGeoRegion.MaxLon;
                MinY         = CurGeoRegion.MinLat;
                MaxY         = CurGeoRegion.MaxLat;
                _info        = new GGeoImageInfo();
                _info.MaxCol = MaxCol;
                _info.MinCol = MinCol;
                _info.MaxRow = MaxRow;
                _info.MinRow = MinRow;

                _info.MaxLevel  = MaxLevel;
                _info.MinLevel  = MinLevel;
                _info.outFormat = outFormat;
                _info.Region    = CurGeoRegion;
                this.Tag        = _info;
                //ResolutionX =
            }
            catch
            {
                return("wrong");
            }

            return("");
        }
Exemple #6
0
        public string Open(string uri)
        {
            int r = OpenLFile(uri, ref _imgPtr, 0);

            if (r == -1)
            {
                throw new Exception("影像文件无法打开!");
                return("wrong!");
            }
            else
            {
                LImageInfo info = new LImageInfo();
                GetImageInfo(_imgPtr, ref info);
                _width   = info.width;
                _height  = info.height;
                _bands   = info.bands;
                _cFormat = info.LCFormate;

                _levels   = info.levelCount;
                _rowCount = info.nRows;
                _colCount = info.nCols;

                _dataType = info.dataType;
                _psjDesp  = info.szProj;

                if (_imgCompressPtr == IntPtr.Zero)
                {
                    CreateLCompress(ref _imgCompressPtr, CFormat, _dataType, _bands);
                }

                //----- 经纬范围,unfinished
                _minX = info.padf[0];
                _maxX = _minX + info.padf[1] * info.width;
                _minY = info.padf[3] + info.padf[5] * info.height;
                _maxY = info.padf[3];

                CurGeoRegion = new GeoRegion(MinX, MaxX, MinY, MaxY);

                if (MaxY > 91 || _minY < -91 || _maxX > 181 || MinX < -181 || (CurGeoRegion.LatitudeSpan < float.Epsilon && CurGeoRegion.MaxLat < float.Epsilon))
                {
                    if (ProjectDescription != "")
                    {
                        IsProjected = true;
                        double minx = 0, miny = 0, maxx = 0, maxy = 0;
                        GeoNormalImage.TranslateToGeoLatLon(ProjectDescription, _minX,
                                                            _maxY, ref minx, ref maxy);
                        GeoNormalImage.TranslateToGeoLatLon(ProjectDescription, _maxX,
                                                            _minY, ref maxx, ref miny); //--如果异常情况,或者投影参数错误,添加处理方法
                        CurGeoRegion = new GeoRegion(minx, maxx, miny, maxy);
                    }
                    else
                    {
                        _minX        = 0;
                        _maxX        = 1;
                        _minY        = 0;
                        _maxY        = (double)Height / Width;
                        CurGeoRegion = new GeoRegion(MinX, MaxX, MinY, MaxY);
                    }
                }

                _resX = (_maxX - _minX) / _width;
                _rexY = (_maxY - _minY) / _height;

                return("");
            }
        }