本文整理汇总了C#中Geometry.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Geometry.Clone方法的具体用法?C# Geometry.Clone怎么用?C# Geometry.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geometry
的用法示例。
在下文中一共展示了Geometry.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultipartToSinglePart
/// <summary>
/// This method takes an input multi part geometry and breaks the parts into individual standalone geometries.
/// This method must be called on the MCT. Use QueuedTask.Run.
/// </summary>
/// <param name="inputGeometry">The geometry to be exploded into the individual parts.</param>
/// <returns>An enumeration of individual parts as standalone geometries. The type of geometry is maintained, i.e.
/// if the input geometry is of type Polyline then each geometry in the return is of type Polyline as well.
/// If the input geometry is of type Unknown then an empty list is returned.</returns>
/// <remarks>This method must be called on the MCT. Use QueuedTask.Run.</remarks>
public IEnumerable<Geometry> MultipartToSinglePart(Geometry inputGeometry)
{
// list holding the part(s) of the input geometry
List<Geometry> singleParts = new List<Geometry>();
// check if the input is a null pointer or if the geometry is empty
if (inputGeometry == null || inputGeometry.IsEmpty)
return singleParts;
// based on the type of geometry, take the parts/points and add them individually into a list
switch (inputGeometry.GeometryType)
{
case GeometryType.Envelope:
singleParts.Add(inputGeometry.Clone() as Envelope);
break;
case GeometryType.Multipatch:
singleParts.Add(inputGeometry.Clone() as Multipatch);
break;
case GeometryType.Multipoint:
var multiPoint = inputGeometry as Multipoint;
foreach (var point in multiPoint.Points)
{
// add each point of collection as a standalone point into the list
singleParts.Add(point);
}
break;
case GeometryType.Point:
singleParts.Add(inputGeometry.Clone() as MapPoint);
break;
case GeometryType.Polygon:
var polygon = inputGeometry as Polygon;
foreach (var polygonPart in polygon.Parts)
{
// use the PolygonBuilder turning the segments into a standalone
// polygon instance
singleParts.Add(PolygonBuilder.CreatePolygon(polygonPart));
}
break;
case GeometryType.Polyline:
var polyline = inputGeometry as Polyline;
foreach (var polylinePart in polyline.Parts)
{
// use the PolylineBuilder turning the segments into a standalone
// polyline instance
singleParts.Add(PolylineBuilder.CreatePolyline(polylinePart));
}
break;
case GeometryType.Unknown:
break;
default:
break;
}
return singleParts;
}