首页 / 浏览问题 / 组件GIS / 问题详情
iobjectsnet 怎么加载镶嵌数据集
3EXP 2020年11月05日
请问 iobjectsnet 怎么加载镶嵌数据集,感谢

1个回答

你是说如何将镶嵌数据集添加到地图还是如何新建镶嵌数据集,

internal  DatasetMosaic CreateMosaic(PrjCoordSys prj, string[] files, string datasetname)
        {
            if (m_workspace.Datasources.Count == 0)
            {
                MessageBox.Show("请先打开一个数据源");
                return null;
            }
            Datasource datasource = m_workspace.Datasources[0];

            if (datasource.Datasets.Contains(datasetname))
            {
                bool issuccessdelete = false;
                try
                {
                    issuccessdelete = datasource.Datasets.Delete(datasetname);
                }
                catch (Exception ex)
                {
                    bool aa = datasource.Datasets.Contains(datasetname);
                    if (!aa)
                    {
                        MessageBox.Show("当前数据源内已经不存在数据集:" + datasetname);
                    }
                }
            }
            DatasetMosaic datasetMosaic = datasource.Datasets.CreateMosaic(datasetname, prj);

            if (datasetMosaic == null)
            {

                return null;
            }
            //对镶嵌数据集的轮廓表扩充属性;
            bool AA = File.Exists(files[0]);
            datasetMosaic.AddFiles(files);
          
            String path = Path.GetDirectoryName(files[0]);
            String overviewpath = path + "\\overview";
            //构建概视图
            String datasetMosaicOverviewPath = overviewpath + "\\" + datasetname + "\\";
            if (!System.IO.File.Exists(datasetMosaicOverviewPath))
            {
                DirectoryInfo directoryInfo = Directory.CreateDirectory(datasetMosaicOverviewPath);
            }
            bool buildOverview = datasetMosaic.BuildOverview(datasetMosaicOverviewPath, 5120, 5120, 3, true, 0);
            return datasetMosaic;
        }

创建镶嵌数据集可以参考上面的代码;

添加到地图可以参考下面的代码:

   public static void AddDatasetMosaicToMAP(DatasetMosaic Dataset, MapControl mapControl, bool isEnsureVisible, Loading loadingform)
        {
            try
            {
                if (Dataset != null)
                {
                    mapControl.Map.Workspace = Dataset.Datasource.Workspace;
                    LayerMosaicGroup layerMosaicGroup = mapControl.Map.Layers.AddMosaicGroup(Dataset, true);
                    LayerMosaic layerMosaic = layerMosaicGroup.MosaicLayer;
                    LayerSettingImage layersetting = layerMosaic.SettingImage as LayerSettingImage;
                    layersetting.DisplayBandIndexes = new int[3] { 2, 1, 0 };
                    if (Dataset.BandCount > 1)
                    {
                        layersetting.DisplayMode = ImageDisplayMode.Composite;
                    }
                    else
                    {
                        layersetting.DisplayMode = ImageDisplayMode.Stretched;
                    }
                    layersetting.DisplayColorSpace = ColorSpaceType.RGB;
                    layersetting.ImageInterpolationMode = ImageInterpolationMode.NearestNeighbor;

                    Dataset.BuildStatistics();

                    ImageStretchOption option = new ImageStretchOption();
                    if (Dataset.PixelFormat == PixelFormat.UBit8)
                    {
                        option.StretchType = ImageStretchType.None;
                    }
                    else
                    {
                        option.StretchType = ImageStretchType.StandardDeviation;
                    }
                    option.StandardDeviationStretchFactor = 1;

                    layersetting.ImageStretchOption = option;
                    layersetting.BackgroundColor = Color.FromArgb(0, 0, 0);
                    //layersetting.SpecialValueColor = Color.FromArgb(65535, 65535, 55537);
                    //layersetting.IsSpecialValueTransparent = true;
                    layersetting.IsBackgroundTransparent = true;
                    if (layerMosaicGroup.FootprintLayer != null)
                    {
                        layerMosaicGroup.FootprintLayer.IsVisible = false;
                        layerMosaicGroup.BoundaryLayer.IsVisible = false;
                    }
                    layerMosaicGroup[1].IsVisible = false;
                    if (isEnsureVisible)
                    {
                        mapControl.Map.EnsureVisible(layerMosaic);
                    }
                    mapControl.Map.Refresh();

                    if (loadingform != null)
                    {
                        loadingform.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                if (loadingform != null)
                {
                    loadingform.Close();
                }
              
            }
        }
4,620EXP 2020年11月05日
...