1. ## Radius of a circle drawn as a polygon

All,

I found this solution to draw a circle as a polygon of 360 points:

{
AGSMutablePolygon * p = [AGSMutablePolygon new];
int pointsCount = 360;
double slice = 2 * M_PI / pointsCount;
for(int i = 0; i<pointsCount;i++){
double rad = slice * i;
[p addPointToRing:[AGSPoint pointWithXx yy spatialReference:[AGSSpatialReference spatialReferenceWithWKID:4326]]];
}

return p;
}

The question I have is what is the units of the radius passed in? For example, if I want to draw a circle of raduis 10 miles, what value do I pass in? If I pass in 10, it just draws a really huge circle with radius several multiples of 10!

I tried to look into the sdk api docs and could not find much info, so any help will be appreciated.

2. ## Re: Radius of a circle drawn as a polygon

Since you're using the WGS84 spatial reference, the value 10 is assumed to be in decimal degrees.
At the equator, 1 degree = 69 miles (approx).
So if you want 10 miles, you should use 10/69 as radius

3. ## Re: Radius of a circle drawn as a polygon

The units will be decimal degrees.

What you might find useful is to buffer around your center-point.

Try something like this:

Code:
```-(AGSPolygon*) circleWithCenter:(AGSPoint*)point radius:(double)radiusInMiles
{
AGSGeometryEngine *ge = [AGSGeometryEngine defaultGeometryEngine];

// Get a point in a spatial reference whose unit is Meters.
AGSPoint *pointToBufferAround = (AGSPoint *)[ge projectGeometry:point toSpatialReference:[AGSSpatialReference webMercatorSpatialReference]];

// Get a "circle" around it, using the unit Meters (1 mile ~= 1609.344 meters).
AGSPolygon *circle = [ge bufferGeometry:pointToBufferAround byDistance:radiusInMiles*1609.344];

// Project the output back to the projection of the input point (which is presumably what you're after).
circle = (AGSPolygon *)[ge projectGeometry:circle toSpatialReference:point.spatialReference];

return circle;
}```
That will use Meters (WebMercator's units). Note that your output may not be what you expect as the input or output approaches the poles. Also, there's no guarantee how many points the output polygon will have in its boundary.

4. ## Re: Radius of a circle drawn as a polygon

Thanks nfurness and Technobrat for your solutions.

Both work, however, per nfurness's solution using buffer around the center point and webMercatorSpatialReference, I am getting an oval shape rather than a circle. Is this expected?

5. ## Re: Radius of a circle drawn as a polygon

Could be. Depends on what the projection is of your map. I'm guessing it's not Web Mercator

My solution will generate you a polygon that is pretty close to circular on the ground (i.e the edge is R miles north and R miles east of the center). If you are using a Web Mercator projection, it will appear circular on the map. If you are using WGS84 for example, it will indeed appear less tall as you move north or south from the equator, by virtue of the projection.

If you want something that looks circular on a WGS84 map, and you know that your center point is WGS84, you can either use your & Technobrat's solution or something like this:

Code:
```-(AGSPolygon*) circleWithCenter:(AGSPoint*)point radius:(double)radiusInMiles
{
AGSGeometryEngine *ge = [AGSGeometryEngine defaultGeometryEngine];

// Get a "circle" around the point, using the 1 decimal degree ~= 69 miles.
AGSPolygon *circle = [ge bufferGeometry:point byDistance:radiusInMiles/69];

return circle;
}```
But remember that this is approximating the conversion between decimal degrees and meters, which is not constant for longitude as latitude varies.

So, it really depends on what you are generating the 10 mile radius geometry for and (in short) how far north or south of the equator. Your solution may be good enough for what you want, but bear in mind that a degree of longitude will be very much less than 69 miles as you approach the poles. On the other hand, your application users may keep asking you why the "circle" is elliptical, and that might be a bigger headache than considering some things that might be more than 10 miles away.