예제 #1
0
        /// <summary>
        /// Creates a new instance from a MapWinGIS.Point
        /// </summary>
        /// <param name="mwPoint">Creates a new instance from a MapWinGIS.Point</param>
        public Coordinate(object mwPoint)
        {
            Coordinate nc = GeometryFactory.CreateCoordinate(mwPoint);

            X = nc.X;
            Y = nc.Y;
        }
예제 #2
0
        /// <summary>
        /// Returns a MultiLineString geometry collection derived from the mwShape
        /// </summary>
        /// <param name="mwShape">The shape to convert into a multi-line string</param>
        public static MultiLineString CreateMultiLineString(MapWinGIS.Shape mwShape)
        {
            MultiLineString MLS = new MultiLineString();
            // Variables
            int        numParts;  // The number of parts in the shape
            int        numPoints; // The number of points in the shape
            LineString LS;

            // Parameter checking
            if (mwShape == null)
            {
                throw new ArgumentException("mwShape should either not be null, or not be specified.");
            }
            if (mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_MULTIPATCH ||
                mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_MULTIPOINT ||
                mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_MULTIPOINTM ||
                mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_MULTIPOINTZ ||
                mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_NULLSHAPE ||
                mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POINT ||
                mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POINTM ||
                mwShape.ShapeType == MapWinGIS.ShpfileType.SHP_POINTZ)
            {
                throw new ArgumentException("Argument mwShape shapetype must be a polyline or polygon.");
            }

            MLS.GeometryN = new List <Geometry>();
            numParts      = mwShape.NumParts;
            numPoints     = mwShape.numPoints;
            // if NumParts = 0, treat as though the whole shape was a single part
            int prt = 0;                 // prt is the part index
            int pt  = 0;                 // pt is the point index

            while (prt < numParts - 1)
            {
                int maxpt = mwShape.get_Part(prt + 1);
                LS = new LineString();
                while (pt < maxpt)
                {
                    Coordinate Coord = GeometryFactory.CreateCoordinate(mwShape.get_Point(pt));
                    LS.Coordinates.Add(Coord);
                    pt++;
                }
                MLS.GeometryN.Add(LS);
                prt++;
            }
            LS = new LineString();
            while (pt < numPoints)
            {
                Coordinate Coord = GeometryFactory.CreateCoordinate(mwShape.get_Point(pt));
                LS.Coordinates.Add(Coord);
                pt++;
            }
            MLS.GeometryN.Add(LS);
            return(MLS);
        }