Beispiel #1
0
        /// <summary>
        /// If a Shape has multiple parts, this will create a separate polyline for each part.
        /// </summary>
        /// <param name="mwShape">A MapWinGIS.Shape that should be a PolyLine shape type</param>
        /// <returns>A List of Polylines derived from the various shapes</returns>
        public static List <PolyLine> mwShape_To_PolyLines(MapWinGIS.Shape mwShape)
        {
            if (Adapter.GetCategory(mwShape) != ShapeCategories.Line)
            {
                throw new ArgumentException("The Split method only takes Polyline shape types.");
            }
            List <PolyLine> newLines = new List <PolyLine>();

            if (mwShape.NumParts <= 1)
            {
                PolyLine Part = new PolyLine();
                for (int I = 0; I < mwShape.numPoints; I++)
                {
                    Part.Add_Point(mwShape.get_Point(I));
                }
                newLines.Add(Part);
                return(newLines);
            }
            int PartIndex = 0;

            for (int P = 0; P < mwShape.NumParts; P++)
            {
                PolyLine Part  = new PolyLine();
                int      Pnext = mwShape.get_Part(P);
                for (int I = PartIndex; I < Pnext; I++)
                {
                    Part.Add_Point(mwShape.get_Point(I));
                }
                newLines.Add(Part);
            }
            return(newLines);
        }
Beispiel #2
0
        /// <summary>
        /// Returns a new instance of the Polyline class with the same values as this object.
        /// </summary>
        /// <returns>Topology2D.Polyline with identical points.</returns>
        public PolyLine Copy()
        {
            PolyLine NewPoly = new PolyLine();

            for (int I = 0; I < Points.Count; I++)
            {
                // Copy each point so that nothing references the same data
                NewPoly.Add_Point(Points[I].Copy());
            }
            return(NewPoly);
        }