The precision of the coordinate values used for the vertices should be determined with respect to the coordinates precision of the circle center and the length of the circle radius. This precision can then be applied through a Round function (e.g., see attached PHP code.)
For my application, I use 36-sided polygons to approximate circles. Each vertex for a given polygon side therefore needs to be at least two decimal places more precise than the center latitude or the center longitude (whichever is most precise).
But, a shorter radius can impose the need for more precision than is implied by the center coordinates. I handle the precision determined by radius length using a simple range test:
if ($radius > 10000000) { $radiusPrecision = 0;
} elseif ($radius > 1000000) { $radiusPrecision = 1;
} elseif ($radius > 100000) { $radiusPrecision = 2;
} elseif ($radius > 10000) { $radiusPrecision = 3;
} elseif ($radius > 1000) { $radiusPrecision = 4;
} elseif ($radius > 100) { $radiusPrecision = 5;
} elseif ($radius > 10) { $radiusPrecision = 6;
} else { $radiusPrecision = 7;
}
Here's my rationale for handling the radius this way: A circle with radius greater than 10,000 kilometers covers a hemsiphere and needs only whole number coordinates (zero decimal places) to precisely divide a polygon with dozens to hundreds of sides. As the circle radius decreases, one needs correspondingly higher precision. For radii less than ten meters, a precision of seven decimal places is sufficient. (Google Earth doesn't seem to deal with objects at scales under a meter anyway, AFAIK).
Attachments
389636-circlegen.zip (367 downloads)Preview this file with the Google Earth Plugin (learn more)