当前位置: 首页>>代码示例>>C#>>正文


C# Polygon.SplitToConnectedDomains方法代码示例

本文整理汇总了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);
                }
            }

        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:60,代码来源:GeometrySerializers.cs

示例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();
            }
        }
开发者ID:gkrsu,项目名称:maparound.core,代码行数:62,代码来源:GeometrySerializers.cs


注:本文中的Polygon.SplitToConnectedDomains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。