コード例 #1
0
        public string MutiRegionsClip(string file, GeoDo.RSS.Core.VectorDrawing.AOIContainerLayer aoiContainer, string savePath)
        {
            _aoiContainer = aoiContainer;

            using (IRasterDataProvider raster = GeoDataDriver.Open(file) as IRasterDataProvider)
            {
                _resolutionX      = raster.ResolutionX;
                _resolutionY      = raster.ResolutionY;
                _fileSize         = new Size(raster.Width, raster.Height);
                _fileEnvelope     = raster.CoordEnvelope;
                _activeSpatialRef = raster.SpatialRef;
                _activeCoordType  = raster.CoordType;
                raster.Dispose();
            }
            GeoDo.RSS.Core.DrawEngine.CoordEnvelope corEnvelope = null;
            corEnvelope = GetGeoRect();      //获取多个aoi的外接矩形
            evp.MaxX    = corEnvelope.MaxX;
            evp.MaxY    = corEnvelope.MaxY;
            evp.MinX    = corEnvelope.MinX;
            evp.MinY    = corEnvelope.MinY;
            BlockDefWithAOI        outEnvelope;
            Size                   size;
            List <BlockDefWithAOI> blockList = new List <BlockDefWithAOI>();

            GetArgs(out outEnvelope, out size);
            envelopes = new BlockDefWithAOI[] { outEnvelope };
            blockList.AddRange(envelopes);
            blockList[0].AOIIndexes = GetIndexes();     //获得多个aoi的Index
            OutDir = savePath;
            string[] put = RasterClipT(file, blockList.ToArray(), OutDir, "Cut");
            return(put[0]);
        }
コード例 #2
0
ファイル: frmImageClip.cs プロジェクト: windygu/hispeed
 private void btnInputFile_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog dlg = new OpenFileDialog())
     {
         dlg.Filter = "LDF files(*.ldf)|*.ldf";
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             txtInputFile.Text = dlg.FileName;
             string extname = Path.GetExtension(dlg.FileName).ToUpper();
             if (!string.IsNullOrEmpty(txtInputFile.Text))
             {
                 using (IRasterDataProvider raster = GeoDataDriver.Open(dlg.FileName) as IRasterDataProvider)
                 {
                     _resolutionX      = raster.ResolutionX;
                     _resolutionY      = raster.ResolutionY;
                     _fileSize         = new Size(raster.Width, raster.Height);
                     _fileEnvelope     = raster.CoordEnvelope;
                     _activeSpatialRef = raster.SpatialRef;
                     _activeCoordType  = raster.CoordType;
                 }
                 _outsizeRegion = new CoordEnvelope(_fileEnvelope.MinX, _fileEnvelope.MaxX, _fileEnvelope.MinY, _fileEnvelope.MaxY);
                 FillControlsValuesByFileArgs();
                 SetInputFilename(txtInputFile.Text);
             }
         }
     }
 }
コード例 #3
0
ファイル: ClipSNWParaData.cs プロジェクト: windygu/hispeed
        public IFileExtractResult ClipSNWResult(string filename, string area)
        {
            inputFileName = filename;
            using (IRasterDataProvider raster = GeoDataDriver.Open(filename) as IRasterDataProvider)
            {
                _resolutionX      = raster.ResolutionX;
                _resolutionY      = raster.ResolutionY;
                _fileSize         = new Size(raster.Width, raster.Height);
                _fileEnvelope     = raster.CoordEnvelope;
                _activeSpatialRef = raster.SpatialRef;
                _activeCoordType  = raster.CoordType;
                raster.Dispose();
            }
            _outsizeRegion = new CoordEnvelope(_fileEnvelope.MinX, _fileEnvelope.MaxX, _fileEnvelope.MinY, _fileEnvelope.MaxY);
            OutDir         = Path.GetDirectoryName(filename);

            string                   hdrfile = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename) + ".hdr");
            List <Feature>           fets    = new List <Feature>();
            IVectorFeatureDataReader dr      = null;

            if (area == "中国区")
            {
                url = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "数据引用\\基础矢量\\行政区划\\面\\中国边界.shp");
            }
            else
            {
                url = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "数据引用\\基础矢量\\行政区划\\面\\省级行政区域_面.shp");
            }
            dr = VectorDataReaderFactory.GetUniversalDataReader(url) as IVectorFeatureDataReader;
            Feature[] temp = null;
            temp = dr.FetchFeatures();
            fets.AddRange(temp);
            Feature[] features = null;
            features   = fets.ToArray();
            _blockName = area;
            int index = GetFeatureIndx(area);

            _vectorFeature = features[index];//_selectFeature
            //string fieldValue = _vectorFeature.GetFieldValue(fieldIndex);
            evp = GetMaskEnvelope(_vectorFeature.Geometry as ShapePolygon);
            BlockDefWithAOI        outEnvelope;
            Size                   size;
            List <BlockDefWithAOI> blockList = new List <BlockDefWithAOI>();

            GetArgs(out outEnvelope, out size, out OutDir, out filename);
            envelopes = new BlockDefWithAOI[] { outEnvelope };
            aoiIndex  = GetFeatureAOIIndex();
            blockList.AddRange(envelopes);
            blockList[0].AOIIndexes = aoiIndex;
            string[] put = RasterClipT(inputFileName, blockList.ToArray(), OutDir, "Cut");
            //put[0] = OutDir + put[0];
            string             getpath = Path.GetDirectoryName(put[0]);
            IFileExtractResult res     = new FileExtractResult("MWS", put[0], true);

            res.SetDispaly(false);
            return(res);
        }
コード例 #4
0
        public LogicalRasterDataProvider(string fileName, string[] fnames, object tag)
        {
            if (fnames == null || fnames.Length == 0)
            {
                throw new ArgumentNullException("fnames");
            }
            _tag          = tag;
            _fileNames    = new string[fnames.Length + 1];
            _fileNames[0] = fileName;
            int  i       = 1;
            bool isFirst = true;

            foreach (string fname in fnames)
            {
                _fileNames[i++] = fname;
                IRasterDataProvider prd = GeoDataDriver.Open(fname) as IRasterDataProvider;
                if (prd == null)
                {
                    continue;
                }
                if (isFirst)
                {
                    _dataType       = prd.DataType;
                    _width          = prd.Width;
                    _height         = prd.Height;
                    _coordEnvelope  = prd.CoordEnvelope;
                    _coordType      = prd.CoordType;
                    _spatialRef     = prd.SpatialRef;
                    _coordTransform = prd.CoordTransform;
                    isFirst         = false;
                }
                else
                {
                    if (_dataType != prd.DataType ||
                        _coordType != prd.CoordType ||
                        !CoordEnvelopeEquals(_coordEnvelope, prd.CoordEnvelope) ||
                        _coordType != prd.CoordType ||
                        _width != prd.Width ||
                        _height != prd.Height ||
                        !_spatialRef.IsSame(prd.SpatialRef)
                        )
                    {
                        continue;
                    }
                }
                for (int b = 0; b < prd.BandCount; b++)
                {
                    IRasterBand band = prd.GetRasterBand(b + 1);
                    band.Description = prd.fileName;
                    _rasterBands.Add(band);
                    band.BandNo = _rasterBands.Count;
                }
                _needDisposeObjects.Add(prd);
            }
        }
コード例 #5
0
        public LogicalRasterDataProvider(string fileName, IRasterBand[] rasterBands, object tag)
        {
            if (rasterBands == null || rasterBands.Length == 0)
            {
                throw new ArgumentNullException("rasterBands");
            }
            _tag       = tag;
            _fileNames = new string[] { fileName };
            List <IRasterBand> bs = new List <IRasterBand>();
            bool isFirst          = true;

            foreach (IRasterBand band in rasterBands)
            {
                if (isFirst)
                {
                    _dataType       = band.DataType;
                    _width          = band.Width;
                    _height         = band.Height;
                    _coordEnvelope  = band.CoordEnvelope;
                    _coordType      = band.RasterDataProvider.CoordType;
                    _spatialRef     = band.SpatialRef;
                    _coordTransform = band.CoordTransform;
                    isFirst         = false;
                }
                else
                {
                    if (_dataType != band.DataType ||
                        _width != band.Width ||
                        _height != band.Height)
                    {
                        continue;
                    }
                    if (_coordType != null && _coordType != band.RasterDataProvider.CoordType)
                    {
                        continue;
                    }
                    if (_coordEnvelope != null && !CoordEnvelopeEquals(_coordEnvelope, band.CoordEnvelope))
                    {
                        continue;
                    }
                    if (_spatialRef != null && !_spatialRef.IsSame(band.SpatialRef))
                    {
                        continue;
                    }
                }
                bs.Add(band);
            }
            _rasterBands.AddRange(bs);
        }
コード例 #6
0
 private void TrySetCoordTypeAndCoordEnvelope()
 {
     if (_coordEnvelope == null)
     {
         _coordEnvelope = new DF.CoordEnvelope(0, _width, 0, _height);
     }
     if (_spatialRef == null)
     {
         _coordType = enumCoordType.Raster;
     }
     else
     {
         if (_spatialRef.ProjectionCoordSystem == null)
         {
             _coordType = enumCoordType.GeoCoord;
         }
         else
         {
             _coordType = enumCoordType.PrjCoord;
         }
     }
 }
コード例 #7
0
ファイル: ExtractRectRegion.cs プロジェクト: windygu/hispeed
        public string ExractRect(string file, GeoDo.RSS.Core.VectorDrawing.AOIContainerLayer aoiContainer, string savePath, string regionName)
        {
            _aoiContainer = aoiContainer;
            using (IRasterDataProvider raster = GeoDataDriver.Open(file) as IRasterDataProvider)
            {
                _resolutionX      = raster.ResolutionX;
                _resolutionY      = raster.ResolutionY;
                _fileSize         = new Size(raster.Width, raster.Height);
                _fileEnvelope     = raster.CoordEnvelope;
                _activeSpatialRef = raster.SpatialRef;
                _activeCoordType  = raster.CoordType;
                raster.Dispose();
            }
            GeoDo.RSS.Core.DrawEngine.CoordEnvelope corEnvelope = null;
            corEnvelope = GetGeoRect();  //获取多个aoi的外接矩形
            evp.MaxX    = corEnvelope.MaxX + 2.0f;
            evp.MaxY    = corEnvelope.MaxY + 2.0f;
            evp.MinX    = corEnvelope.MinX - 2.0f;
            evp.MinY    = corEnvelope.MinY - 2.0f;
            string filename = ExtractFile(file, 0, evp, regionName, savePath);

            return(filename);
        }
コード例 #8
0
ファイル: frmImageClip.cs プロジェクト: windygu/hispeed
        private void SetSession(ISmartSession smartSession)
        {
            if (smartSession == null)
            {
                return;
            }
            ICanvasViewer canViewer = smartSession.SmartWindowManager.ActiveCanvasViewer;

            if (canViewer == null)
            {
                return;
            }
            IRasterDrawing      drawing      = canViewer.Canvas.PrimaryDrawObject as IRasterDrawing;
            IRasterDataProvider activeRaster = drawing.DataProvider;

            if (activeRaster == null)
            {
                return;
            }
            _resolutionX      = activeRaster.ResolutionX;
            _resolutionY      = activeRaster.ResolutionY;
            _fileSize         = new Size(activeRaster.Width, activeRaster.Height);
            _fileEnvelope     = activeRaster.CoordEnvelope;
            _activeSpatialRef = activeRaster.SpatialRef;
            _activeCoordType  = activeRaster.CoordType;
            IAOIProvider aoiProvider = canViewer.AOIProvider;

            if (aoiProvider == null)
            {
                return;
            }
            AOIItem[] aoiItems = aoiProvider.GetAOIItems();
            if (aoiItems != null && aoiItems.Length == 1)
            {
                txtRegionName.Text = string.IsNullOrEmpty(aoiItems[0].Name) ? "DXX" : aoiItems[0].Name;
                txtMask.Text       = _blockName;
            }
            GeoDo.RSS.Core.DrawEngine.CoordEnvelope corEnvelope = null;
            switch (_activeCoordType)
            {
            case enumCoordType.PrjCoord:
            {
                corEnvelope = aoiProvider.GetPrjRect();
                break;
            }

            case enumCoordType.GeoCoord:
            {
                corEnvelope = aoiProvider.GetGeoRect();
                break;
            }
            }
            if (corEnvelope == null)
            {
                _outsizeRegion = new CoordEnvelope(activeRaster.CoordEnvelope.MinX, activeRaster.CoordEnvelope.MaxX, activeRaster.CoordEnvelope.MinY, activeRaster.CoordEnvelope.MaxY);
            }
            else
            {
                _outsizeRegion = new CoordEnvelope(corEnvelope.MinX, corEnvelope.MaxX, corEnvelope.MinY, corEnvelope.MaxY);
            }
            FillControlsValuesByFileArgs();
            if (_outsizeRegion != null)
            {
                GeoRegionChanged(_outsizeRegion);
            }
            if (drawing != null)
            {
                IRasterDataProvider rdp = drawing.DataProvider;
                SetInputFilename(rdp.fileName);
            }
        }