ArcGIS Pro SDK (九)几何 8 线段

ArcGIS Pro SDK (九)几何 8 线段

文章目录

  • [ArcGIS Pro SDK (九)几何 8 线段](#ArcGIS Pro SDK (九)几何 8 线段)
    • [1 使用两个地图点构造线段](#1 使用两个地图点构造线段)
    • [2 更改线段坐标](#2 更改线段坐标)

环境:Visual Studio 2022 + .NET6 + ArcGIS Pro SDK 3.0

1 使用两个地图点构造线段

csharp 复制代码
// 使用 builderEx 的便捷方法或使用 builderEx 构造函数。

MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0);
MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 1.0);

// BuilderEx 的便捷方法不需要在 MCT 上运行。
LineSegment lineFromMapPoint = LineBuilderEx.CreateLineSegment(startPt, endPt);

// coordinate2D
Coordinate2D start2d = (Coordinate2D)startPt;
Coordinate2D end2d = (Coordinate2D)endPt;

LineSegment lineFromCoordinate2D = LineBuilderEx.CreateLineSegment(start2d, end2d);

// coordinate3D
Coordinate3D start3d = (Coordinate3D)startPt;
Coordinate3D end3d = (Coordinate3D)endPt;

LineSegment lineFromCoordinate3D = LineBuilderEx.CreateLineSegment(start3d, end3d);

// lineSegment
LineSegment anotherLineFromLineSegment = LineBuilderEx.CreateLineSegment(lineFromCoordinate3D);


// builderEx 的构造函数不需要在 MCT 上运行
LineBuilderEx lbEx = new LineBuilderEx(startPt, endPt);
lineFromMapPoint = lbEx.ToSegment() as LineSegment;

lbEx = new LineBuilderEx(start2d, end2d);
lineFromCoordinate2D = lbEx.ToSegment() as LineSegment;

lbEx = new LineBuilderEx(start3d, end3d);
lineFromCoordinate3D = lbEx.ToSegment() as LineSegment;

lbEx = new LineBuilderEx(startPt, endPt);
lineFromMapPoint = lbEx.ToSegment() as LineSegment;

lbEx = new LineBuilderEx(lineFromCoordinate3D);
anotherLineFromLineSegment = lbEx.ToSegment() as LineSegment;

2 更改线段坐标

csharp 复制代码
// builderEx 的构造函数不需要在 MCT 上运行
LineBuilderEx lbuilderEx = new LineBuilderEx(lineSegment);
// 查找现有的坐标
lbuilderEx.QueryCoords(out startPt, out endPt);

// 或者使用
//startPt = lbuilderEx.StartPoint;
//endPt = lbuilderEx.EndPoint;

// 更新坐标
lbuilderEx.SetCoords(GeometryEngine.Instance.Move(startPt, 10, 10) as MapPoint, GeometryEngine.Instance.Move(endPt, -10, -10) as MapPoint);

// 或者使用
//lbuilderEx.StartPoint = GeometryEngine.Instance.Move(startPt, 10, 10) as MapPoint;
//lbuilderEx.EndPoint = GeometryEngine.Instance.Move(endPt, -10, -10) as MapPoint;

LineSegment segment2 = lbuilderEx.ToSegment() as LineSegment;
相关推荐
CV大法好3 小时前
刘铁猛C#入门 027 抽象和开闭原则
开发语言·c#
离歌漠4 小时前
C#调用C++ DLL方法之P/Invoke
c++·c#·p/invoke
公子小六5 小时前
在WPF程序中实现PropertyGrid功能
windows·microsoft·c#·.net·wpf
dangoxiba6 小时前
[Unity Demo]从零开始制作空洞骑士Hollow Knight第二十集:制作专门渲染HUD的相机HUD Camera和画布HUD Canvas
游戏·unity·c#·游戏引擎·playmaker
WangYan20227 小时前
泥石流灾害风险评估与模拟丨AI与R语言、ArcGIS、HECRAS融合,提升泥石流灾害风险预测的精度和准确性
arcgis·chatgpt·遥感技术·地质灾害·泥石流·hecras·风险评价
小吴同学·13 小时前
.NET6 WebApi第1讲:VSCode开发.NET项目、区别.NET5框架【两个框架启动流程详解】
c#·.netcore·.net core
bluefox197918 小时前
使用 Oracle.DataAccess.Client 驱动 和 OleDB 调用Oracle 函数的区别
开发语言·c#
鲤籽鲲20 小时前
C# MethodTimer.Fody 使用详解
开发语言·c#·mfc
工业3D_大熊20 小时前
3D可视化引擎HOOPS Luminate场景图详解:形状的创建、销毁与管理
java·c++·3d·docker·c#·制造·数据可视化