0

I know that we can encode a polygon in android like this:

  encoded_string = polyutil.encode(polygon.getPoints());

But how can we get a encoded string for a circle?

iamlegend
  • 169
  • 3
  • 15

2 Answers2

0

I don't know what polyutil is or what its encode method does, but a circle's equivalent of a polygon's points is the center and radius. It shouldn't be too hard to call getCenter() and getRadius() on the circle and make a string with that data in it.

https://developer.android.com/reference/com/google/android/gms/maps/model/Circle.html

nasch
  • 5,330
  • 6
  • 31
  • 52
0

You may be able to use Java Topology Suite to do it. http://mvnrepository.com/artifact/com.vividsolutions/jts/1.11

    Coordinate center = new Coordinate(entity.getLongitude(), entity.getLatitude());
    GeometricShapeFactory gsf = new GeometricShapeFactory();

    gsf.setCentre(center);
    gsf.setNumPoints(20);
    gsf.setSize(10.2);

    Polygon poly = gsf.createCircle();

    Coordinate[] coordArray = poly.getCoordinates();

Not sure if this is what you want, but it'll give you an array of Coordinates on the perimeter of the circle, so it may be worth playing around with.

Boo
  • 377
  • 6
  • 18