How to drae a circle?

Mar 12, 2011 at 8:29 AM

How to draw a circle use dotspatial?

Mar 18, 2011 at 3:44 PM

Maybe it's very easy,but I don't know.can any one help me.thanks very much.

Mar 22, 2011 at 4:03 PM

thanks!

Editor
Mar 23, 2011 at 11:35 AM

you probably need some sort of geometry shape factory. I don't know if there is one in DotSpatial, but you can derive something from this:

        public static SharpMap.Geometries.LinearRing CreateEllipse(SharpMap.Geometries.Point center,
                                                                    System.Drawing.SizeF size,
                                                                    int segmentsPerQuadrant)
        {
            const double piHalf = System.Math.PI * 0.5d;

            var step = piHalf / segmentsPerQuadrant;

            var pts = new SharpMap.Geometries.Point[4 * segmentsPerQuadrant + 1];
            var angle = 0d;
            for (var i = 0; i < 4 * segmentsPerQuadrant; i++)
            {
                pts[i] = new SharpMap.Geometries.Point(center.X + System.Math.Cos(angle) * size.Width,
                                                       center.Y + System.Math.Sin(angle) * size.Height);
                angle += step;
            }
            pts[pts.Length - 1] = pts[0];
            return new SharpMap.Geometries.LinearRing(pts);
        }

NOTE: you'll need to replace SharpMap.Geometries with the proper DotSpatial namespace (DotSpatial.Topology.Geometries?) and maybe change the constructor for the linestring.

Hth FObermaier

Apr 20, 2011 at 6:36 AM

thanks very much.

Aug 31, 2012 at 4:58 PM

//TO DRAW CIRCLE

 IGeometry g = GeometryFactory.Default.CreatePoint(new Coordinate(0,0)); // Centre of MAP CONTROL
            g = g.Buffer(10); Radius of Circle 1

            IGeometry c2 = GeometryFactory.Default.CreatePoint(new Coordinate(0, 0));  // Centre of MAP CONTROL
            c2 = c2.Buffer(20); //Radius of Circle 2

          
            f = new Feature(g);
            fs.Features.Add(f);

            f = new Feature(c2);
            fs.Features.Add(f);
           
            MapLineLayer ml = new MapLineLayer(fs);
            ml.Symbolizer = new LineSymbolizer(Color.Blue, 1);
            map.MapFrame.DrawingLayers.Add(rangeRingAxis);  // ADD MAP CONTROL

            map.MapFrame.Invalidate();