• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FeatureLayerClass类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中FeatureLayerClass的典型用法代码示例。如果您正苦于以下问题:C# FeatureLayerClass类的具体用法?C# FeatureLayerClass怎么用?C# FeatureLayerClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FeatureLayerClass类属于命名空间,在下文中一共展示了FeatureLayerClass类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: InMemoryWorkspaceFactoryClass

        private void 添加点型图层ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //创建要素类
            #region 创建新的内存工作空间
            IWorkspaceFactory pWSF = new InMemoryWorkspaceFactoryClass();
            IWorkspaceName pWSName = pWSF.Create("", "Temp", null, 0);

            IName pName = (IName)pWSName;
            IWorkspace pMemoryWS = (IWorkspace)pName.Open();
            #endregion

            IField oField = new FieldClass();
            IFields oFields = new FieldsClass();
            IFieldsEdit oFieldsEdit = null;
            IFieldEdit oFieldEdit = null;
            IFeatureClass oFeatureClass = null;
            IFeatureLayer oFeatureLayer = null;

            oFieldsEdit = oFields as IFieldsEdit;
            oFieldEdit = oField as IFieldEdit;
            oFieldEdit.Name_2 = "OBJECTID";
            oFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID;
            oFieldEdit.IsNullable_2 = false;
            oFieldEdit.Required_2 = false;
            oFieldsEdit.AddField(oField);

            oField = new FieldClass();
            oFieldEdit = oField as IFieldEdit;
            IGeometryDef pGeoDef = new GeometryDefClass();
            IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit)pGeoDef;
            pGeoDefEdit.AvgNumPoints_2 = 5;
            pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
            pGeoDefEdit.GridCount_2 = 1;
            pGeoDefEdit.HasM_2 = false;
            pGeoDefEdit.HasZ_2 = false;
            pGeoDefEdit.SpatialReference_2 = axMapControl1.SpatialReference;
            oFieldEdit.Name_2 = "SHAPE";
            oFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
            oFieldEdit.GeometryDef_2 = pGeoDef;
            oFieldEdit.IsNullable_2 = true;
            oFieldEdit.Required_2 = true;
            oFieldsEdit.AddField(oField);

            oField = new FieldClass();
            oFieldEdit = oField as IFieldEdit;
            oFieldEdit.Name_2 = "Code";
            oFieldEdit.Type_2 = esriFieldType.esriFieldTypeSmallInteger;
            //oFieldEdit.Length = 10;
            oFieldEdit.IsNullable_2 = true;
            oFieldsEdit.AddField(oField);
            //创建要素类
            oFeatureClass = (pMemoryWS as IFeatureWorkspace).CreateFeatureClass("Temp", oFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", "");
            oFeatureLayer = new FeatureLayerClass();
            oFeatureLayer.Name = "PointLayer";
            oFeatureLayer.FeatureClass = oFeatureClass;
            //创建唯一值符号化对象


            IUniqueValueRenderer pURender = new UniqueValueRendererClass();
            pURender.FieldCount = 1;
            pURender.set_Field(0, "Code");
            pURender.UseDefaultSymbol = false;
            //创建SimpleMarkerSymbolClass对象
            ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();
            //创建RgbColorClass对象为pSimpleMarkerSymbol设置颜色
            IRgbColor pRgbColor = new RgbColorClass();
            pRgbColor.Red = 255;
            pSimpleMarkerSymbol.Color = pRgbColor as IColor;
            //设置pSimpleMarkerSymbol对象的符号类型,选择钻石
            pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond;
            //设置pSimpleMarkerSymbol对象大小,设置为5
            pSimpleMarkerSymbol.Size = 5;
            //显示外框线
            pSimpleMarkerSymbol.Outline = true;
            //为外框线设置颜色
            IRgbColor pLineRgbColor = new RgbColorClass();
            pLineRgbColor.Green = 255;
            pSimpleMarkerSymbol.OutlineColor = pLineRgbColor as IColor;
            //设置外框线的宽度
            pSimpleMarkerSymbol.OutlineSize = 1; 

            //半透明颜色

 


            pURender.AddValue("1", "", pSimpleMarkerSymbol as ISymbol);

            //唯一值符号化内存图层
            (oFeatureLayer as IGeoFeatureLayer).Renderer = pURender as IFeatureRenderer;
            ILayerEffects pLyrEffect = oFeatureLayer as ILayerEffects;
            //透明度
            pLyrEffect.Transparency = 0;


            oFeatureLayer.Visible = true;

            this.axMapControl1.AddLayer(oFeatureLayer,axMapControl1.LayerCount);
            insertpoint = true;
        }
开发者ID:hijushen,项目名称:WindowDemo,代码行数:100,代码来源:MainForm.cs


示例2: OnClick

        protected override void OnClick()
        {
            string tablePath = Path.Combine(DataPath, @"File-Based\MajorCities.csv");
            string tableName = Path.GetFileName(tablePath);

            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesFile.TextFileWorkspaceFactory");
            IWorkspaceFactory workspaceFactory = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
            IWorkspace workspace = workspaceFactory.OpenFromFile(Path.GetDirectoryName(tablePath), 0);

            ITable table = ((IFeatureWorkspace) workspace).OpenTable(tableName);
            ISpatialReference sRef = CreateSpatialReference(esriSRGeoCSType.esriSRGeoCS_WGS1984);

            IFeatureClass featureClass = CreateXYEventFeature(table, "POINT_X", "POINT_y", sRef);
            IFeatureLayer featureLayer = new FeatureLayerClass
            {
                FeatureClass = featureClass,
                Name = "CSV XY Event Table"
            };

            IFeatureLayerSourcePageExtension sourcePageExtension = new XYDataSourcePageExtensionClass();
            ((ILayerExtensions) featureLayer).AddExtension(sourcePageExtension);

            ArcMap.Document.FocusMap.AddLayer(featureLayer);
            ArcMap.Document.UpdateContents();
        }
开发者ID:ApexGIS,项目名称:developer-support,代码行数:25,代码来源:DisplayXYData.cs


示例3: FindMyFeatureLayer

 public static IFeatureLayer FindMyFeatureLayer(IMap inMap, string inName)
 {
     string isfound = "false";
     ILayer tempLayer;
     IFeatureLayer goodLayer = new FeatureLayerClass();
     for (int i = 0; i < inMap.LayerCount; i++)
     {
         tempLayer = inMap.get_Layer(i);
         if (tempLayer is IFeatureLayer)
         {
             if (tempLayer.Name == inName)
             {
                 isfound = "true";
                 goodLayer = tempLayer as IFeatureLayer;
             }
         }
     }
     //duplicate name in the map.? How we deal with it
     if (isfound == "true")
     {
         return goodLayer;
     }
     else
     {
         return null;
     }
 }
开发者ID:jiang-ming,项目名称:aerialphotoviewer,代码行数:27,代码来源:Helper.cs


示例4: 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


示例5: CreateBlobber

        public static Blobber CreateBlobber()
        {
            BlobberRepository repository = new BlobberRepository();

            repository.StartEdit();

            Blobber b = repository.Create();
            b.BlobberId = BLOBBER_ID;

            IFeatureLayer layer = new FeatureLayerClass();
            layer.Name = BLOBBER_VALUE_1;

            IPropertySet properties = new PropertySetClass();
            properties.SetProperty("VALUE1", BLOBBER_VALUE_1);
            properties.SetProperty("VALUE2", BLOBBER_VALUE_2);
            properties.SetProperty("VALUE3", BLOBBER_VALUE_3);

            b.Properties = properties;

            b.Store();

            repository.StopEdit(true);

            return b;
        }
开发者ID:george-silva,项目名称:esri-active-record,代码行数:25,代码来源:CarExampleTests.cs


示例6: OnClick

        protected override void OnClick()
        {
            //
            //  TODO: Sample code showing how to access button host
            //
            // ArcMap.Application.CurrentTool = null;

               // Nohe did this
            //IDocument doc = ArcMap.Application.Document;
            //IMxDocument mxDoc = doc as IMxDocument;
            //int value = ArcMap.Application.hWnd;

            //IActiveView av = mxDoc.ActiveView as IActiveView;
            //IMap map = mxDoc.FocusMap as IMap;

               //frddie
            IMap map = ArcMap.Document.ActiveView.FocusMap;
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");

               IWorkspaceFactory wsf = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
               //nohe
            //IWorkspaceFactory wsf = new FileGDBWorkspaceFactory();
            IFeatureWorkspace ws = wsf.OpenFromFile(@"C:\Users\alex7370\Documents\GitHub\MyAddins\AddingAFeature\features.gdb", 0) as IFeatureWorkspace;
            IFeatureLayer featureLayer = new FeatureLayerClass { FeatureClass = ws.OpenFeatureClass("pointFeature")};
            featureLayer.Name = featureLayer.FeatureClass.AliasName;

            map.AddLayer(featureLayer);
            ArcMap.Document.ActiveView.Refresh();
        }
开发者ID:nohe427,项目名称:MyAddins,代码行数:29,代码来源:addFeatureButton.cs


示例7: btnGO_Click

        private void btnGO_Click(object sender, EventArgs e)
        {
            string fileName;
            string shpFile;
            int startX, endX;
            string shpDir;
            try
            {
                if (bDataPath == true)
                {
                    fileName=txtOutputData.Text;
                    shpDir =fileName.Substring(0, fileName.LastIndexOf("\\"));
                    startX=fileName.LastIndexOf("\\");
                    endX=fileName.Length;
                    shpFile=fileName.Substring(startX+1,endX-startX-1);
                }
                else
                {
                    shpDir=txtOutputData.Text;
                    shpFile="��ֵ��";
                }
                if (m_pRasterLyr != null)
                {
                    double dInterval=Convert.ToDouble(txtConInterval.Text);
                    double dBaseLine=Convert.ToDouble(txtBaseLine.Text);
                    object objBaseLine=dBaseLine;
                    ISurfaceOp pRasterSurfaceOp = new RasterSurfaceOpClass();
                    IRaster pInRaster = m_pRasterLyr.Raster;
                    IFeatureClass  pOutFClass= pRasterSurfaceOp.Contour(pInRaster as IGeoDataset , dInterval, ref objBaseLine) as IFeatureClass ;
                    //2. QI to IDataset
                    IDataset pFDS=pOutFClass as IDataset ;
                    //3. Get a shapefile workspace
                    IWorkspaceFactory pSWF=new  ShapefileWorkspaceFactoryClass();
                    IFeatureWorkspace pFWS=pSWF.OpenFromFile(shpDir,0) as IFeatureWorkspace ;
                    //4. Copy contour output to a new shapefile
                    IWorkspace pWS = pFWS as IWorkspace;
                    if (pWS.Exists() == true)
                        Utility.DelFeatureFile(shpDir, shpFile + ".shp");
                    pFDS.Copy(shpFile,pFWS as IWorkspace );
                    IFeatureLayer pFeatLyr = new FeatureLayerClass();
                    pFeatLyr.FeatureClass = pOutFClass;
                    pFeatLyr.Name = pOutFClass.AliasName;
                    pFeatLyr.Visible = true;
                    pMainFrm.getMapControl().AddLayer(pFeatLyr, 0);
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }
        }
开发者ID:chinasio,项目名称:Control,代码行数:53,代码来源:frmContour.cs


示例8: addFeatureClassToMap

        /// <summary> Add feature class to active View and then zoom to its extend </summary>
        /// <param name="view">the current active view</param>
        /// <param name="inFeatureClass">the feature class to add</param>
        /// <param name="zoomTo">zoom to loaded feature class</param>
        /// <returns>the created layer</returns>
        public static IFeatureLayer addFeatureClassToMap(IActiveView view, IFeatureClass inFeatureClass, bool zoomTo = false)
        {
            IFeatureLayer featureLayer = new FeatureLayerClass();
            featureLayer.FeatureClass = inFeatureClass;
            featureLayer.Name = inFeatureClass.AliasName;
            featureLayer.Visible = true;
            view.FocusMap.AddLayer(featureLayer);

            if(zoomTo) view.Extent = featureLayer.AreaOfInterest;

            return featureLayer;
        }
开发者ID:geopunt,项目名称:geopunt4arcgis,代码行数:17,代码来源:geopuntHelper.cs


示例9: btnApply_Click

 private void btnApply_Click(object sender, EventArgs e)
 {
     if (isSelectNode == true)
     {
         IFeatureClass pFeatCls = m_pFeatureWorkspace.OpenFeatureClass(m_strSelFeatLayer);
         IFeatureLayer pFeatLayer = new FeatureLayerClass();
         pFeatLayer.FeatureClass = pFeatCls;
         pFeatLayer.Visible = true;
         pFeatLayer.Name = pFeatCls.AliasName;
         AxMapControl axMap = pMainFrm.getMapControl();
         axMap.AddLayer(pFeatLayer);
         axMap.Refresh();
     }
 }
开发者ID:chinasio,项目名称:Control,代码行数:14,代码来源:frmAddSDEData.cs


示例10: init

        public void init(int programID, AxMapControl mc, Intersect.ProgramStepUserControl.OnFinish of, MainWindow mw)
        {
            inited = true;

            if (program == null)
                program = new Program();
            program.id = programID;
            program.select();

            if (project == null)
                project = new Project();
            project.id = program.projectID;
            project.select();

            NetSizeUserControl.init(program.id);
            ConditionUserControl.init(program.id);

            mapControl = mc;
            onFinish = of;
            mainWindow = mw;

            mapControlMouseDown = null;

            //在初始化时就要对valid进行判断.
            Thread t = new Thread(delegate()
            {
                System.Threading.Thread.Sleep(500);
                Dispatcher.BeginInvoke((ThreadStart)delegate()
                {
                    if (isValid())
                    {
                        valid = true;
                        onFinish(true);
                        IFeatureClass resultFeatureClass;
                        if ((resultFeatureClass = GisUtil.getFeatureClass(System.IO.Path.GetDirectoryName(project.path), "评价结果.shp")) != null)
                        {
                            IFeatureLayer resultFeatureLayer = new FeatureLayerClass();
                            resultFeatureLayer.FeatureClass = resultFeatureClass;
                            mapControl.AddLayer(resultFeatureLayer);
                        }
                        else
                        {
                            SiteSelector siteSelector = new SiteSelector(mapControl, program.id);
                            siteSelector.startSelectSite();
                        }
                    }
                });
            });
            t.Start();
        }
开发者ID:Leooonard,项目名称:CGXM,代码行数:50,代码来源:ConfigUserControl.xaml.cs


示例11: MainForm_Load

        private void MainForm_Load(object sender, EventArgs e)
        {        
            m_mapControl = (IMapControl3) axMapControl1.Object;

            //relative file path to the sample data from EXE location
            string filePath = @"..\..\..\data\USAMajorHighways";
 
            //Add Lakes layer
            IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass();
            IFeatureWorkspace workspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(filePath, axMapControl1.hWnd);
            IFeatureLayer featureLayer = new FeatureLayerClass();
            featureLayer.Name = "Lakes";
            featureLayer.Visible = true;
            featureLayer.FeatureClass = workspace.OpenFeatureClass("us_lakes");

            #region create a SimplerRenderer
            IRgbColor color = new RgbColorClass();
            color.Red = 190;
            color.Green = 232;
            color.Blue = 255;

            ISimpleFillSymbol sym = new SimpleFillSymbolClass();
            sym.Color = color;

            ISimpleRenderer renderer = new SimpleRendererClass();
            renderer.Symbol = sym as ISymbol;
            #endregion

            ((IGeoFeatureLayer)featureLayer).Renderer = renderer as IFeatureRenderer;
            axMapControl1.Map.AddLayer((ILayer)featureLayer);

            //Add Highways layer
            featureLayer = new FeatureLayerClass();
            featureLayer.Name = "Highways";
            featureLayer.Visible = true;
            featureLayer.FeatureClass = workspace.OpenFeatureClass("usa_major_highways");
            axMapControl1.Map.AddLayer((ILayer)featureLayer);

            //******** Important *************
            //store a reference to this form (Mainform) using the EditHelper class
            EditHelper.TheMainForm = this;
            EditHelper.IsEditorFormOpen = false;

            //add the EditCmd command to the toolbar
            axEditorToolbar.AddItem("esriControls.ControlsOpenDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axEditorToolbar.AddItem("esriControls.ControlsSaveAsDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axEditorToolbar.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axEditorToolbar.AddItem(new EditCmd(), 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
             
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:50,代码来源:MainForm.cs


示例12: ThematicView2_Load

        void ThematicView2_Load(object sender, EventArgs e)
        {
            SdeConnection conn = new SdeConnection();
            ISdeConnectionInfo sdeConn = (ISdeConnectionInfo)conn;
            IFeatureWorkspace fw = (IFeatureWorkspace)sdeConn.Workspace;
            IFeatureClass fcThua = fw.OpenFeatureClass("sde.thixa_thua");
            IFeatureLayer flThua = new FeatureLayerClass();
            flThua.FeatureClass = fcThua;
            ILayer layerThua = (ILayer)flThua;
            IFeatureClass fcDuong = fw.OpenFeatureClass("sde.thixa_duong");
            IFeatureLayer flDuong = new FeatureLayerClass();
            flDuong.FeatureClass = fcDuong;
            ILayer layerDuong = (ILayer)flDuong;
            layerDuong.Name = fcDuong.AliasName;
            layerThua.Name = fcThua.AliasName;

            _mapController.AddLayer(layerDuong);
            _mapController.AddLayer(layerThua);
        }
开发者ID:truonghinh,项目名称:TnX,代码行数:19,代码来源:ThematicView2.cs


示例13: showMap

        private void showMap()
        {
            SdeConnection conn = new SdeConnection();
            ISdeConnectionInfo sdeConn = (ISdeConnectionInfo)conn;
            IFeatureWorkspace fw = (IFeatureWorkspace)sdeConn.Workspace;
            IFeatureClass fcHem = fw.OpenFeatureClass("sde.thixa_hem");
            IFeatureLayer flHem = new FeatureLayerClass();
            flHem.FeatureClass = fcHem;
            ILayer layerThua = (ILayer)flHem;
            IFeatureClass fcDuong = fw.OpenFeatureClass("sde.thixa_duong");
            IFeatureLayer flDuong = new FeatureLayerClass();
            flDuong.FeatureClass = fcDuong;
            ILayer layerDuong = (ILayer)flDuong;
            layerDuong.Name = fcDuong.AliasName;
            layerThua.Name = fcHem.AliasName;

            _mapController.AddLayer(flHem);
            _mapController.AddLayer(flDuong);
        }
开发者ID:truonghinh,项目名称:TnX,代码行数:19,代码来源:FrmHem2.cs


示例14: AddData_CAD

        public static void AddData_CAD(AxMapControl axMapControl1)
        {
            IWorkspaceFactory pWorkspaceFactory;
            IFeatureWorkspace pFeatureWorkspace;
            IFeatureLayer pFeatureLayer;
            IFeatureDataset pFeatureDataset;
            //获取当前路径和文件名
            OpenFileDialog dlg = new OpenFileDialog();
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string strFullPath = dlg.FileName;
                if (strFullPath == "") return;
                int Index = strFullPath.LastIndexOf("//");
                string filePath = strFullPath.Substring(0, Index);
                string fileName = strFullPath.Substring(Index + 1);
                //打开CAD数据集
                pWorkspaceFactory = new CadWorkspaceFactoryClass();
                pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(filePath, 0);
                //打开一个要素集
                pFeatureDataset = pFeatureWorkspace.OpenFeatureDataset(fileName);
                //IFeaturClassContainer可以管理IFeatureDataset中的每个要素类
                IFeatureClassContainer pFeatClassContainer = (IFeatureClassContainer)pFeatureDataset;
                //对CAD文件中的要素进行遍历处理
                for (int i = 0; i < pFeatClassContainer.ClassCount - 1; i++)
                {
                    IFeatureClass pFeatClass = pFeatClassContainer.get_Class(i);
                    if (pFeatClass.FeatureType == esriFeatureType.esriFTCoverageAnnotation)
                        //如果是注记,则添加注记层
                        pFeatureLayer = new CadAnnotationLayerClass();
                    else
                        //如果是点、线、面,则添加要素层
                        pFeatureLayer = new FeatureLayerClass();
                    pFeatureLayer.Name = pFeatClass.AliasName;
                    pFeatureLayer.FeatureClass = pFeatClass;
                    axMapControl1.Map.AddLayer(pFeatureLayer);
                    axMapControl1.ActiveView.Refresh();
                }

                ILayer layer = axMapControl1.get_Layer(0);
                axMapControl1.Extent = layer.AreaOfInterest;
            }
        }
开发者ID:AgentWord,项目名称:SiPing,代码行数:42,代码来源:GISTools.cs


示例15: OracleQueryLayer

        public IFeatureLayer OracleQueryLayer()
        {
            // 创建SqlWorkspaceFactory的对象
            Type pFactoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SqlWorkspaceFactory");

            IWorkspaceFactory pWorkspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(pFactoryType);

            // 构造连接数据库的参数
            IPropertySet pConnectionProps = new PropertySetClass();
            pConnectionProps.SetProperty("dbclient", "Oracle11g");
            pConnectionProps.SetProperty("serverinstance", "esri");
            pConnectionProps.SetProperty("authentication_mode", "DBMS");
            pConnectionProps.SetProperty("user", "scott");
            pConnectionProps.SetProperty("password", "arcgis");

            // 打开工作空间
            IWorkspace workspace = pWorkspaceFactory.Open(pConnectionProps, 0);

            ISqlWorkspace pSQLWorkspace = workspace as ISqlWorkspace;

            //获取数据库中的所有表的名称

               //IStringArray pStringArray= pSQLWorkspace.GetTables();

               //for (int i = 0; i < pStringArray.Count; i++)
               //{
               //    MessageBox.Show(pStringArray.get_Element(i));

               //}

               // 构造过滤条件 SELECT * FROM PointQueryLayer

               IQueryDescription queryDescription = pSQLWorkspace.GetQueryDescription("SELECT * FROM TEST");

               ITable pTable = pSQLWorkspace.OpenQueryClass("QueryLayerTest", queryDescription);

               IFeatureLayer pFeatureLayer = new FeatureLayerClass();

               pFeatureLayer.FeatureClass = pTable as IFeatureClass;

               return pFeatureLayer;
        }
开发者ID:esrichina,项目名称:Engine10DevApplication,代码行数:42,代码来源:QuerylayerTest.cs


示例16: OnClick

        protected override void OnClick()
        {
            try
            {
                string shpFilePath = string.Format(@"C:\temp\contour datas");
                string shpFileName = "contour2.shp"; // height data

                IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ShapefileWorkspaceFactoryClass();
                IWorkspace workspace = workspaceFactory.OpenFromFile(shpFilePath, 0);
                IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
                IFeatureClass pFeatureClass = featureWorkspace.OpenFeatureClass(shpFileName);
                IFeatureLayer pFeatureLayer = new FeatureLayerClass();
                pFeatureLayer.FeatureClass = pFeatureClass;
                IQueryFilter pQueryFilter = new QueryFilterClass();
                pQueryFilter.WhereClause = "";

                IEnvelope pEnv = pFeatureLayer.AreaOfInterest;
                IGeoDataset pGDS = (IGeoDataset)pFeatureLayer.FeatureClass;
                ISpatialReference pSR = pGDS.SpatialReference;
                IGeometry pGeom = pEnv;
                pGeom.Project(pSR);
                ITinEdit pTinEdit = new TinClass();
                pTinEdit.InitNew(pEnv);
                IFields pFields = pFeatureClass.Fields;
                IField pFiled = pFields.get_Field(pFields.FindField("HSL"));
                object Missing = Type.Missing;
                esriTinSurfaceType pTinSurface = esriTinSurfaceType.esriTinHardLine;
                pTinEdit.AddFromFeatureClass(pFeatureClass, pQueryFilter, pFiled, pFiled, pTinSurface, ref Missing);
                string outputFolderPath = @"C:\temp\Output\";
                string tinFolderName = "tin_data";
                pTinEdit.SaveAs(outputFolderPath + tinFolderName, ref Missing);
                MessageBox.Show("end");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            ArcMap.Application.CurrentTool = null;
        }
开发者ID:ApexGIS,项目名称:developer-support,代码行数:40,代码来源:_CreateTIN.cs


示例17: OnClick

        public override void OnClick()
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Title = "打开CAD文件";
            openFileDialog1.Filter = "CAD图形文件(*.dwg)|*.DWG";
            if (openFileDialog1.ShowDialog() == DialogResult.OK && m_hookHelper.Hook is IMapControlDefault)
            {
                FileInfo fileinfo = new FileInfo(openFileDialog1.FileName);
                string path = fileinfo.DirectoryName;
                string name = fileinfo.Name;
                IWorkspaceFactory cadWorkSpaceFactory = new CadWorkspaceFactoryClass();
                IFeatureWorkspace workspace = cadWorkSpaceFactory.OpenFromFile(path, 0) as IFeatureWorkspace;
                IFeatureDataset featDataset = workspace.OpenFeatureDataset(name);
                IFeatureClassContainer featClassContainer = featDataset as IFeatureClassContainer;
                IFeatureClass featClass;
                IFeatureLayer featLayer;

                for (int i = 0; i < featClassContainer.ClassCount; i++)
                {
                    featClass = featClassContainer.get_Class(i);
                    if (featClass.FeatureType == esriFeatureType.esriFTCoverageAnnotation)
                    {
                        //标注类型,必须设置为单位的标注图层
                        featLayer = new CadAnnotationLayerClass();
                    }
                    else
                    {
                        //点线面类型
                        featLayer = new FeatureLayerClass();
                    }

                    featLayer.Name = featClass.AliasName;
                    featLayer.FeatureClass = featClass;
                    ((IMapControlDefault)m_hookHelper.Hook).Map.AddLayer((ILayer)featLayer);
                }
            }
        }
开发者ID:chinasio,项目名称:minegis,代码行数:37,代码来源:AddCADToFeatures.cs


示例18: AddDataToMapAsLayer

        /// <summary>
        /// add raster or featureclass to map as layer
        /// </summary>
        public static void AddDataToMapAsLayer(IGeoDataset RasterDSOrFeatureClass, string LayerName)
        {
            ILayer ThisLayer = null;

            if (RasterDSOrFeatureClass is IRasterDataset)
            {
                //add rasterdataset as raster layer
                ThisLayer = new RasterLayerClass() as ILayer;
                ((IRasterLayer)ThisLayer).CreateFromDataset(RasterDSOrFeatureClass as IRasterDataset);
            }

            if (RasterDSOrFeatureClass is IFeatureClass)
            {
                //add feature class to a feature layer
                ThisLayer = new FeatureLayerClass() as ILayer;
                ((IFeatureLayer)ThisLayer).FeatureClass = RasterDSOrFeatureClass as IFeatureClass;
            }

            ThisLayer.Name = LayerName;

            //Add the raster layer to ArcMap
            NPSGlobal.Instance.Document.FocusMap.AddLayer(ThisLayer);
            NPSGlobal.Instance.Document.ActiveView.Refresh();
        }
开发者ID:regan-sarwas,项目名称:NPSTransectTool,代码行数:27,代码来源:Utility.cs


示例19: SdeConnection

        void IGMap.ZoomToSelectMa(string layerName, string fieldName, params object[] key)
        {
            bool hasLayer = false;
            int c = this._mapHook.LayerCount;
            if (c == 0)
            {
                return;
            }
            IFeatureClass fc = null;
            IFeatureLayer fl = null;
            SdeConnection conn = new SdeConnection();
            ISdeConnectionInfo sdeConn = (ISdeConnectionInfo)conn;
            IFeatureWorkspace fw = (IFeatureWorkspace)sdeConn.Workspace;
            string name = "";
            string queryString = QueryStringBuilder.CreateOrQueryString(fieldName, key);
            for (int i = 0; i < c; i++)
            {
                fl = (IFeatureLayer)this._mapHook.get_Layer(i);

                name = fl.FeatureClass.AliasName;
                //MessageBox.Show(string.Format("line 260 GMap name={0} - layername={1}", name,layerName));
                if (Compare.Compare2SdeLayerName(name, layerName) == 0)
                {
                    hasLayer = true;
                    //MessageBox.Show(string.Format("line 261 GMap layername={0}", name));
                    fc = fl.FeatureClass;
                    break;
                }
            }
            if (!hasLayer)
            {
                try
                {
                    fc = fw.OpenFeatureClass(layerName);
                }
                catch (Exception)
                {
                    return;
                }
                fl = new FeatureLayerClass();
                fl.FeatureClass = fc;
                fl.Name = fc.AliasName;
                ILayer layer = (ILayer)fl;
                this._mapHook.AddLayer(layer, 0);
            }
            if (fl == null)
            {
                //MessageBox.Show(string.Format("line 285 GMap"));
                return;
            }
            IQueryFilter qrf = new QueryFilterClass();
            qrf.WhereClause = queryString;
            //MessageBox.Show(string.Format("line 290 GMap, qrf={0}",queryString));
            ISelectionSet sls = fc.Select(qrf, esriSelectionType.esriSelectionTypeHybrid, esriSelectionOption.esriSelectionOptionNormal, sdeConn.Workspace);
            IFeatureSelection fts = (IFeatureSelection)fl;
            fts.SelectionSet = sls;
            //MessageBox.Show(string.Format("selection count={0}", sls.Count));
            _mapHook.ActiveView.Refresh();
            ((IGMap)this).ZoomToSelected();
        }
开发者ID:truonghinh,项目名称:TnX,代码行数:60,代码来源:GMap.cs


示例20: calculate

        protected override void calculate()
        {
            #region khoi dau
            base.calculate();
            CalculationEventArg evt = new CalculationEventArg();
            //evt.Type = EnumTypeOfLoopCalculation.InListCalculators;
            evt.CurrentIndexCalculator = this._index;
            evt.Log = string.Format("**********  Bắt đầu tính cho thửa nông nghiệp ở vị trí {0} ********", vitri);
            onCalculating(evt);
            #endregion

            //[thaydoi] - them cac khai bao can thiet
            //************************************
            #region khai bao cac bien
            //Lay connection info hien tai
            SdeConnection conn = new SdeConnection();
            ISdeConnectionInfo sdeConn = conn as ISdeConnectionInfo;
            IWorkspaceEdit wspEdit = (IWorkspaceEdit)sdeConn.Workspace;
            this._fcName = new TnFeatureClassName(sdeConn.Workspace);
            this._tblName = new TnTableName(sdeConn.Workspace);
            IFeatureWorkspace fw = (IFeatureWorkspace)sdeConn.Workspace;
            ICopyFeatures copyTool = new DataManager(sdeConn.Workspace,sdeConn.Environment);

            #region thua
            string thuaName = string.Format("{0}_{1}", DataNameTemplate.Thua, this._currentConfig.NamApDung);
            _fcName.FC_THUA.NAME = thuaName;
            _fcName.FC_THUA.InitIndex();
            IFeatureClass thuaFeatureClass = fw.OpenFeatureClass(thuaName);
            IFeatureLayer thuaFeatureLayer = new FeatureLayerClass();
            thuaFeatureLayer.FeatureClass = thuaFeatureClass;
            IFeatureSelection thuaFeatureSelection;
            #endregion
            #region xa
            IFeatureClass xaFeatureClass = fw.OpenFeatureClass(DataNameTemplate.Ranh_Xa_Poly);
            IFeatureLayer xaFeatureLayer = new FeatureLayerClass();
            xaFeatureLayer.FeatureClass = xaFeatureClass;
            IFeatureSelection xaFeatureSelection;
            #endregion
            #region duong
            IFeatureClass duongFeatureClass = fw.OpenFeatureClass(DataNameTemplate.Duong);
            IFeatureLayer duongFeatureLayer = new FeatureLayerClass();
            duongFeatureLayer.FeatureClass = duongFeatureClass;
            IFeatureSelection duongFeatureSelection;
            //_fcName.FC_DUONG.InitIndex();
            #endregion

            #region thua gia dat
            string tgd = string.Format("{0}_{1}", DataNameTemplate.Thua_Gia_Dat_Draft, this._currentConfig.NamApDung);
            _fcName.FC_THUA_GIADAT_DRAFT.NAME = tgd;
            _fcName.FC_THUA_GIADAT_DRAFT.InitIndex();
            //_fcName.FC_THUA_GIADAT_DRAFT.NAME = tgd;
            //_fcName.FC_THUA_GIADAT_DRAFT.InitIndex();
            IFeatureClass tgdFeatureClass=null;
            try
            {
                tgdFeatureClass = fw.OpenFeatureClass(tgd);
            }
            catch (Exception exc)
            {
                evt.Log = string.Format("Không tìm thấy lớp dữ liệu: {0}", tgd);
                onCalculating(evt);
                onFinished(evt);
                return;
            }
            ITable tblThuaGiaDat = (ITable)tgdFeatureClass;
            IFeatureLayer tgdFeatureLayer = new FeatureLayerClass();
            ISDETableEditor sdeTblTgdEditor = new SDETable(tblThuaGiaDat, sdeConn.Workspace);
            #endregion

            #region gia dat duong
            //string gdd = string.Format("{0}_{1}", DataNameTemplate.Gia_Dat_Duong, this._currentConfig.NamApDung);
            //_tblName.GIA_DAT_DUONG.NAME = gdd;
            //_tblName.GIA_DAT_DUONG.InitIndex();
            #endregion

            #region ten duong
            ITable tblTenDuong;
            try
            {
                tblTenDuong = fw.OpenTable(DataNameTemplate.Ten_Duong);
            }
            catch (Exception exc)
            {
                evt.Log = string.Format("Không tìm thấy lớp dữ liệu: {0}", DataNameTemplate.Ten_Duong);
                onCalculating(evt);
                onFinished(evt);
                return;
            }
            #endregion

            #region loai dat
            ITable tblLoaiDat;
            try
            {
                tblLoaiDat = fw.OpenTable(DataNameTemplate.Loai_Dat);
            }
            catch (Exception exc)
            {
                evt.Log = string.Format("Không tìm thấy lớp dữ liệu: {0}", DataNameTemplate.Loai_Dat);
                onCalculating(evt);
//.........这里部分代码省略.........


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FeatureType类代码示例发布时间:2022-05-24
下一篇:
C# FeatureLayer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap