ArcGIS Pro SDK (九)几何 2 坐标

ArcGIS Pro SDK (九)几何 2 坐标

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

1 矢量极坐标

Coordinate3D polarVector = new Coordinate3D(0, 7, 0);
Tuple<double, double, double> polarComponents = polarVector.QueryPolarComponents();
// polarComponents.Item1 = 0  (方位角)
// polarComponents.Item2 = 0 (倾角)
// polarComponents.Item3 = 7 (大小)

polarVector.SetPolarComponents(Math.PI / 4, Math.PI / 2, 8);
polarComponents = polarVector.QueryComponents();
// polarComponents.Item1 = 0 (x)
// polarComponents.Item2 = 0 (y)
// polarComponents.Item3 = 7 (z)

2 获取矢量倾角

Coordinate3D v = new Coordinate3D(0, 0, 7);
double inclination = v.Inclination;         // inclination = PI/2

v.SetComponents(-2, -3, 0);
inclination = v.Inclination;                // inclination = 0

v.SetComponents(0, 0, -2);
inclination = v.Inclination;                // inclination = -PI/2

3 获取矢量方位角

Coordinate3D vector = new Coordinate3D(0, 7, 0);
double azimuth = vector.Azimuth;      // azimuth = 0

vector.SetComponents(1, 1, 42);
azimuth = vector.Azimuth;
double degrees = AngularUnit.Degrees.ConvertFromRadians(azimuth);       // degrees = 45

vector.SetComponents(-8, 8, 2);
azimuth = vector.Azimuth;
degrees = AngularUnit.Degrees.ConvertFromRadians(azimuth);              // degrees = 315

4 向量运算

// 简单的3D向量
Coordinate3D v = new Coordinate3D(0, 1, 0);
// v.Magnitude = 1

Coordinate3D other = new Coordinate3D(-1, 0, 0);
// other.Magnitude = -1

double dotProduct = v.DotProduct(other);      // dotProduct = 0

Coordinate3D crossProduct = v.CrossProduct(other);
// crossProduct.X = 0
// crossProduct.Y = 0
// crossProduct.Z = 1

Coordinate3D addVector = v.AddCoordinate3D(other);
// addVector.X = -1
// addVector.Y = 1
// addVector.Z = 0

// 绕x轴旋转
Coordinate3D w = v;
w.Rotate(Math.PI, other);
// w.X = 0
// w.Y = -1
// w.Z = 0

w.Scale(0.5);
// w.X = 0
// w.Y = -0.5
// w.Z = 0

w.Scale(-4);
// w.X = 0
// w.Y = 2
// w.Z = 0
// w.Magnitude = 2

w.Move(3, 2, 0);
// w.X = 3
// w.Y = 4
// w.Z = 0
// w.Magnitude = 5

Coordinate3D emptyVector = new Coordinate3D();
// emptyVector = (0, 0, 0)
emptyVector.SetEmpty();
// emptyVector = (Nan, Nan, Nan)

Coordinate3D c1 = new Coordinate3D(2, 3, 4);
Coordinate3D c2 = new Coordinate3D(9, -1, 3);

var result_add = c1 + c2;
// result_add = (11, 2, 7)
var result_sub = c1 - c2;
// result_sub = (-7, 4, 1)

var b = result_sub != result_add;
// b = true

result_add = emptyVector + c1;
// result_add = (Nan, Nan, Nan)

b = result_add == emptyVector;
// b = true

5 2D 矢量操作

Coordinate2D v = new Coordinate2D(0, 1);
// v.Magnitude = 1

Coordinate2D other = new Coordinate2D(-1, 0);
double dotProduct = v.DotProduct(other);
// dotProduct = 0

Coordinate2D w = v + other;
// w = (-1, 1)

w += other;
// w = (-2, 1)

w -= other;
// w = (-1, 1)

w = v;
w.Rotate(Math.PI, other);
// w = (-2, -1)

w = other;

w.Scale(-4);
// w = (4, 0)
// w.Magnitude = 4

w.Move(-1, 4);
// w = (3, 4)
// w.Magnitude = 5

w.Move(-6, -1);
Tuple<double, double> components = w.QueryComponents();
// components = (-3, 3)
// w.Magnitude = 3 * Math.Sqrt(2)

Coordinate2D unitVector = w.GetUnitVector();
// w = (-Math.Sqrt(2) / 2, Math.Sqrt(2) / 2)
// w.Magnitude = 1

w.SetComponents(3, 4);

6 生成器

// 点列表
List<MapPoint> points = new List<MapPoint>
{
  MapPointBuilderEx.CreateMapPoint(0, 0, 2, 3, 1),
  MapPointBuilderEx.CreateMapPoint(1, 1, 5, 6),
  MapPointBuilderEx.CreateMapPoint(2, 1, 6),
  MapPointBuilderEx.CreateMapPoint(0, 0)
};

// 将有属性,因为它是通过便捷方法创建的
Polyline polylineWithAttrs = PolylineBuilderEx.CreatePolyline(points);
bool hasZ = polylineWithAttrs.HasZ;          // hasZ = true
bool hasM = polylineWithAttrs.HasM;          // hasM = true
bool hasID = polylineWithAttrs.HasID;        // hasID = true

// 将没有属性,因为它被指定为参数
Polyline polylineWithoutAttrs = 
  PolylineBuilderEx.CreatePolyline(points, AttributeFlags.None);
hasZ = polylineWithoutAttrs.HasZ;          // hasZ = false
hasM = polylineWithoutAttrs.HasM;          // hasM = false
hasID = polylineWithoutAttrs.HasID;        // hasID = false

// 将有属性,因为它是通过便捷方法创建的
Polygon polygonWithAttrs = PolygonBuilderEx.CreatePolygon(points);
hasZ = polygonWithAttrs.HasZ;               // hasZ = true
hasM = polygonWithAttrs.HasM;               // hasM = true
hasID = polygonWithAttrs.HasID;             // hasID = true

// 将没有属性,因为它被指定为参数
Polygon polygonWithoutAttrs = 
      PolygonBuilderEx.CreatePolygon(points, AttributeFlags.None);
hasZ = polygonWithoutAttrs.HasZ;               // hasZ = false
hasM = polygonWithoutAttrs.HasM;               // hasM = false
hasID = polygonWithoutAttrs.HasID;             // hasID = false

// 将没有属性,因为它被指定为参数
PolylineBuilderEx polylineB = 
           new PolylineBuilderEx(points, AttributeFlags.None);
hasZ = polylineB.HasZ;                      // hasZ = false
hasM = polylineB.HasM;                      // hasM = false
hasID = polylineB.HasID;                    // hasID = false

// 将有属性,因为它传递了一个带属性的折线
polylineB = new PolylineBuilderEx(polylineWithAttrs);
hasZ = polylineB.HasZ;                      // hasZ = true
hasM = polylineB.HasM;                      // hasM = true
hasID = polylineB.HasID;                    // hasID = true

// 将没有属性,因为它传递了一个不带属性的折线
polylineB = new PolylineBuilderEx(polylineWithoutAttrs);
hasZ = polylineB.HasZ;                      // hasZ = false
hasM = polylineB.HasM;                      // hasM = false
hasID = polylineB.HasID;                    // hasID = false

// 将没有属性,因为它被指定为参数
PolygonBuilderEx polygonB = new PolygonBuilderEx(points, AttributeFlags.None);
hasZ = polygonB.HasZ;                       // hasZ = false
hasM = polygonB.HasM;                       // hasM = false
hasID = polygonB.HasID;                     // hasID = false

// 将有属性,因为它传递了一个带属性的多边形
polygonB = new PolygonBuilderEx(polygonWithAttrs);
hasZ = polygonB.HasZ;                       // hasZ = true
hasM = polygonB.HasM;                       // hasM = true
hasID = polygonB.HasID;                     // hasID = true

// 将没有属性,因为它传递了一个不带属性的多边形
polygonB = new PolygonBuilderEx(polygonWithoutAttrs);
hasZ = polygonB.HasZ;                       // hasZ = true
hasM = polygonB.HasM;                       // hasM = true
hasID = polygonB.HasID;                     // hasID = true
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ArcGIS Pro SDK是用于创建ArcGIS Pro加载项的开发工具包。您可以使用ArcGIS Pro SDK来扩展ArcGIS Pro的功能,添加自定义工具、面板、任务和其他功能。\[1\] 要安装ArcGIS Pro SDK 3.0,您需要使用Visual Studio 2022,并从Visual Studio Marketplace搜索并安装以下三个扩展:ArcGIS Pro SDK for .NET,ArcGIS Pro SDK for .NET(Utilities),ArcGIS Pro SDK for .NET(Migration)\[1\]。请注意,ArcGIS Pro SDK for .NET扩展只能集成到Visual Studio 2022中,建议使用版本17.2或更高版本\[2\]。 ArcGIS Pro SDK for .NET提供了三个不同的扩展名(.vsix文件):ArcGIS Pro SDK for .NET用于创建ArcGIS Pro加载项的工程和项模板的集合,ArcGIS Pro SDK for .NET(Utilities)用于帮助创建ArcGIS Pro加载项的实用程序的集合,ArcGIS Pro SDK for .NET(Migration)用于将ArcGIS Pro SDK 2.x扩展模块迁移到ArcGIS Pro SDK 3.0 for .NET\[3\]。 总结来说,ArcGIS Pro SDK是用于创建ArcGIS Pro加载项的开发工具包,您可以使用它来扩展ArcGIS Pro的功能。要安装ArcGIS Pro SDK 3.0,您需要使用Visual Studio 2022,并从Visual Studio Marketplace安装相应的扩展。 #### 引用[.reference_title] - *1* *2* *3* [VS2022中ArcGIS Pro SDK for .NET安装和卸载指南](https://blog.csdn.net/u012685544/article/details/126317090)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值