I am currently using the below code to create a GeoJson Polygon. this gives me a bad circle which is not valid...
in this case RADIUS = 1609.34
, which is 1 mile in meters.
public GeoJsonPolygon createRadiusPolygon( Point point,double RADIUS) {
GeometricShapeFactory shapeFactory = new GeometricShapeFactory();
shapeFactory.setNumPoints(32);
shapeFactory.setCentre(new com.vividsolutions.jts.geom.Coordinate(point.getX(), point.getY()));
shapeFactory.setSize(RADIUS * 2);
com.vividsolutions.jts.geom.Geometry circle = shapeFactory.createCircle();
List<Point> points = new ArrayList<Point>();
for (com.vividsolutions.jts.geom.Coordinate coordinate : circle.getCoordinates()) {
Point lngLatAtl = new Point(coordinate.x, coordinate.y);
points.add(lngLatAtl);
}
Collections.reverse(points);
return new GeoJsonPolygon(points);
}
referenced: http://docs.geotools.org/stable/userguide/library/jts/geometry.html
currently if i use Point(-73.87,40.84) RADIUS = 1609.34, i get the below link. https://gist.githubusercontent.com/VanitySoft/56c4ce0f5c1c7e7fe0461ed46fd5ed11/raw/94544750a140d81780ebe9206395a21ab88bb1f7/circle
===SOLVED== from @Ian answer: Using method in his answer. RADIUS is in miles, to get the Circle used to create the GeoJson.
...
com.vividsolutions.jts.geom.Point jtsPoint = new GeometryFactory().createPoint(new com.vividsolutions.jts.geom.Coordinate(point.getY(), point.getX()));
javax.measure.Measure measure = Measure.valueOf(RADIUS, NonSI.MILE);
com.vividsolutions.jts.geom.Geometry circle = createCircleRadis(measure,CRS.decode("epsg:4326"),jtsPoint );
...
...