MapxTreme2005 画扇区

 public MapInfo.Geometry.Geometry DrawSector(double x, double y, int middle, int angle, double radius)
        {
            if ((angle == 0) || (radius == 0))
                return null;
            MapInfo.Geometry.DPoint center = new MapInfo.Geometry.DPoint(x, y);           
            //创建一段弧线
            double beginAngle, endAngle;
            if (middle < 90)
            {
                beginAngle = 90 - middle - angle / 2;
                endAngle = 90 - middle + angle / 2;
            }
            else if (middle == 90)
            {
                beginAngle = 360 - angle / 2;
                endAngle = angle / 2;
            }
            else if (middle == 360)
            {
                beginAngle = 0;
                endAngle = 360;            
            }
            else
            {
                beginAngle = 450 - middle - angle / 2;
                endAngle = 450 - middle + angle / 2;
            }

            MapInfo.Geometry.LegacyArc sector = new LegacyArc(map.GetDisplayCoordSys(), center, radius, radius,
            MapInfo.Geometry.DistanceUnit.Kilometer, MapInfo.Geometry.DistanceType.Spherical, beginAngle, endAngle);

            MultiCurve mc = sector.CreateMultiCurve(100);

            MapInfo.Geometry.DPoint[] tmpPoints = mc[0][0].SamplePoints();

            MapInfo.Geometry.DPoint[] dPoints = new MapInfo.Geometry.DPoint[3];
            dPoints[0] = mc[0].EndPoint;
            dPoints[1] = new MapInfo.Geometry.DPoint(x, y);
            dPoints[2] = mc[0].StartPoint;

            MapInfo.Geometry.DPoint[] mPoints = new MapInfo.Geometry.DPoint[tmpPoints.Length - 1 + 3];
            for (int i = 0, j = 0; i < tmpPoints.Length - 1 + 3; i++)
            {
                if (i < tmpPoints.Length - 1)
                    mPoints[i] = tmpPoints[i];
                else
                    mPoints[i] = dPoints[j++];
            }

            MapInfo.Geometry.MultiPolygon mp = new MultiPolygon(map.GetDisplayCoordSys(), CurveSegmentType.Linear, mPoints);
            mp.EditingComplete();
            return mp;          
        }

你可能感兴趣的:(map)