本文整理汇总了C#中Polygon.SplitToConnectedDomains方法的典型用法代码示例。如果您正苦于以下问题:C# Polygon.SplitToConnectedDomains方法的具体用法?C# Polygon.SplitToConnectedDomains怎么用?C# Polygon.SplitToConnectedDomains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon
的用法示例。
在下文中一共展示了Polygon.SplitToConnectedDomains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SerializePolygon
/// <summary>
/// Serializes a polygon geometry into stream using a specified byte order.
/// </summary>
/// <param name="stream">A stream instance</param>
/// <param name="polygon">A polygon geometry to serialize</param>
/// <param name="byteOrder">A byte order which is used to write integer and double values</param>
/// <param name="reverseVertices">A value indicating whether a standart order of vertices
/// should be inverted in WKB</param>
public static void SerializePolygon(Stream stream, Polygon polygon, WKBByteOrder byteOrder, bool reverseVertices)
{
List<Polygon> polygons = polygon.SplitToConnectedDomains();
if (polygons.Count == 0)
throw new ArgumentException(_degeneratePolygon, "polygon");
if (reverseVertices)
foreach (Polygon p in polygons)
foreach (Contour c in p.Contours)
c.Reverse();
// порядок байтов
stream.Write(new byte[] { (byte)byteOrder }, 0, sizeof(byte));
if (polygons.Count == 1)
{
// тип геометрической фигуры
writeUInt32((uint)WKBGeometryType.Polygon, stream, byteOrder);
// количество контуров
writeUInt32((uint)polygons[0].Contours.Count, stream, byteOrder);
foreach (Contour c in polygons[0].Contours)
writeContour(stream, c, byteOrder);
}
else
{
// тип геометрической фигуры
writeUInt32((uint)WKBGeometryType.MultiPolygon, stream, byteOrder);
// количество полигонов
writeUInt32((uint)polygons.Count, stream, byteOrder);
// полигоны
foreach (Polygon p in polygons)
{
// порядок байтов
stream.Write(new byte[] { (byte)byteOrder }, 0, sizeof(byte));
// тип геометрической фигуры
writeUInt32((uint)WKBGeometryType.Polygon, stream, byteOrder);
// количество контуров
writeUInt32((uint)p.Contours.Count, stream, byteOrder);
// контуры
foreach (Contour c in p.Contours)
writeContour(stream, c, byteOrder);
}
}
}
示例2: GetPolygonWKT
/// <summary>
/// Computes a well-known text representation
/// of the polygon geometry.
/// </summary>
/// <param name="polygon">An instance of MapAround.Geometry.Polygon to setialize</param>
/// <param name="reverseVerticesOrder">A value indicating whether a standart order of vertices
/// should be inverted in WKT</param>
/// <returns>A well-known text representation of specified geometry.</returns>
public static string GetPolygonWKT(Polygon polygon, bool reverseVerticesOrder)
{
List<Polygon> polygons = polygon.SplitToConnectedDomains();
for (int i = polygons.Count - 1; i >= 0; i--)
{
if (reverseVerticesOrder)
foreach (Contour c in polygons[i].Contours)
c.Reverse();
if (polygons[i].Contours.Count == 0)
polygons.RemoveAt(i);
}
if (polygons.Count == 0)
throw new ArgumentException(_degeneratePolygon, "polygon");
if (polygons.Count == 1)
{
if (polygon.Contours.Count == 0)
throw new ArgumentException(_degeneratePolygon, "polygon");
StringBuilder sb = new StringBuilder("Polygon (");
int cnt = polygons[0].Contours.Count;
for (int i = 0; i < cnt; i++)
{
sb.Append(contourString(polygons[0].Contours[i]));
if (i < cnt - 1)
sb.Append(", ");
}
sb.Append(")");
return sb.ToString();
}
else
{
StringBuilder sb = new StringBuilder("MultiPolygon (");
for (int i = 0; i < polygons.Count; i++)
{
sb.Append("(");
int cnt = polygons[i].Contours.Count;
for (int j = 0; j < cnt; j++)
{
sb.Append(contourString(polygons[i].Contours[j]));
if (j < cnt - 1)
sb.Append(", ");
}
sb.Append(")");
if (i < polygons.Count - 1)
sb.Append(", ");
}
sb.Append(")");
return sb.ToString();
}
}