Amelia
Amelia

Reputation: 19

Draw an ellipse with one latlon point and a distance value from that point

I want to draw an ellipse around a point, for that I am creating a rectangle and within that I am drawing the ellipse.

For the rectangle I need the point, width and height. I have the point but no width and height. The only thing I have is a distance from the point. I want to calculate width and height of the rectangle with that distance?

Distance is 2km from the point in any direction around it.

Rectangle rec = new Rectangle(Convert.ToInt32(cx), Convert.ToInt32(cy), width, height);
gr.DrawEllipse(Pens.Red, rec);gr.FillEllipse(Brushes.Red, rec);

Upvotes: 1

Views: 149

Answers (1)

Amelia
Amelia

Reputation: 19

This is how I did it,

private static ENCX.S57Draw _draw;

 Savedrfpt.Lat = Convert.ToDouble(24.34567);
 Savedrfpt.Lon = Convert.ToDouble(54.32456);
 ENCX.PixelPoint Saved_rfpixpts = _draw.GeoPix.Point(Savedrfpt);

double Distance_meters = Convert.ToDouble(2) * 1000;
double pixelpermeters = getPixelSizeInMeters();
Double d = Distance_meters / pixelpermeters;
gr.DrawEllipse(greenPen, (float)Saved_rfpixpts.X - (float)d, (float)Saved_rfpixpts.Y - (float)d, (float)d + (float)d, (float)d + (float)d);
gr.FillEllipse(brush, (float)Saved_rfpixpts.X - (float)d, (float)Saved_rfpixpts.Y - (float)d, (float)d + (float)d, (float)d + (float)d);


 public double getPixelSizeInMeters()
        {
            double sizem = _draw.PixelSizeMetres;
            double disscale = _draw.GeoPix.DisplayScale;
            return _draw.PixelSizeMetres * _draw.GeoPix.DisplayScale;
        }

Thanks,

Upvotes: 1

Related Questions