how to create and display and ellipse on the map

624
3
08-17-2010 04:58 AM
DarrenRempel
New Contributor III
I am trying to create and display an ellipse from the user selecting 2 points using the NewEllipseFeedbackClass but am not having any luck.  Here is the code I am using:
EllipticArcClass ellipticalArc = new EllipticArcClass();
                    IEnvelope env = new EnvelopeClass();
                    IPoint lowerLeft = new PointClass();
                    lowerLeft.X = centerPoint.X - width;
                    lowerLeft.Y = centerPoint.Y - height;
                    IPoint upperRight = new PointClass();
                    upperRight.X = centerPoint.X + width;
                    upperRight.Y = centerPoint.Y + height;
                    env.LowerLeft = lowerLeft;
                    env.UpperRight = upperRight;

                    ellipticalArc.ConstructEnvelope(env);
                    IGraphicTrackerSymbol graphicTrackerSymbol = this.graphicTracker.CreateSymbol(simpleFillSymbol, null);

                    int shapeId = this.graphicTracker.Add(ellipticalArc, graphicTrackerSymbol);

I have tried some of the other methods such as PutCoords and PutCoordsbyAngle but was unable to get them to work.  Anyone have any hints on how to do this?
0 Kudos
3 Replies
DarrenRempel
New Contributor III
interesting - my code works when dynamic display is turned off but does NOT work with dynamic display turned on!  also, if you try and use any of the built in drawing commands such as ControlsNewEllipseTool or ControlsNewCircleTool - they don't work in dynamic display.
0 Kudos
DarrenRempel
New Contributor III
here's a 'workaround' for dynamic display:

//create your EllipticArcClass as you would according to the ESRI documentation then get
//the points that make up the ellipse and create a polygon based on it - not efficient but it works

List<PointClass> points = new System.Collections.Generic.List<PointClass>();
//the level of fidelity should be adjusted
for(double d = 0.1; d < ellipticalArc.Length; d += 0.1)
{
  PointClass p = new PointClass();
  ellipticalArc.QueryPoint(esriSegmentExtension.esriNoExtension, d, false, p);
   points.Add(p);
}

polygon = new PolygonClass();
foreach (PointClass p in points)
     polygon.AddPoint(p);

ITopologicalOperator topo = polygon as ITopologicalOperator;
    topo.Simplify();

//added polygon using graphicTracker and simplefillsymbol
0 Kudos