Hi Trieuvy,
The CreateCircle code didnt work. It gives me an OutOfMemoryException when I try to draw the resulting polygon at the line:
PathGradientBrush pthGrBrush = new PathGradientBrush(path);
I modified my existing circle creation method to multiply the radius by 1.609344 but its still not quite correct.
Why is there a need to convert the radius from metres to miles? How do I know if my map projection is using metres or miles?
Here is the code I use to generate the circle:
public static NetTopologySuite.Geometries.Polygon CreateEllipse(NetTopologySuite.Geometries.Point center,
double radius,
int segmentsPerQuadrant)
{
const double piHalf = System.Math.PI * 0.5d;
double step = piHalf / segmentsPerQuadrant;
radius = radius * 1.609344; // Convert metters to miles
System.Collections.ObjectModel.Collection pts =
new System.Collections.ObjectModel.Collection();
double angle = 0d;
for (int i = 0; i < 4 * segmentsPerQuadrant; i++)
{
NetTopologySuite.Geometries.Point pt = new NetTopologySuite.Geometries.Point(
(int)(center.X + Math.Cos(angle) * radius),
(int)(center.Y + Math.Sin(angle) * radius)
);
pts.Add( pt.Coordinate );
angle += step;
}
pts[pts.Count  1] = pts[0];
LinearRing lr = new NetTopologySuite.Geometries.LinearRing(pts.ToArray());
Polygon poly = new Polygon(lr);
return poly;
}
