Draw a circle with radius in meters

3471
1
09-20-2013 04:56 AM
DmitrySokolov
New Contributor
Hi

I need to draw a circle on GraphicsLayer layer with given center and given radius in meters. So me method looks like this:

 private Polygon drawCircle(Point center, double radius, int pointsCount) {
  double r = convertFromMeters(radius); //I don't know how to convert from meters
  Polygon p = new Polygon();
  boolean started = false;
  double slice = 2 * Math.PI / pointsCount;
  for (int i = 0; i <= pointsCount; i++) {
   double rad = slice * i;
   double px = center.getX() + r * Math.cos(rad);
   double py = center.getY() + r * Math.sin(rad);
   Point point = new Point(px, py);
   if (started) {
    p.lineTo(point);
   } else {
    p.startPath(point);
    started = true;
   }
  }
  return p;
 }


Could anyone help me, how to convert from meters to suitable units?
Thanks.
0 Kudos
1 Reply
DanO_Neill
Occasional Contributor III
The Android API provides Unit.convertUnits() to convert between the same UnitType.
0 Kudos