public PolygonPart(PolygonClosingPole closingPole)
 {
     this.closingPole = closingPole;
 }
            public void Load(IList <MapPoint> points, int firstPointIndex, int segmentLength, PolygonClosingPole closingPole)
            {
                MapPoint mapPoint  = points[firstPointIndex];
                MapPoint mapPoint2 = points[firstPointIndex + segmentLength - 1];

                m_polygonIsClosed  = mapPoint.Equals(mapPoint2);
                m_polygonIsCut     = false;
                m_polygonPartsList = new List <PolygonPart>();
                PolygonPart polygonPart = new PolygonPart(closingPole);
                MapPoint    mapPoint3   = default(MapPoint);

                for (int i = 0; i < segmentLength; i++)
                {
                    MapPoint mapPoint4 = points[firstPointIndex + i];
                    if (i == 0)
                    {
                        polygonPart.Points.Add(mapPoint4);
                    }
                    else
                    {
                        MapPoint mapPoint5 = mapPoint3;
                        foreach (MapPoint item in DensifyLine(mapPoint3, mapPoint4, DEFAULT_DENSIFICATION_ANGLE))
                        {
                            if (Math.Abs(item.X - mapPoint5.X) <= 180.0)
                            {
                                polygonPart.Points.Add(item);
                                mapPoint5 = item;
                                continue;
                            }
                            if (Math.Abs(item.X) == 180.0)
                            {
                                MapPoint mapPoint6 = new MapPoint(0.0 - item.X, item.Y);
                                polygonPart.Points.Add(mapPoint6);
                                mapPoint5 = mapPoint6;
                                continue;
                            }
                            if (Math.Abs(mapPoint5.X) == 180.0 && polygonPart.Points.Count == 1)
                            {
                                mapPoint5.X = 0.0 - mapPoint5.X;
                                polygonPart.Points[polygonPart.Points.Count - 1] = mapPoint5;
                                polygonPart.Points.Add(item);
                                mapPoint5 = item;
                                continue;
                            }
                            FindIntersectionPoints(mapPoint5, item, out MapPoint intersectionPoint, out MapPoint intersectionPoint2);
                            if (!mapPoint5.Equals(intersectionPoint))
                            {
                                polygonPart.Points.Add(intersectionPoint);
                            }
                            m_polygonPartsList.Add(polygonPart);
                            polygonPart = new PolygonPart(closingPole);
                            if (!item.Equals(intersectionPoint2))
                            {
                                polygonPart.Points.Add(intersectionPoint2);
                            }
                            polygonPart.Points.Add(item);
                            m_polygonIsCut = true;
                            mapPoint5      = item;
                        }
                        mapPoint4 = mapPoint5;
                    }
                    mapPoint3 = mapPoint4;
                }
                if (m_polygonIsCut && m_polygonIsClosed && polygonPart.LastPoint.Equals(m_polygonPartsList[0].FirstPoint))
                {
                    polygonPart.Points.RemoveAt(polygonPart.Points.Count - 1);
                    m_polygonPartsList[0].Points.InsertRange(0, polygonPart.Points);
                }
                else
                {
                    m_polygonPartsList.Add(polygonPart);
                }
                if (!m_polygonIsCut && m_polygonIsClosed && Math.Abs(polygonPart.FirstPoint.X) == 180.0 && polygonPart.FirstPoint.X == 0.0 - polygonPart.LastPoint.X)
                {
                    m_polygonIsCut = true;
                }
            }
 public void ProcessShapeSegment(ShapeSegment segment, IList <MapPoint> points, int firstPointIndex, PolygonClosingPole closingPole, out List <ShapeSegment> segments, out List <MapPoint> segmentPoints, out bool isClosedAtPole)
 {
     isClosedAtPole = false;
     segments       = new List <ShapeSegment>();
     segmentPoints  = new List <MapPoint>();
     Load(points, firstPointIndex, segment.Length, closingPole);
     foreach (PolygonPart shape in GetShapes())
     {
         ShapeSegment item = default(ShapeSegment);
         item.Type   = segment.Type;
         item.Length = shape.Points.Count;
         segments.Add(item);
         segmentPoints.AddRange(shape.Points);
         isClosedAtPole |= shape.isClosedAtPole;
     }
 }