Beispiel #1
0
        public static IGeoImage GeoOpen(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }

            if (System.IO.Path.GetExtension(path) == ".rst")
            {
                try
                {
                    GeoImage img = new GeoImage(path);
                    img.Tag = path;
                    return(img);
                }
                catch
                {
                    return(null);
                }
            }
            else
            {
                GeoNormalImage img = new GeoNormalImage();
                if ("" != img.Open(path))
                {
                    img.Dispose();
                    return(null);
                }
                img.Tag = path;
                return(img);
            }
        }
Beispiel #2
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("");
            }
        }