/// <summary>
        /// Creates a MapWinGIS.Shape object from the point data specified by the user.
        /// </summary>
        /// <returns>Returns a MapWinGIS.Shape object.</returns>
        public MapWinGIS.Shape ToMWShape(MapWinGIS.ShpfileType type)
        {
            if (m_Points.Count == 0)
            {
                return(null);
            }

            MapWinGIS.Shape shp = new MapWinGIS.ShapeClass();
            MapWinGIS.Point pnt;

            int partNum    = 0;
            int pointIndex = 0;

            bool bres;

            bres = shp.Create(type);
            bres = shp.InsertPart(0, ref partNum);

            for (int i = 0; i < m_Points.Count; i++)
            {
                pnt        = new MapWinGIS.PointClass();
                pnt.x      = ((PointD)m_Points[i]).x;
                pnt.y      = ((PointD)m_Points[i]).y;
                pointIndex = i;
                bres       = shp.InsertPoint(pnt, ref pointIndex);
                pnt        = null;
            }

            return(shp);
        }
        /// <summary>
        /// Creates one multi-part polygon out of two input polygons.
        /// </summary>
        /// <param name="poly1">The first polygon to be combined.</param>
        /// <param name="poly2">The second polygon to be combined.</param>
        /// <param name="resultShp">The resulting multi-part polygon.</param>
        /// <returns>True if combining was successful, false otherwise.</returns>
        private static bool CombinePolygons(ref MapWinGIS.Shape poly1, ref MapWinGIS.Shape poly2, out MapWinGIS.Shape resultShp)
        {
            int p1NumParts = poly1.NumParts;

            if (p1NumParts == 0)
            {
                p1NumParts = 1;
            }
            int p2NumParts = poly2.NumParts;

            if (p2NumParts == 0)
            {
                p2NumParts = 1;
            }

            MapWinGIS.Shape multiShp = new MapWinGIS.ShapeClass();
            multiShp.Create(poly1.ShapeType);
            int partIndex  = 0;
            int pointIndex = 0;
            int numPoints  = poly1.numPoints;
            int begPart    = 0;
            int endPart    = numPoints;

            //deal with the first shape and all of its parts
            //			Globals.Vertex[][] p1VertArray = new Globals.Vertex[p1NumParts][];
            //			Globals.ConvertPolyToVertexArray(ref poly1, out p1VertArray);
            //bool firstIsClockwise = Globals.IsClockwise(ref p1VertArray[0]);

            for (int i = 0; i <= p1NumParts - 1; i++)
            {
                partIndex  = i;
                pointIndex = multiShp.numPoints;
                multiShp.InsertPart(pointIndex, ref partIndex);

                begPart = poly1.get_Part(i);
                if (i < p1NumParts - 1)
                {
                    endPart = poly1.get_Part(i + 1);
                }
                else
                {
                    endPart = poly1.numPoints;
                }
                //				if(firstIsClockwise)
                //				{
                //add part
                for (int j = begPart; j <= endPart - 1; j++)
                {
                    pointIndex = multiShp.numPoints;
                    multiShp.InsertPoint(poly1.get_Point(j), ref pointIndex);
                }
                //				}
                //				else
                //				{
                //					//add part in reverse order
                //					for(int j = endPart-1; j >= begPart; j--)
                //					{
                //						pointIndex = multiShp.numPoints;
                //						multiShp.InsertPoint(poly1.get_Point(j), ref pointIndex);
                //					}
                //				}
            }            //end of adding poly1 and all of its parts to the result shape

            //deal with the second shape and all of its parts
            //			Globals.Vertex[][] p2VertArray = new Globals.Vertex[p2NumParts][];
            //			Globals.ConvertPolyToVertexArray(ref poly2, out p2VertArray);
            //			bool secondIsClockwise = Globals.IsClockwise(ref p2VertArray[0]);
            partIndex++;
            numPoints = poly2.numPoints;
            begPart   = 0;
            endPart   = numPoints;

            for (int i = 0; i <= p2NumParts - 1; i++)
            {
                partIndex += i;
                pointIndex = multiShp.numPoints;
                multiShp.InsertPart(pointIndex, ref partIndex);

                begPart = poly2.get_Part(i);
                if (i < p2NumParts - 1)
                {
                    endPart = poly2.get_Part(i + 1);
                }
                else
                {
                    endPart = poly2.numPoints;
                }

                //				if(secondIsClockwise)
                //				{
                for (int j = begPart; j <= endPart - 1; j++)
                {
                    pointIndex = multiShp.numPoints;
                    multiShp.InsertPoint(poly2.get_Point(j), ref pointIndex);
                }
                //				}
                //				else
                //				{
                //					for(int j = endPart-1; j >= begPart; j--)
                //					{
                //						pointIndex = multiShp.numPoints;
                //						multiShp.InsertPoint(poly2.get_Point(j), ref pointIndex);
                //					}
                //				}
            }            //end of inserting parts from the second shape

            resultShp = multiShp;
            if (resultShp.numPoints > 0)
            {
                return(true);
            }
            else
            {
                gErrorMsg = "Error occured while trying to combine parts. No points in result shape.";
                Debug.WriteLine(gErrorMsg);
                Error.SetErrorMsg(gErrorMsg);
                MapWinUtility.Logger.Dbg(gErrorMsg);
                return(false);
            }
        }