ArcGIS Pro SDK (九)几何 6 包络
ArcGIS Pro SDK (九)几何 6 包络
文章目录
- ArcGIS Pro SDK (九)几何 6 包络
- 1 构造包络
- 2 构造包络 - 从 JSON 字符串
- 3 合并两个包络
- 4 与两个包络相交
- 5 展开包络
- 6 更新包络的坐标
环境:Visual Studio 2022 + .NET6 + ArcGIS Pro SDK 3.0
(图片来源网络,侵删)1 构造包络
// 使用 builderEx 的便捷方法或者使用 builderEx 构造函数。 MapPoint minPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); MapPoint maxPt = MapPointBuilderEx.CreateMapPoint(2.0, 2.0); Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(minPt, maxPt); EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(minPt, maxPt); envelope = builderEx.ToGeometry() as Envelope;
2 构造包络 - 从 JSON 字符串
string jsonString = "{ \"xmin\" : 1, \"ymin\" : 2,\"xmax\":3,\"ymax\":4,\"spatialReference\":{\"wkid\":4326}}"; Envelope envFromJson = EnvelopeBuilderEx.FromJson(jsonString);3 合并两个包络
// 使用便利构建器 Envelope env1 = EnvelopeBuilderEx.CreateEnvelope(0, 0, 1, 1, SpatialReferences.WGS84); Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(0.5, 0.5, 1.5, 1.5, SpatialReferences.WGS84); Envelope env3 = env1.Union(env2); double area = env3.Area; double depth = env3.Depth; double height = env3.Height; double width = env3.Width; double len = env3.Length; MapPoint centerPt = env3.Center; Coordinate2D coord = env3.CenterCoordinate; bool isEmpty = env3.IsEmpty; int pointCount = env3.PointCount; // 坐标 //env3.XMin, env3.XMax, env3.YMin, env3.YMax //env3.ZMin, env3.ZMax, env3.MMin, env3.MMax bool isEqual = env1.IsEqual(env2); // false // 或者使用 builderEx 构造函数,不需要在 MCT 上运行。 EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(0, 0, 1, 1, SpatialReferences.WGS84); builderEx.Union(env2); // 更新 builder 为结果 depth = builderEx.Depth; height = builderEx.Height; width = builderEx.Width; centerPt = builderEx.Center; coord = builderEx.CenterCoordinate; isEmpty = builderEx.IsEmpty; env3 = builderEx.ToGeometry() as Envelope;
4 与两个包络相交
// 使用便捷的 builder 方法 Envelope env1 = EnvelopeBuilderEx.CreateEnvelope(0, 0, 1, 1, SpatialReferences.WGS84); Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(0.5, 0.5, 1.5, 1.5, SpatialReferences.WGS84); bool intersects = env1.Intersects(env2); // true Envelope env3 = env1.Intersection(env2); // 或者使用 builderEx 构造函数 = 不需要在 MCT 上运行。 EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(0, 0, 1, 1, SpatialReferences.WGS84); intersects = builderEx.Intersects(env2); builderEx.Intersection(env2); // 注意这会将 builder 设置为相交的结果 env3 = builderEx.ToGeometry() as Envelope;
5 展开包络
// 使用 builderEx 的便捷方法或者使用 builderEx 构造函数。 // 便捷方法不需要在 MCT 上运行。 Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(100.0, 100.0, 500.0, 500.0); // 缩小封套大小 50% Envelope result = envelope.Expand(0.5, 0.5, true); // builderEx 构造函数不需要在 MCT 上运行。 EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(100.0, 100.0, 500.0, 500.0); builderEx.Expand(0.5, 0.5, true); envelope = builderEx.ToGeometry() as Envelope;
6 更新包络的坐标
Coordinate2D minCoord = new Coordinate2D(1, 3); Coordinate2D maxCoord = new Coordinate2D(2, 4); Coordinate2D c1 = new Coordinate2D(0, 5); Coordinate2D c2 = new Coordinate2D(1, 3); // 使用 EnvelopeBuilderEx。这个构造函数不需要在 MCT 上运行。 EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(minCoord, maxCoord); // builderEx.XMin, YMin, Zmin, MMin = 1, 3, 0, double.Nan // builderEx.XMax, YMax, ZMax, MMax = 2, 4, 0, double.Nan // 设置 XMin。如果 XMin > XMax,则同时更改 XMin 和 XMax builderEx.XMin = 6; // builderEx.XMin, YMin, ZMin, MMin = 6, 3, 0, double.Nan // builderEx.XMax, YMax, ZMax, MMax = 6, 4, 0, double.Nan // 设置 XMax builderEx.XMax = 8; // builderEx.XMin, YMin, ZMin, MMin = 6, 3, 0, double.Nan // builderEx.XMax, YMax, ZMax, MMax = 8, 4, 0, double.Nan // 设置 XMax。如果 XMax ZMax,则同时更改 ZMin 和 ZMax builderEx.ZMin = 3; // builderEx.XMin, YMin, ZMin, MMin = 3, 2, 3, double.Nan // builderEx.XMax, YMax, ZMax, MMax = 3, 4, 3, double.Nan // 设置 ZMax。如果 ZMax
免责声明:我们致力于保护作者版权,注重分享,被刊用文章因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理! 部分文章是来自自研大数据AI进行生成,内容摘自(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供学习参考,不准确地方联系删除处理! 图片声明:本站部分配图来自人工智能系统AI生成,觅知网授权图片,PxHere摄影无版权图库和百度,360,搜狗等多加搜索引擎自动关键词搜索配图,如有侵权的图片,请第一时间联系我们,邮箱:ciyunidc@ciyunshuju.com。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!
