i am trying to create circle around specific coordinate using below method which I got from some git hub repo.
public static Geometry createCircle(Coordinate coordinate, double radius)
{
GeometricShapeFactory shape = new GeometricShapeFactory(geomFactory);
shape.setCentre(coordinate);
shape.setSize(2 * radius);
shape.setNumPoints(32);
return shape.createCircle();
}
I want to pass the radius in miles, but looks like its taking in some other unit and the circle getting created is huge when I am giving 5 as radius. Can someone explain how can I use radius argument in miles in above example?
JTS is geometry/topology library. As such, it uses whatever units the geometry is in.
Assuming you are working with a point that is a longitude, latitude pair, then the units are degrees of longitude/latitude. At the equator, a degree is around ~110 kilometers / 69 miles.
As a really quick fix, you could set your radius to something like 5/69. As a complete solution, you could apply GeoTools's (a Java geospatial library) GeodeticCalculator class [1] to the code you suggested to get a more accurate circle.
That solution will have some issues around the poles, but that's another issue...
[1] http://docs.geotools.org/stable/userguide/library/referencing/calculator.html