(转载)ArcGIS Engine中各种点的创建方法

2023-11-05

点(Point)代表了一个0纬的具有X、Y坐标的几何对象。点是没有任何形状的,可用于描述点类型的要素,而且Geometry中的任何类型都是用点来产生的。

   构成几何形状的顶点存在3种可以选择的属性,即Z、M和ID。Z值在大多数情况下都可用于表示一个点的Z坐标,还可以将Z值作为一个点的辅助值来使用;M即度量值,可以一个路径对象的线性度量,用于交通工程中一条公路的不同点的位置;ID值即作为一个点的唯一标识值。

  点击(Multipoint)是具有相同属性的点的集合,用于构建高级几何对象、几何对象动态模拟等。

  IPoint接口定义了Point对象的属性和方法,点(Point)可以使用PutCoods方法创建,也可以使用IConstructPoint借口来创建。IConstructPoint接口提供了10种创建点的方法,下面分别介绍:

   (1) ConstructAlong 沿线创建法:基于一个曲线上的起始点对象,通过给定距离、比例和扩展类型,沿着曲线创建一个新点。如果距离比曲线的长度长,那么点将沿着它的切线生成。其扩展参数如下:

   EsriNoExtension:没有扩展。在这种方式下构建点将始终在输入曲线上。如果距离小于0,则构建点在曲线的起点;如果输入距离大于曲线的长度,则构建点在曲线的终点。

   EsriExtendTangentAtFrom:起点切线。在这种方式下,如果输入距离小于0,则构建点在曲线起点的切线且与曲线反方向的距离位置上。

  EsriExtendTangentAtTo:终点切线。在这种方式下,如果距离大于曲线,则构建点放在曲线终点的切线且与曲线反方向的距离位置上。

  EsriExtendEmbeddedAtFrom:与起点切线类似,但使用嵌入几何不是切线。

  EsriExtendEmbeddedAtTo:与终点切线类似,但使用嵌入几何不是切线。

   EsriExtendEmbedded:在这种方式下,根据输入距离自动使用esriExtendEmbeddedAtFrom或esriExtendEmbeddedAtTo创建构建点。

 EsriExtendTranGents:在这种方式下,根据输入距离自动使用esriExtendTangentAtFrom或esriExtendTangentAtTo创建构建点。

(2)ConstructAngleBisector 角平分线构建法:这种方法使用3个点,即起点(FromPoint)、经由点(Through Point)和终止点(ToPoint)。该方法通过平分3点形成的夹角,并设置一个距离在平分线上寻找一个点。

 (3)ConstructAngleDistance 构造角度距离法:通过一个给定点和一个相对点的绝对角度和距离构建一个点。

(4)ConstructAngleIntersection构建角度交点法:通过给定的两个点和两个角度产生两条线,然后在两条射线的焦点产生了一个焦点。

(5)ConstructDeflection构造偏转角度法:通过给一条基准线、一个偏转角度和一个距离,沿着线的偏转角度的射线方向一给定距离为之构建一个点。

(6)ConstructDeflectionIntersection构造偏转角交点法:通过指定一条线段作为基线,从该线段的起点和终点的偏转角度引出连个射线,然后再两条射线的焦点构建一个点。该方法的bRightSide指定偏转角在线段的左边或右边。

(7)ConstructOffset构造偏移点法:该方法通过指定一条曲线,沿着曲线的距离或比例进行水平偏移。可以设置参数Offset的值,如果值为正,则该点向右偏移;如果值为负,则向左偏移。其扩展参数如下:

   EsriNoExtension:没有扩展。在这种方式下构建点将始终再输入曲线上。如果输入距离小于0,则构建点在区县的起点;如果输入距离大于曲线的长度,则构建点在曲线的终点。

  EsriExtendTangentAtFrom:起点切线。在这种方式下,如果距离小于0,这构建点在曲线起点的切线且与·曲线同方向的距离位置上。

  EsriExtendTangentAfTo:终点切线。在这种方式下,输入距离大于曲线长度,则构建点放在曲线终点的切线且与曲线同方向的距离位置上。

  EsriExtendEmbeddedAtFrom:与起点切线类似,但使用嵌入几何不是切线。

  EsriExtendEmbeddedAtTo:与终点切线类似,但是用嵌入几何不是切线。

   EsriExtendEmbedded:在这种方式下,根据输入距离自动使用esriExtendEmbeddedAtFrom或esriExtendEmbeddedAtTo。

   EsriExtendTangents:在这种方式下,根据输入距离自动使用esriExtendTangentAtFrom或esriExtendTangentAtTo创建构建点。

   EsriExtendAtFrom:在这种方下,包括esriExtendTangentAtFrom和esriExtendEmbeddedAtFrom。

   EsriExtendAtTo:在这种方式下,包括了esriExtendTrangentAtTo和esriExtendEmbeddedAtTo。

   EsriExtendEmbeddedAtTo:在这种方式下,包括了esriExtendTangentAtTo和EsriExtendEmbeddedAtTo.

(8) ConstructParallel 构造平行线上的点:该方法是给一条路径Path、一个参考点Point以及一个距离或比率,在平行线上构建一个点。其扩展参数同ConstructOffset。

(9)ConstructPerpendicular  构造垂直线上点法:通过给定一条路径Path、一个参考点Point以及一个距离,在参考点与路径垂直的方向上,在给定距离为之构建一个点。

(10)ConstructThreePointResection  后方交会定点法:该方法即测量学中的后方交会定点法,即构建点对3个已知点进行观测,得到两个角度,然后确定构建点的位置。

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.Geometry;
namespace WindowsFormsApplication11
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void axLicenseControl1_Enter(object sender, EventArgs e)
        {
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            loadMapDocument();
        }
        //加载地图文档
        private void loadMapDocument()
        {
            OpenFileDialog openFileDialog;
            openFileDialog = new OpenFileDialog();
            openFileDialog.Title = "打开地图文档";
            openFileDialog.Filter = "map document(*.mxd)|*.mxd";
            openFileDialog.ShowDialog();
            string filepath = openFileDialog.FileName;
            if (axMapControl1.CheckMxFile(filepath))
            {
                axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerArrowHourglass;
                axMapControl1.LoadMxFile(filepath);
          
                axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerDefault;
            }
            else
            {
                MessageBox.Show(filepath + "不是有效的地图文档");
            }
        }
        //获取线实体
        private ESRI.ArcGIS.Geodatabase.IFeature getPolylineFeature(string layerName)
        {
            int i = 0;
            ESRI.ArcGIS.Carto.ILayer layer = null;
            for ( i = 0; i < axMapControl1.LayerCount; i++)
            {
                layer = axMapControl1.Map.get_Layer(i);
                if (layer.Name.ToLower() == layerName)
                    break;
            }
            ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = layer as ESRI.ArcGIS.Carto.IFeatureLayer;
            ESRI.ArcGIS.Geodatabase.IFeatureClass featureclass = featureLayer.FeatureClass;
            ESRI.ArcGIS.Geodatabase.IQueryFilter queryfilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
            queryfilter.WhereClause = "";
            ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = featureclass.Search(queryfilter, true);
            ESRI.ArcGIS.Geodatabase.IFeature feature= featureCursor.NextFeature();
            if (feature != null)
            {
                return feature;
            }
            return null;
        }
        //获取所有的实体点
        private System.Collections.ArrayList getPointFeature(string layerName)
        {
            int i = 0;
            ESRI.ArcGIS.Carto.ILayer layer = null;
            for ( i = 0; i < axMapControl1.LayerCount; i++)
            {
                layer = axMapControl1.Map.get_Layer(i);
                if (layer.Name.ToLower() == layerName)
                {
                    break;
                }
            }
            ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = layer as ESRI.ArcGIS.Carto.IFeatureLayer;
            ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureLayer.FeatureClass;
            ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
            queryFilter.WhereClause = "";
            ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = featureClass.Search(queryFilter, true);
            ESRI.ArcGIS.Geodatabase.IFeature feature = featureCursor.NextFeature();
            System.Collections.ArrayList features = new System.Collections.ArrayList();
            while (feature != null)
            {
                features.Add(feature as object);
                feature = featureCursor.NextFeature();
            }
            return features;
        }
        //添加实体点
        private void addFeature(string layername, ESRI.ArcGIS.Geometry.IPoint point)
        {
            int i = 0;
            ESRI.ArcGIS.Carto.ILayer layer = null;
            for ( i = 0; i < axMapControl1.LayerCount; i++)
            {
                layer = axMapControl1.Map.get_Layer(i);
                if (layer.Name.ToLower() == layername)
                {
                    break;
                }
            }
            ESRI.ArcGIS.Carto.IFeatureLayer featureLayer=layer as ESRI.ArcGIS.Carto.IFeatureLayer;
            ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureLayer.FeatureClass;
            ESRI.ArcGIS.Geodatabase.IDataset dataset = (ESRI.ArcGIS.Geodatabase.IDataset)featureClass;
            ESRI.ArcGIS.Geodatabase.IWorkspace workspace = dataset.Workspace;
            ESRI.ArcGIS.Geodatabase.IWorkspaceEdit workspaceEdit = (ESRI.ArcGIS.Geodatabase.IWorkspaceEdit)workspace;
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();
            ESRI.ArcGIS.Geodatabase.IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();
            ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = featureClass.Insert(true);
            featureBuffer.Shape = point;
            object featureOID = featureCursor.InsertFeature(featureBuffer);
            featureCursor.Flush();
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
        }
        //构造偏移点法
        private void button7_Click(object sender, EventArgs e)
        {
            IPoint[] points = new IPoint[4];
            for (int i = 0; i < 4; i++)
                points[i] = new PointClass();
            points[0].PutCoords(0, 0);
            points[1].PutCoords(10, 0);
            points[2].PutCoords(20, 0);
            points[3].PutCoords(30, 0);
            IPointCollection polyline = new PolylineClass();
            IGeometryBridge geometryBridge = new GeometryEnvironmentClass();
            geometryBridge.AddPoints(polyline as IPointCollection4, ref points);
            IConstructPoint constructPointRight = new PointClass();
            IConstructPoint constructionPointLeft = new PointClass();
            constructPointRight.ConstructOffset(polyline as ICurve, esriSegmentExtension.esriNoExtension, 15, false, 5);
            IPoint outPoint1 = constructPointRight as IPoint;
            constructionPointLeft.ConstructOffset(polyline as ICurve, esriSegmentExtension.esriNoExtension, 1, false, -5);
            IPoint outPoint2 = constructionPointLeft as IPoint;
            addFeature("point", points[0]);
            addFeature("point", points[1]);
            addFeature("point", points[2]);
            addFeature("point", points[3]);
            addFeature("point", outPoint1);
            addFeature("point", outPoint2);
            axMapControl1.Refresh();
 
        }
        private void button11_Click(object sender, EventArgs e)
        {
          
            ESRI.ArcGIS.Carto.ILayer layer = null;
           
                layer = axMapControl1.Map.get_Layer(0);
             
            ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = layer as ESRI.ArcGIS.Carto.IFeatureLayer;
            ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureLayer.FeatureClass;
            ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
            queryFilter.WhereClause = "";
            ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = featureClass.Search(queryFilter, true);
            ESRI.ArcGIS.Geodatabase.IFeature feature = featureCursor.NextFeature();
           // System.Collections.ArrayList features = new System.Collections.ArrayList();
            while (feature != null)
            {
                textBox1.Text = "搜索到" + feature.get_Value(25).ToString();
                Search(layer, feature.get_Value(0).ToString(), feature.get_Value(1) as ESRI.ArcGIS.Geometry.IPoint, feature.get_Value(25).ToString());
                feature = featureCursor.NextFeature();
            }
             
        }
         private void Search( ESRI.ArcGIS.Carto.ILayer layer,string FID,  ESRI.ArcGIS.Geometry.IPoint point,string name )
        {
     
         
            ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = layer as ESRI.ArcGIS.Carto.IFeatureLayer;
            ESRI.ArcGIS.Geodatabase.IFeatureClass featureClass = featureLayer.FeatureClass;
            ESRI.ArcGIS.Geodatabase.IQueryFilter queryFilter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
            queryFilter.WhereClause = "";
            ESRI.ArcGIS.Geodatabase.IFeatureCursor featureCursor = featureClass.Search(queryFilter, true);
            ESRI.ArcGIS.Geodatabase.IFeature feature = featureCursor.NextFeature();
           // System.Collections.ArrayList features = new System.Collections.ArrayList();
            while (feature != null)
            {
               // features.Add(feature as object);
                if((feature.get_Value(0).ToString()!=FID))
                {
                    ESRI.ArcGIS.Geometry.IPoint pt=feature.get_Value(1) as ESRI.ArcGIS.Geometry.IPoint;
                    if(point.X==pt.X&& point.Y==pt.Y)
                    {
                         if(feature.get_Value(25).ToString()==name)
                        {
                             textBox1.Text = "删除" + feature.get_Value(0).ToString();
                             feature.Delete();
                            break;
                        }
                    }
                }
                feature = featureCursor.NextFeature();
               
                //feature.get_Value(0).ToString()
              
            }
             
        }
        //沿线创建点
         private void button1_Click(object sender, EventArgs e)
         {
             ESRI.ArcGIS.Geodatabase.IFeature polylineFeature;
             polylineFeature = getPolylineFeature("polyline");
             if (polylineFeature != null)
             {
                 ESRI.ArcGIS.Geometry.ICurve cure = polylineFeature.Shape as ESRI.ArcGIS.Geometry.ICurve;
                 ESRI.ArcGIS.Geometry.IConstructPoint constructPoint = new ESRI.ArcGIS.Geometry.PointClass();
                 constructPoint.ConstructAlong(cure, ESRI.ArcGIS.Geometry.esriSegmentExtension.esriNoExtension, 10, true);
                 ESRI.ArcGIS.Geometry.IPoint point1 = constructPoint as ESRI.ArcGIS.Geometry.IPoint;
                 constructPoint = new ESRI.ArcGIS.Geometry.PointClass();
                 constructPoint.ConstructAlong(cure, ESRI.ArcGIS.Geometry.esriSegmentExtension.esriNoExtension, 20, false);
                 ESRI.ArcGIS.Geometry.IPoint point2 = constructPoint as ESRI.ArcGIS.Geometry.IPoint;
                 addFeature("point", point1);
                 addFeature("point", point2);
             }
         }
        //角平分线创建法
         private void button2_Click(object sender, EventArgs e)
         {
             ESRI.ArcGIS.Geometry.IPoint point1, point2, point3, point4;
             point1 = new ESRI.ArcGIS.Geometry.PointClass();
             point2 = new ESRI.ArcGIS.Geometry.PointClass();
             point3 = new ESRI.ArcGIS.Geometry.PointClass();
             point1.PutCoords(0, 0);
             point2.PutCoords(0, 20);
             point3.PutCoords(20, 20);
             ESRI.ArcGIS.Geometry.IConstructPoint constructPoint = new ESRI.ArcGIS.Geometry.PointClass();
             constructPoint.ConstructAngleBisector(point1, point2, point3, 50, true);
             point4 = constructPoint as ESRI.ArcGIS.Geometry.IPoint;
             addFeature("point", point1);
             addFeature("point", point2);
             addFeature("point", point3);
             addFeature("point", point4);
             axMapControl1.Refresh();

         }
//构造角度距离法
         private void button3_Click(object sender, EventArgs e)
         {
             ESRI.ArcGIS.Geometry.IPoint point1, point2;
             point1 = new ESRI.ArcGIS.Geometry.PointClass();
             point1.PutCoords(0, 0);
             double distance = 20;
             double angle = 60;
             ESRI.ArcGIS.Geometry.IConstructPoint constructPoint = new ESRI.ArcGIS.Geometry.PointClass();
             double angleRad = angle * 2 * Math.PI / 360;
             constructPoint.ConstructAngleDistance(point1, angleRad, distance);
             point2 = constructPoint as ESRI.ArcGIS.Geometry.IPoint;
             addFeature("point", point1);
             addFeature("point", point2);
             axMapControl1.Refresh();
         }
//构造角度交点法
         private void button4_Click(object sender, EventArgs e)
         {
             ESRI.ArcGIS.Geometry.IPoint point1, point2;
             point1 = new ESRI.ArcGIS.Geometry.PointClass();
             point2 = new ESRI.ArcGIS.Geometry.PointClass();
             point1.PutCoords(0, 0);
             point2.PutCoords(10, 0);
             double angleRed1 = 45 * 2 * Math.PI / 360;
             double angleRed2 = 60 * 2 * Math.PI / 360;
             ESRI.ArcGIS.Geometry.IConstructPoint constructPoint = new ESRI.ArcGIS.Geometry.PointClass();
             constructPoint.ConstructAngleIntersection(point1, angleRed1, point2, angleRed2);
             addFeature("point", point1);
             addFeature("point", point2);
             addFeature("point", constructPoint as ESRI.ArcGIS.Geometry.IPoint);
             axMapControl1.Refresh();
         }
//构造偏转角度发
         private void button5_Click(object sender, EventArgs e)
         {
             IPoint fromPoint = new PointClass();
             fromPoint.PutCoords(0, 0);
             IPoint toPoint = new PointClass();
             toPoint.PutCoords(1, 1);
             ILine line = new LineClass();
             line.PutCoords(fromPoint, toPoint);
             double distance = 1.4142135623731;
             double angle = Math.PI / 4;
             IConstructPoint constructPoint = new PointClass();
             constructPoint.ConstructDeflection(line, distance, angle);
             IPoint point = constructPoint as IPoint;
             addFeature("point", fromPoint);
             addFeature("point", toPoint);
             addFeature("point", point);
             axMapControl1.Refresh();
         }
//构造偏转交点法
         private void button6_Click(object sender, EventArgs e)
         {
             IPoint fromPoint = new PointClass();
             fromPoint.PutCoords(0, 0);
             IPoint toPoint = new PointClass();
             toPoint.PutCoords(1,1);
             ILine line=new LineClass();
             line.PutCoords(fromPoint,toPoint);
             double startAnale=Math.PI/4;
             double endAngle=Math.PI/4;
             IConstructPoint constructPoint=new PointClass();
             constructPoint.ConstructDeflectionIntersection(line,startAnale,endAngle,false);
             IPoint point=constructPoint as IPoint;
             addFeature("point",fromPoint);
             addFeature("point",toPoint);
             addFeature("point",point);
             axMapControl1.Refresh();
         }
        //构造平行线上点法
         private void button8_Click(object sender, EventArgs e)
         {
             IPoint[] points = new IPoint[2];
             for (int i = 0; i < 2; i++)
             {
                 points[i] = new PointClass();
             }
             points[0].PutCoords(0, 0);
             points[1].PutCoords(20, 0);
             ISegment segment;
             ILine line = new LineClass();
             line.FromPoint = points[0];
             line.ToPoint = points[1];
             segment = line as ISegment;
             IPoint fromPoint = new PointClass();
             fromPoint.X = points[0].X + 10;
             fromPoint.Y = points[0].Y + 5;
             IConstructPoint constructPoint = new PointClass();
             constructPoint.ConstructParallel(segment, esriSegmentExtension.esriNoExtension, fromPoint, segment.Length);
             addFeature("point", points[0]);
             addFeature("point", points[1]);
             addFeature("point", constructPoint as IPoint);
             axMapControl1.Refresh();
         }
        //构造垂直线上点法
         private void button9_Click(object sender, EventArgs e)
         {
             IPoint[] points = new IPoint[2];
             for (int i = 0; i < 2; i++)
             {
                 points[i] = new PointClass();
             }
             points[0].PutCoords(0, 0);
             points[1].PutCoords(20, 0);
             ISegment segment;
             ILine line = new LineClass();
             line.FromPoint = points[0];
             line.ToPoint = points[1];
             segment = line as ISegment;
             IPoint fromPoint = new PointClass();
             fromPoint.X = points[0].X + 10;
             fromPoint.Y = points[0].Y + 10;
             IConstructPoint constructPoint = new PointClass();
             constructPoint.ConstructPerpendicular(segment, esriSegmentExtension.esriNoExtension, fromPoint, 3, false);
             addFeature("point", points[0]);
             addFeature("point", points[1]);
             addFeature("point", constructPoint as IPoint);
             axMapControl1.Refresh();
         }
        //后方交会定点法
         private void button10_Click(object sender, EventArgs e)
         {
             IPoint[] points = new IPoint[3];
             for (int i = 0; i < 3; i++)
             {
                 points[i] = new PointClass();
             }
             IConstructPoint constructPoint = new PointClass();
             points[0].PutCoords(0, 10);
             points[1].PutCoords(20, 20);
             points[2].PutCoords(0, 0);
             double angle1 = Math.PI / 4;
             double angle2 = Math.PI / 4;
             double angle3;
             try
             {
                 constructPoint.ConstructThreePointResection(points[0], angle1, points[1], angle2, points[2], out angle3);
                 addFeature("point", points[0]);
                 addFeature("point", points[1]);
                 addFeature("point", points[2]);
                 addFeature("point", constructPoint as IPoint);
             }
             catch (Exception ex)
             {
             }
             axMapControl1.Refresh();
         }
    }
}
 Multipoint对象是一个具有相同结构的点的集合,通过使用Add方法来添加一个点到集合中。这个过程需要使用IPointCollection接口完成,在IConstructMultipoint接口中定义了“ConstructArcPoints”、“ConstructDivideEqual”、“ConstructDivideLength”、“ConstructIntersection”、“ConstructTangent”等5种构造方法。
  (1)ConstructArcPoints构造圆弧点:通过给定的一段圆弧,返回该圆弧的起点、终点、圆心和切线的交点。
  (2)ConstructDivideEqual构造等分点法:通过一条曲线和需要返回的点数来产生一个点集合。
  (3)ConstructDivideLength构造等长点法:通过给定的一条曲线对象和已经定义的间距长度,返回所有处于这条曲线上的点。
  (4)ConstructIntersection构造交点法:通过给定的两条曲线对象,以及这两条曲线的延长线、切线,计算这些线的交点。
  (5)ConstructTangent构造切线点:通过一条曲线和一个指定的点,产生指定的点到曲线的切线。
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.Geometry;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
namespace WindowsFormsApplication12
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //加载地图文档
        private void loadMapDocument()
        {
            OpenFileDialog openFileDialog;
            openFileDialog = new OpenFileDialog();
            openFileDialog.Title = "打开地图文档";
            openFileDialog.Filter = "map documents(*.mxd)|*.mxd";
            openFileDialog.ShowDialog();
            string filepath = openFileDialog.FileName;
            if (axMapControl1.CheckMxFile(filepath))
            {
                axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerArrowHourglass;
                axMapControl1.LoadMxFile(filepath, 0, Type.Missing);
                axMapControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerDefault;
            }
            else
            {
                MessageBox.Show(filepath + "不是有效的地图文档");
            }
        }
        //添加实体点
        private void addFeature(string layerName, ESRI.ArcGIS.Geometry.IPoint point)
        {
            int i = 0;
            ESRI.ArcGIS.Carto.ILayer layer = null;
            for (i = 0; i < axMapControl1.LayerCount; i++)
            {
                layer = axMapControl1.Map.get_Layer(i);
                if (layer.Name.ToLower() == layerName)
                {
                    break;
                }
            }
            ESRI.ArcGIS.Carto.IFeatureLayer featureLayer = layer as ESRI.ArcGIS.Carto.IFeatureLayer;
            IFeatureClass featureClass = featureLayer.FeatureClass;
            IDataset dataset = (IDataset)featureClass;
            IWorkspace workspace = dataset.Workspace;
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();
            IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer();
            IFeatureCursor featureCursor = featureClass.Insert(true);
            featureBuffer.Shape = point;
            object featureOID = featureCursor.InsertFeature(featureBuffer);
            featureCursor.Flush();
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
        }
        //构造圆弧点
        private void button1_Click(object sender, EventArgs e)
        {
            IPoint centerPoint = new PointClass();
            centerPoint.PutCoords(10, 0);
            IPoint fromPoint = new PointClass();
            fromPoint.PutCoords(0, 0);
            IPoint toPoint = new PointClass();
            toPoint.PutCoords(0, 20);
            IConstructCircularArc circularArcConstruction = new CircularArcClass();
            circularArcConstruction.ConstructThreePoints(fromPoint, centerPoint, toPoint, false);
            //勾画圆弧
            IConstructMultipoint constructMultipoint = new MultipointClass();
            constructMultipoint.ConstructArcPoints(circularArcConstruction as ICircularArc);
            IPointCollection pointCollection = constructMultipoint as IPointCollection;
            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                addFeature("point", pointCollection.get_Point(i));
            }
            axMapControl1.Refresh();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            loadMapDocument();
        }
        //构造等分点
        private void button2_Click(object sender, EventArgs e)
        {
            IPoint centerPoint = new PointClass();
            centerPoint.PutCoords(10, 0);
            IPoint fromPoint = new PointClass();
            fromPoint.PutCoords(0, 0);
            IPoint toPoint = new PointClass();
            toPoint.PutCoords(0, 20);
            ICircularArc circularArcConstruction = new CircularArcClass();
            circularArcConstruction.PutCoords(fromPoint, centerPoint, toPoint, esriArcOrientation.esriArcClockwise);
            //勾画圆弧
            IConstructMultipoint constructMultipoint = new MultipointClass();
            constructMultipoint.ConstructDivideEqual(circularArcConstruction as ICurve, (int)circularArcConstruction.Length / 5);
            IPointCollection pointCollection = constructMultipoint as IPointCollection;
            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                addFeature("point", pointCollection.get_Point(i));
            }
            axMapControl1.Refresh();
        }
        //构造等长点
        private void button3_Click(object sender, EventArgs e)
        {
            IPoint centerPoint = new PointClass();
            centerPoint.PutCoords(10, 0);
            IPoint fromPoint = new PointClass();
            fromPoint.PutCoords(0, 0);
            IPoint toPoint = new PointClass();
            toPoint.PutCoords(0, 20);
            ICircularArc circularArcConstruction = new CircularArcClass();
            circularArcConstruction.PutCoords(fromPoint, centerPoint, toPoint, esriArcOrientation.esriArcClockwise);
            //勾画圆弧
            IConstructMultipoint constructMultipoint = new MultipointClass();
            constructMultipoint.ConstructDivideLength(circularArcConstruction as ICurve, 10);
            IPointCollection pointCollection = constructMultipoint as IPointCollection;
            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                addFeature("point", pointCollection.get_Point(i));
            }
            axMapControl1.Refresh();
        }
        //构造交点
        private void button4_Click(object sender, EventArgs e)
        {
            IPoint[] points = new IPoint[4];
            for (int i = 0; i < 4; i++)
            {
                points[i] = new PointClass();
            }
            points[0].PutCoords(15, 10);
            points[1].PutCoords(20, 60);
            points[2].PutCoords(40, 60);
            points[3].PutCoords(45, 10);
            //构造Bezier曲线
            IBezierCurveGEN bezierCurve = new BezierCurveClass();
            bezierCurve.PutCoords(ref points);
            IPoint centerPoint = new PointClass();
            centerPoint.PutCoords(30, 30);
            IPoint fromPoint = new PointClass();
            fromPoint.PutCoords(10, 10);
            IPoint toPoint = new PointClass();
            toPoint.PutCoords(50, 10);
            //勾画圆弧
            IConstructCircularArc circularArcConstruction = new CircularArcClass();
            circularArcConstruction.ConstructThreePoints(fromPoint, centerPoint, toPoint, false);
            object param0, param1, isTangentPoint;
            IConstructMultipoint constructMultipoint = new MultipointClass();
            constructMultipoint.ConstructIntersection(circularArcConstruction as ISegment, esriSegmentExtension.esriNoExtension, bezierCurve as ISegment, esriSegmentExtension.esriNoExtension, out param0, out param1, out isTangentPoint);
            IMultipoint multipoint = constructMultipoint as IMultipoint;
            IPointCollection pointCollection = multipoint as IPointCollection;
            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                addFeature("point", pointCollection.get_Point(i));
            }
            axMapControl1.Extent = multipoint.Envelope;
            axMapControl1.Refresh();
        }
        //构造切线点
        private void button5_Click(object sender, EventArgs e)
        {
             IPoint[] points = new IPoint[4];
            for (int i = 0; i < 4; i++)
            {
                points[i] = new PointClass();
            }
            points[0].PutCoords(15, 10);
            points[1].PutCoords(20, 60);
            points[2].PutCoords(40, 60);
            points[3].PutCoords(45, 10);
            //构造Bezier曲线
            IBezierCurveGEN bezierCurve = new BezierCurveClass();
            bezierCurve.PutCoords(ref points);
            IPoint centerPoint = new PointClass();
           
            //勾画圆弧

            IConstructMultipoint constructMultipoint = new MultipointClass();
            constructMultipoint.ConstructTangent( bezierCurve as ICurve, points[1]);
            IMultipoint multipoint = constructMultipoint as IMultipoint;
            IPointCollection pointCollection = multipoint as IPointCollection;
            for (int i = 0; i < pointCollection.PointCount; i++)
            {
                addFeature("point", pointCollection.get_Point(i));
            }
          
            axMapControl1.Refresh();
        
        }
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

(转载)ArcGIS Engine中各种点的创建方法 的相关文章

  • GeoJSON 坐标?

    我有一个 GeoJSON 文件 我正在尝试处理它 以便在谷歌地图上绘制一些特征 然而 问题在于坐标不是传统的纬度 经度表示形式 而是一些大的六 七位数 例子 type FeatureCollection features type Feat
  • 在哪里以及如何安装 ArcPy for Python 2.7?

    我检查过http www lfd uci edu gohlke pythonlibs http www lfd uci edu gohlke pythonlibs http help arcgis com en arcgisdesktop
  • ST_MAKELINE 丢弃重复点,即使不连续

    考虑这个简化的例子 SELECT ST MAKELINE ST GEOGPOINT 5 51 ST GEOGPOINT 5 52 ST GEOGPOINT 5 51 我希望这能构建一条包含三个点的线 并在自身上加倍 相反 我得到的是 LIN
  • 如何使用 ggplot2 剪切、裁剪或白色填充紧紧包围多边形外部的矩形

    我只是想用白色填充简单多边形之外的区域 出于某种原因 它在中心画了一根奇怪的木桩 就像它认为这是一个吸血鬼杀手或其他什么东西一样 搞砸了 我尝试跟随这个帖子 https stackoverflow com questions 2128664
  • R:计算两个点层之间的最短距离

    我需要计算两个点矩阵之间的最短距离 我是 R 新手 不知道如何做到这一点 这是我用来调用数据并将其转换为点的代码 library dismo laurus lt gbif Laurus nobilis locs lt subset laur
  • R可以用于GIS吗? [关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我想创建一些 GIS 绘图 我想知道 R 是否可以用于此目的 以下是一些与我想要制作的概念相似的绘图示例 美国的温度图 或等高线图 颜
  • 使用 EPSG:25832 投影在 Leaflet 中垂直对齐 TMS 图块

    我使用 Leaflet 和 Proj4Leaflet 来处理 25832 中的图块 该应用程序相当简单 我尝试将 EPSG 25832 中的图块叠加到全比例底图上 我已从瓷砖地图元信息中复制了各个分辨率和来源 我面临的问题是地图未对齐 一旦
  • python:使用 gdal 绑定在内存中执行 gdalwarp

    我目前有一个加工链R下载MODIS数据然后调用gdalwarp从系统将特定子数据集 例如 NDVI 重新投影到 WGS1984 中 所结果的GeoTiffs然后被收集到一个HDF5文件以供进一步处理 现在我将处理链移至python 我想知道
  • 在 R SF 中交叉大型空间数据集

    我有两个空间数据集 一个数据集包含许多多边形 总共超过 150k 指定不同的特征 如河流 植被 另一个数据集包含更少的指定不同区域的多边形 500 我需要将这两个数据集相交以获得不同区域的特征 我可以根据不同的特征对第一个数据集进行子集化
  • 每行创建多边形并保留列

    早上好 下午好或晚上好 我已将一些位置数据分组到 1 小时的分组中 对于每个我都提取了最小的纬度和经度 它看起来像这样 df lt ID time bin count lat lon maxlat minlat maxlon minlon
  • 使用 Google Maps API V3 确定标记是否位于 KML 图层边界内

    有没有办法确定标记是否已进入 KmlLayer 覆盖的区域 我的 kml 主要由
  • 更改 ggplot2 中栅格图的颜色

    由于一些不相关的原因 我尝试使用 ggplot2 而不是栅格包绘图函数来制作栅格图 我想缩放颜色 使图上的最低温度为蓝色 图上的最高温度为红色 而中间范围为白色 我已经尝试了 ggplot2 中的许多功能 但始终未能获得所需的结果 这就是我
  • 如何执行两个 SpatialPolygonsDataFrame 对象的矢量叠加?

    我有两个 GIS 图层 称呼它们为Soils and Parcels 存储为SpatialPolygonsDataFrames SPDFs 我想 覆盖 它们 在此处描述的意义上 http resources esri com help 9
  • 将多边形转换为网格

    我有很多多边形 理想情况下 所有多边形不得相互重叠 但它们可以彼此相邻 但实际上 我必须考虑到slight多边形重叠 由一定的公差定义 因为所有这些多边形都是从用户手绘输入获得的 这并不像我希望的那样机器精确 我的问题是 是否有任何软件库组
  • 如何将世界上所有国家/城市/州放入我的数据库?

    我有一个困难的架构和网络问题 我正在尝试为世界上每个城市制作一个关于徒步旅行的页面http www comehike com http www comehike com 我必须以某种方式导入世界上所有的城市 并按州构建它们 而州又按国家构建
  • 在地图上显示线串的方向 - 自动缩放地图

    我有这段代码 它在地图上绘制一个线串 它是用户提供的 2 个坐标点的轨迹 public class Quickstart public static void main String args throws Exception displa
  • 在 Debian 上安装 PostGis 时出现错误“找不到 PGXS Makefile”

    我正在 Debian 机器上通过 psql 安装 PostGis 实际上是 crunchbang 我已完成以下步骤 wget http download osgeo org postgis source postgis 2 0 3 tar
  • SVG中的地理识别位置(GeoLocation/GeoTag)

    我想知道如何对 SVG 地图进行地理标记 我的搜索结果 地理标签以元数据格式提供 例如Exif http www awaresystems be imaging tiff tifftags privateifd gps html XMP h
  • 如何将美国人口普查局的州级形状文件合并为全国性形状

    人口普查局不提供全国范围内公共使用微数据区域的形状文件 美国社区调查中可用的最小地理区域 我尝试用几种不同的方法将它们结合起来 但即使是消除重复标识符的方法一旦到达加利福尼亚州也会崩溃 我是在做一些愚蠢的事情还是需要一个困难的解决方法 下面
  • 老虎普查数据中的 Shape_area 和 ALAND AWATER

    Shape area 是什么意思 我注意到它不是 Aland 和 Awater 的总和 这三个的单位是什么 ALAND和AWATER的单位是平方米 例如 tl 2015 us county dbf康明县有记录ALAND 1477895811

随机推荐

  • 盘点慢查询原因及优化方法

    目录 一 前言 二 准备 type重点看 三 慢查询原因和解决 1 sql未加索引 2 索引失效 3 limit深分页问题 1 limit深分页为什么会慢 2 深分页优化 4 in元素过多 5 join 或者子查询过多 6 order by
  • YARN与MapReduce1的区别

    YARN与MapReduce1的区别 1 组成对比 MapReduce1中 两类守护进程控制着作业执行过程 一个JobTracker和一个或多个TaskTracker JobTracker通过调度TaskTracker上运行的任务来协调所有
  • 【Linux】浅谈eloop机制

    目录 1 eloop 机制 2 eloop结构体 2 1 eloop data结构体 2 2 Socket事件结构体 2 3 Timeout事件结构体 2 4 Signal事件结构体 3 eloop init 4 eloop run 4 1
  • CGAL-5.6的安装与编译(Win10+vs2022+CGAL-5.6+Boost1.82.0)

    文章目录 前言 一 安装Boost 1 下载 2 环境变量 二 安装CGAL和GMP and MPFR libraries 1 下载 2 解压 3 环境变量 其他 参考 前言 CGAL是Computational Geometry Algo
  • 2023年副业赚钱最快的方法,最后一个时代红利,你一定要抓住!

    你有没有发现 生活中大部分的烦恼 归根结底只有一个原因 没钱 守着几千块的死工资 升职加薪难上加难 平时要为了省十几块钱不舍得打车 跟老公三天两头吵架 原因不过就是家里没钱给孩子报学费高昂的兴趣班 平时想买瓶香水都要费心思让老公送 出个远门
  • Java定时任务调度工具详解之Timer篇(初级)

    一 Timer简介 定时任务的基本概念 Timer的函数 综合运用和缺陷 基于给定的时间点 给定的时间间隔或者给定的执行次数自动执行的任务 Timer 和Quartz Timer 出身 由jdk提供 调用方式简单粗暴 能力 Timer能完成
  • 计算机内存只认4,为什么电脑的8GB内存只有7.45GB可用?

    今天偶遇到这样一个问题 本来8GB内存的笔记本系统却只有7 45GB可用 具体什么现象请看下图 丢失了0 55GB内存 为此我还特意百度了一下 得到这样的结果 电脑少的内存被核心显卡占用 核心显卡和系统共享内存是不错 但是我的这款i7 77
  • dac0832产生梯形波程序C语言,DAc0832产生三角波,正旋波,梯形波

    DAc0832产生三角波 正旋波 梯形波 换电路接成同相电压输出形式 其输出电压Vout IR 1 R2 R1 8 1 利用dac0832产生三角波 程序介绍 单片机通过DAC0832转换在LM358的7脚输 出三角波 实际应用如 函数波形
  • 2021年你一定要了解的概念——元宇宙

    2021年是元宇宙元年 随着VR AR 3D和脑机接口技术的不断进步 元宇宙的广阔市场被逐渐打开 除了最接近元宇宙形态的沙盒游戏外 你还了解多少元宇宙的知识 Part 1 什么是元宇宙 元宇宙的概念一提出来 所有人都在说元宇宙 那么元宇宙到
  • 使用SimHash进行海量文本去重

    阅读目录 1 SimHash与传统hash函数的区别 2 SimHash算法思想 3 SimHash流程实现 4 SimHash签名距离计算 5 SimHash存储和索引 6 SimHash存储和索引 7 参考内容 本文介绍的SimHash
  • 错误:app Transport Security has blocked a cleartext HTTP......

    在Xcode7中 苹果将 http 协议改成了 https 协议 使用 TLS1 2 SSL加密请求数据 因此在模拟器上运行程序时 要是程序还是使用的 http 协议就会报下图中的错误 解决办法 打开info plist 添加键值 App
  • jdbc的学习

    操作数据库的基本步骤 1 引入依赖 注册驱动 2 获取连接对象 如何获取数据库的连接 3 获取发送sql语句的对象 发送sql语句 4 处理结果集 5 释放资源 1 0 原始版本 public static void main String
  • 六、Java框架之SpringBoot

    黑马课程 文章目录 1 SpringBoot入门 1 1 SpringBoot入门案例 步骤1 创建SpringBoot项目 高版本springboot常见错误 步骤2 创建BookController 步骤3 启动服务器并运行程序 pom
  • Matlab画星座图

    1 clear all msg randi 0 7 1 80 八进制 80个符号 figure 1 stem msg msg1 pskmod msg 8 psk调制 scatterplot msg1 画星座图 hold on rectang
  • MySQL分组TOPN终极详解

    MySQL分组TOPN终极详解 终极终极详细解释 因为比较详细 适合小白看 大佬请出门左拐 代码比较简单 但是我一开始纠结了好久 脑壳疼 首先gruop by limit 肯定是不可以的 下面演示一下 1 建表 CREATE TABLE s
  • leanback android,Android TV之谷歌android leanback框架详解

    google leanback 库简介 Leanback 就是靠着看的意思 是指以放松的姿势倒在沙发上 谷歌推出 android support v17 leanback 软件包提供的 API 支持在电视设备上构建用户界面 它为电视应用提供
  • 零基础如何入门Python?这里有份宝典!

    大家好 你是否想过学习编程 但是觉得太难 太枯燥 太无聊 你是否想过用编程来解决一些实际的问题 或者创造一些有趣的东西 你是否想过用编程来提升自己的职业技能 或者开拓自己的事业前景 如果你有以上的想法 那么恭喜你 你找到了学习编程的动机 动
  • 【Transformer】基于Transformer的目标检测算法综述

    本文参考文献 基于Transformer的目标检测算法综述 网络首发时间 2023 01 19 15 01 34 网络首发地址 https kns cnki net kcms detail 11 2127 TP 20230118 1724
  • [Python人工智能] 二十三.基于机器学习和TFIDF的情感分类(含详细的NLP数据清洗)

    从本专栏开始 作者正式研究Python深度学习 神经网络及人工智能相关知识 前一篇文章分享了自定义情感词典 大连理工词典 实现情感分析和情绪分类的过程 这篇文章将详细讲解自然语言处理过程 基于机器学习和TFIDF的情感分类算法 并进行了各种
  • (转载)ArcGIS Engine中各种点的创建方法

    点 Point 代表了一个0纬的具有X Y坐标的几何对象 点是没有任何形状的 可用于描述点类型的要素 而且Geometry中的任何类型都是用点来产生的 构成几何形状的顶点存在3种可以选择的属性 即Z M和ID Z值在大多数情况下都可用于表示