当前位置: 首页>>代码示例>>C#>>正文


C# Geoprocessor.Validate方法代码示例

本文整理汇总了C#中Geoprocessor.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# Geoprocessor.Validate方法的具体用法?C# Geoprocessor.Validate怎么用?C# Geoprocessor.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Geoprocessor的用法示例。


在下文中一共展示了Geoprocessor.Validate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ClipByLayer

        /// <summary>
        /// 两图层进行裁剪运算
        /// </summary>
        /// <param name="inputLayer">被裁剪图层</param>
        /// <param name="clipLayer">裁剪图层</param>
        /// <param name="outputFullPath">输出图层完整路径</param>
        public void ClipByLayer(ILayer inputLayer, ILayer clipLayer, string outputFullPath)
        {
            string inputPath = GetLayerPath(inputLayer);
            string clipPath = GetLayerPath(clipLayer);

            Clip clipTool = new Clip();
            clipTool.in_features = inputPath;
            clipTool.clip_features = clipPath;
            clipTool.out_feature_class = outputFullPath;

            Geoprocessor processor = new Geoprocessor();
            IGPProcess process = null;
            processor.OverwriteOutput = true;
            process = clipTool;
            processor.Validate(process, true);
            processor.Execute(process, null);

            FileInfo fi = new FileInfo(outputFullPath);
            string pathDir = fi.Directory.FullName;
            string name = fi.Name;
            IWorkspaceFactory wsf = new ShapefileWorkspaceFactoryClass();
            IFeatureWorkspace fws = wsf.OpenFromFile(pathDir, 0) as IFeatureWorkspace;
            IFeatureClass featCls = fws.OpenFeatureClass(name);
            IFeatureLayer layer = new FeatureLayerClass();
            layer.FeatureClass = featCls;
            layer.Name = featCls.AliasName;
            m_mapControl.Map.AddLayer(layer as ILayer);
        }
开发者ID:chinasio,项目名称:minegis,代码行数:34,代码来源:ClipLayer.cs

示例2: btnOK_Click


//.........这里部分代码省略.........
            pDatasetName = pFeatureClassName as IDatasetName;
            pDatasetName.Name = openpath.Name;  //"Intersect_Result";
            pDatasetName.WorkspaceName = pNewWSName;

            double tol = 0.1;

            IBasicGeoprocessor pBGP;
            pBGP = new BasicGeoprocessorClass();
            pBGP.SpatialReference = m_mapControl.Map.SpatialReference;
            IFeatureClass pOutputFeatureClass;
            IFeatureLayer pOutputFeatLayer;
            pOutputFeatLayer = new FeatureLayerClass();
            int n = listBox1.SelectedIndex;

            if (n>= 0 && n< 3)
            {
                switch (n)
                {
                    case(0):
                        pOutputFeatureClass = pBGP.Intersect(pInputTable, false, pOverlayTable, false, tol, pFeatureClassName);
                        pOutputFeatLayer.FeatureClass = pOutputFeatureClass;
                        pOutputFeatLayer.Name = pOutputFeatureClass.AliasName;
                        m_mapControl.Map.AddLayer(pOutputFeatLayer);
                        break;
                    case(1):
                        pOutputFeatureClass = pBGP.Union(pInputTable, false, pOverlayTable, false, tol, pFeatureClassName);
                        pOutputFeatLayer.FeatureClass = pOutputFeatureClass;
                        pOutputFeatLayer.Name = pOutputFeatureClass.AliasName;
                        m_mapControl.Map.AddLayer(pOutputFeatLayer);
                        break;
                    case(2):
                        pOutputFeatureClass = pBGP.Clip(pInputTable, false, pOverlayTable, false, tol, pFeatureClassName);
                        pOutputFeatLayer.FeatureClass = pOutputFeatureClass;
                        pOutputFeatLayer.Name = pOutputFeatureClass.AliasName;
                        m_mapControl.Map.AddLayer(pOutputFeatLayer);
                        break;
                }
            }*/
            //Geoprocessor processor = new Geoprocessor();
            IFeatureLayer inputLyr = m_mapControl.Map.get_Layer(comboBox1.SelectedIndex) as IFeatureLayer;
            IDataLayer2 dataLy = inputLyr as IDataLayer2;
            IDatasetName inputdsName = dataLy.DataSourceName as IDatasetName;
            IWorkspaceName inputws = inputdsName.WorkspaceName as IWorkspaceName;
            string input=inputws.PathName+"\\"+inputLyr.Name;

            IFeatureLayer overlayLyr = m_mapControl.Map.get_Layer(comboBox2.SelectedIndex) as IFeatureLayer;
            IDataLayer2 dataOverlay = overlayLyr as IDataLayer2;
            IDatasetName overlayDsName = dataOverlay.DataSourceName as IDatasetName;
            IWorkspaceName overlayWs = overlayDsName.WorkspaceName;
            string overlay =overlayWs.PathName+"\\"+overlayLyr.Name;

            string output =textBox1.Text;

            Geoprocessor processor = new Geoprocessor();
            processor.OverwriteOutput = true;
            IGPProcess process=null;
            switch (listBox1.SelectedIndex)
            {
                case 0:
                    Intersect intersect = new Intersect();
                    intersect.in_features = "'" + input + "'" + ";" + "'" + overlay + "'";
                    intersect.out_feature_class =output;
                    intersect.output_type = "INPUT";
                    intersect.join_attributes = "ALL";
                    //intersect.cluster_tolerance=0.1;
                    process = intersect;
                    break;
                case 1:
                    Union union = new Union();
                    union.in_features = "'" + input+"'" +";"+"'"+overlay+ "'";
                    union.out_feature_class = @""+output;
                    union.join_attributes = "ALL";
                    //union.cluster_tolerance = 0.1;
                    process = union;
                    break;
                case 2:
                    Erase erase = new Erase();
                    erase.in_features = "'" + input + "'";
                    erase.erase_features = "'" + overlay + "'";
                    erase.out_feature_class = output;
                    //erase.cluster_tolerance = 0.1;
                    process = erase;
                    break;

            }
            processor.Validate(process, true);
            processor.Execute(process, null);
            this.Dispose();

            FileInfo fi = new FileInfo(textBox1.Text);
            string pathDir = fi.Directory.FullName;
            string name = fi.Name;
            IWorkspaceFactory wsf = new ShapefileWorkspaceFactoryClass();
            IFeatureWorkspace fws = wsf.OpenFromFile(pathDir, 0) as IFeatureWorkspace;
            IFeatureClass featCls = fws.OpenFeatureClass(name);
            IFeatureLayer layer = new FeatureLayerClass();
            layer.FeatureClass = featCls;
            layer.Name = featCls.AliasName;
            m_mapControl.Map.AddLayer(layer as ILayer);
        }
开发者ID:chinasio,项目名称:minegis,代码行数:101,代码来源:OverLayerForm.cs

示例3: ClipRasterByLayer

        /// <summary>
        /// 图层切割栅格数据
        /// </summary>
        /// <param name="rasterLayer">栅格数据图层</param>
        /// <param name="clipLayer">切割适量图层</param>
        /// <param name="outputFullPath">切割栅格完整路径</param>
        public void ClipRasterByLayer(ILayer rasterLayer, ILayer clipLayer, string outputFullPath)
        {
            string rasterPath = GetLayerPath(rasterLayer);
            string clipPath = GetLayerPath(clipLayer);

            ExtractByMask clipTool = new ExtractByMask();
            clipTool.in_raster = rasterPath;
            clipTool.in_mask_data = clipPath;
            clipTool.out_raster = outputFullPath;

            Geoprocessor processor = new Geoprocessor();
            IGPProcess process = null;
            processor.OverwriteOutput = true;
            process = clipTool;
            processor.Validate(process, true);
            processor.Execute(process, null);

            DirectoryInfo di = new DirectoryInfo(outputFullPath);
            string rasterDir = di.Parent.FullName;
            string name = di.Name;
            IWorkspaceFactory rasterWorkspaceFactory = new RasterWorkspaceFactoryClass();
            IRasterWorkspace rasterWorkspace = rasterWorkspaceFactory.OpenFromFile(rasterDir, 0) as IRasterWorkspace;
            IRasterDataset rasterDataset = rasterWorkspace.OpenRasterDataset(name);
            IRasterLayer rasterLyr = new RasterLayerClass();
            rasterLyr.CreateFromDataset(rasterDataset);
            m_mapControl.Map.AddLayer(rasterLyr as ILayer);
        }
开发者ID:chinasio,项目名称:minegis,代码行数:33,代码来源:ClipLayer.cs


注:本文中的Geoprocessor.Validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。