Пример #1
0
            /// <summary>
            /// Adds a chain of links as a part to a shape
            /// </summary>
            /// <param name="l">chain</param>
            /// <param name="shape"></param>
            /// <param name="partindex"></param>
            /// <param name="pointindex"></param>
            /// <returns>true iff no eror</returns>
            private bool addChainToShape(List <Link> l, MapWinGIS.Shape shape,
                                         ref int partindex, ref int pointindex)
            {
                if (!shape.InsertPart(pointindex, ref partindex))
                {
                    return(false);
                }
                partindex++;
                Polygon.rotate(l);
                Link l0 = l[0];

                MapWinGIS.Point p0;
                p0 = linkToPoint(l0);
                if (!shape.InsertPoint(p0, ref pointindex))
                {
                    return(false);
                }
                pointindex++;
                Direction lastDir = l0.dir;

                for (int i = 1; i < l.Count; i++)
                {
                    Link nextLink = l[i];
                    if (nextLink.dir != lastDir)
                    {
                        // next link has a new direction, so include its start point
                        if (!shape.InsertPoint(linkToPoint(nextLink), ref pointindex))
                        {
                            return(false);
                        }
                        pointindex++;
                    }
                    lastDir = nextLink.dir;
                }
                // close the polygon
                if (!shape.InsertPoint(p0, ref pointindex))
                {
                    return(false);
                }
                pointindex++;
                return(true);
            }