Arcgis Runtime for Net创建包含多个线条的Polyline要素

  • A+
所属分类:.NET技术
摘要

在Arcgis的Polyline图层,有时需要用两个或多个线条表示一个要素,比如存在分支的路径,道路的上下行车道。

在Arcgis的Polyline图层,有时需要用两个或多个线条表示一个要素,比如存在分支的路径,道路的上下行车道。

Arcgis Runtime for Net创建包含多个线条的Polyline要素

在ArcMap中可以通过编辑图层,选中两个线条后,执行Merge命令,那么在Runtime for Net中如何实现呢?

开始找了很长时间是不是也有与Merge功能类似的API提供,后来发现可能没有。需要在创建Geometry时,就设定为两个或多个线条。

将线条的构成点分别存入两个PointCollection,然后用PointCollection的列表创建要素即可。  

PointCollection pts1 = new PointCollection(SpatialReferences.Wgs84); pts1.Add(pt); pts1.Add(pt1); pts1.Add(pt2); PointCollection pts2 = new PointCollection(SpatialReferences.Wgs84); pts2.Add(pt3); pts2.Add(pt4); List<PointCollection> lines = new List<PointCollection>() { pts1,pts2}; Polyline poly = new Polyline(lines);