博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【036】◀▶ 自己写的程序源代码
阅读量:6847 次
发布时间:2019-06-26

本文共 5077 字,大约阅读时间需要 16 分钟。

●·● 目录:

A1 …………

A2 …………
A3 …………
A4 …………
A5 …………
A6 …………

---------------------------------------------------------------------------------------------------------

Visual Studio 2008 + ArcGIS Engine 9.3

---------------------------------------------------------------------------------------------------------

            ╔════════╗

╠════╣     ╠══════════════════════════════════════════════════╣
            ╚════════╝

点击下载:   标注:实现了基本 GIS 功能,部分截图如下!

 

全局:

鹰眼:

自定义工具对话框:

面符号:

线符号:

点符号:

右键菜单:

图层属性表:

--------------------------------------------------------------------------------------------------------- 

Visual Studio 2010 + ArcGIS Engine 10.0

--------------------------------------------------------------------------------------------------------- 

            ╔════════╗

╠════╣     ╠══════════════════════════════════════════════════╣
            ╚════════╝

点击下载:   标注:实现新建shapefile文件,部分截图如下!

 

属性截图如下:

实现步骤:

  • 新建工作空间工厂 IWorkspaceFactory!(矢量数据)
  • 新建要素工作空间 IFeatureWorkspace!  <IWorkspaceFactory.OpenFromFile()>
  • 若指定的文件名存在了,则将其内部的数据删除!  <IDataset.Delete()>
  • 为要素集新建字段 IFields!
  • 新建要素集 IFeatureClass!  <IFeatureWorkspace.CreateFeatureClass()>
  • 新建要素 IFeature!  <IFeatureClass.CreateFeature()>

代码如下:

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using ESRI.ArcGIS.Carto;using System.IO;using ESRI.ArcGIS.Geodatabase;using ESRI.ArcGIS.DataSourcesFile;using ESRI.ArcGIS.Geometry;namespace NewPoints{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        ///         /// 保存文件的完整路径        ///         string saveFullPath = string.Empty;        private void button1_Click(object sender, EventArgs e)        {            SaveFileDialog sfd = new SaveFileDialog();            sfd.InitialDirectory = Directory.GetCurrentDirectory();            sfd.Filter = "Shp文件(*.shp)|*.shp";            if (sfd.ShowDialog() == DialogResult.OK)            {                saveFullPath = sfd.FileName;            }            textBox1.Text = saveFullPath;        }        private void button2_Click(object sender, EventArgs e)        {            IFeatureLayer pFeatureLayer = CreateShpFromPoint(saveFullPath);            pFeatureLayer.Name = "Point";            axMapControl1.Map.AddLayer(pFeatureLayer);        }        private IFeatureLayer CreateShpFromPoint(string outfileNamePath)        {            string folder = System.IO.Path.GetDirectoryName(outfileNamePath);            string file = System.IO.Path.GetFileName(outfileNamePath);            IWorkspaceFactory pWSF = new ShapefileWorkspaceFactoryClass();            IFeatureWorkspace pFWS = pWSF.OpenFromFile(folder, 0) as IFeatureWorkspace;            if (File.Exists(outfileNamePath))            {                IFeatureClass featureClass = pFWS.OpenFeatureClass(file);                IDataset pDataset = featureClass as IDataset;                pDataset.Delete();            }            IFields pFields = new FieldsClass();            IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;            IField pField = new FieldClass();            IFieldEdit pFieldEdit = pField as IFieldEdit;            pFieldEdit.Name_2 = "Shape";            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;            IGeometryDef pGeometryDef = new GeometryDefClass();            IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit;            pGeometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;            pFieldEdit.GeometryDef_2 = pGeometryDef;            pFieldsEdit.AddField(pField);            pField = new FieldClass();            pFieldEdit = pField as IFieldEdit;            pFieldEdit.Name_2 = "X";            pFieldEdit.Length_2 = 20;            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;            pFieldsEdit.AddField(pField);            pField = new FieldClass();            pFieldEdit = pField as IFieldEdit;            pFieldEdit.Name_2 = "Y";            pFieldEdit.Length_2 = 20;            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;            pFieldsEdit.AddField(pField);            IFeatureClass pFeatureClass = pFWS.CreateFeatureClass(file, pFields, null, null, esriFeatureType.esriFTSimple, "Shape", "");                        for (int i = 0; i < 100;i+=10 )            {                for (int j = 0; j < 100;j+=10 )                {                    IPoint pPoint = new PointClass();                    pPoint.PutCoords(i, j);                    IFeature pFeature = pFeatureClass.CreateFeature();                    pFeature.Shape = pPoint as IPoint;                    pFeature.set_Value(pFeature.Fields.FindField("X"), i.ToString());                    pFeature.set_Value(pFeature.Fields.FindField("Y"), j.ToString());                    pFeature.Store();                }            }            IFeatureLayer pFeatureLayer = new FeatureLayerClass();            pFeatureLayer.FeatureClass = pFeatureClass;            return pFeatureLayer;        }    }}

 

 

转载于:https://www.cnblogs.com/alex-bn-lee/archive/2012/04/26/2472772.html

你可能感兴趣的文章
Tomcat
查看>>
try catch 怎么写?
查看>>
iOS学习笔记(十五)——数据库操作(SQLite)
查看>>
Android spinner 样式及其使用详解
查看>>
ftps加密服务器
查看>>
[置顶] 批处理命令
查看>>
谈谈不换行空格
查看>>
ubuntu 13.04 nginx.conf 配置详解
查看>>
Android调用系统的打电话和发短信界面(1.将消息内容带过去2.实现群发)
查看>>
如何在内网安装compass
查看>>
TF-IDF理解及其Java实现
查看>>
使用升级版的 Bootstrap typeahead v1.2.2
查看>>
项目中自增长编码生成方法
查看>>
认清Linux中标准输入和标准输出的双重含义
查看>>
[家里蹲大学数学杂志]第270期张恭庆编《泛函分析讲义》2.5节以前的习题参考解答...
查看>>
Smack 广播
查看>>
[物理学与PDEs]第2章习题5 正应力的平均值
查看>>
DIV元素水平和垂直居中
查看>>
ASP.NET MVC 5– 使用Wijmo MVC 5模板1分钟创建应用
查看>>
JVM体系结构之三:方法区之1
查看>>