示例#1
0
        public void DisposeSurface()
        {
            if (_rasterSurface == null)
            {
                return;
            }

            _msg.Debug("Disposing raster");

            _rasterSurface.Dispose();
            _rasterSurface = null;

            IWorkspace memoryWs = null;

            if (_memoryRasterDataset != null)
            {
                memoryWs = _memoryRasterDataset.Workspace;
                _memoryRasterDataset.Delete();
                ComUtils.ReleaseComObject(_memoryRasterDataset);
                _memoryRasterDataset = null;
            }

            if (memoryWs != null)
            {
                ((IDataset)memoryWs).Delete();
                ComUtils.ReleaseComObject(memoryWs);
            }
        }
示例#2
0
        public void DisposeSurface()
        {
            if (_tinSurface == null)
            {
                return;
            }

            _msg.Debug("Disposing tin");

            _tinSurface.Dispose();

            _tinSurface = null;
        }
示例#3
0
        private ISimpleSurface GetRasterSurface(
            [NotNull] IRaster sourceRaster,
            [NotNull] IEnvelope box,
            [CanBeNull] out IDataset memoryRasterDataset)
        {
            // Remark:
            // surface values outside 'raster'.envelope (but within 'box') are 0

            Assert.ArgumentNotNull(sourceRaster, nameof(sourceRaster));
            Assert.ArgumentNotNull(box, nameof(box));

            IRasterFunction        rasterFunction    = new ClipFunctionClass();
            IClipFunctionArguments functionArguments = new ClipFunctionArgumentsClass();

            functionArguments.Raster = sourceRaster;

            IEnvelope clipBox = GetClipBox(box, sourceRaster);

            functionArguments.Extent           = clipBox;
            functionArguments.ClippingGeometry = clipBox;
            functionArguments.ClippingType     = esriRasterClippingType.esriRasterClippingOutside;

            IFunctionRasterDataset functionRasterDataset = new FunctionRasterDataset();

            functionRasterDataset.Init(rasterFunction, functionArguments);
            functionRasterDataset.RasterInfo.NoData = (float)-9999;

            // unsicher, wie die memory verwaltung ist

            // zum sicherstellen der memory-verwaltung
            // --> inmemory raster erstellen
            var            save   = (ISaveAs2)functionRasterDataset;
            IWorkspaceName wsName = WorkspaceUtils.CreateInMemoryWorkspace("raster");
            var            ws     = (IWorkspace)((IName)wsName).Open();

            save.SaveAs("clipped", ws, "MEM");

            IRasterDataset rasterDataset = ((IRasterWorkspace2)ws).OpenRasterDataset("clipped");

            IRaster rasterData = rasterDataset.CreateDefaultRaster();

            // Problems and workarounds for raster(-mosaic) data in surfaces
            // -------------------------------------------------------------
            //
            // Extent completly within footprint of mosaic dataset: -> no NoDataValues -> no problems
            // Extent partly within footprint of mosaic dataset : -> double.NaN returned for values outside footprint -> no problems (TODO: verifiy)
            // Extent completely outside footprint of mosaic dataset, but within extent of mosaic data set:
            //    0-values returned for Null-raster values
            //    workaround: ((IRasterProps) rasterData).NoDataValue = (float)0; works, if ((IRasterProps) raster).NoDataValue = null and no Height == 0
            //    workaround to test: use CustomPixelFilter (see https://github.com/Esri/arcobjects-sdk-community-samples/tree/master/Net/Raster/CustomNodataFilter/CSharp
            // Extent completely outside extent of mosaic dataset
            //    0-values returned for Null-raster values, rasterData.Height = 1, rasterData.Width = 1
            //    workaround 1: use custom RasterSurface class.
            //    workaround 2: ((IRasterProps) rasterData).NoDataValue = (float)0; works, if ((IRasterProps) raster).NoDataValue = null and no Height == 0

            memoryRasterDataset = (IDataset)rasterDataset;

            ISimpleSurface rasterSurface = RasterReference.CreateSurface(rasterData);

            return(rasterSurface);
        }