/** * Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, * miles, or kilometers; and steps for precision. This uses the {@link #DEFAULT_STEPS} and * {@link TurfConstants#UNIT_DEFAULT} values. * * @param center a {@link Point} which the circle will center around * @param radius the radius of the circle * @return a {@link Polygon} which represents the newly created circle * @since 3.0.0 */ public static Polygon circle(@NonNull Point center, double radius) { return circle(center, radius, 64, TurfConstants.UNIT_DEFAULT); }
/** * Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, * miles, or kilometers; and steps for precision. This uses the {@link #DEFAULT_STEPS}. * * @param center a {@link Point} which the circle will center around * @param radius the radius of the circle * @param units one of the units found inside {@link TurfConstants.TurfUnitCriteria} * @return a {@link Polygon} which represents the newly created circle * @since 3.0.0 */ public static Polygon circle(@NonNull Point center, double radius, @TurfConstants.TurfUnitCriteria String units) { return circle(center, radius, DEFAULT_STEPS, units); }
@Test @Ignore public void name() throws Exception { Feature feature = Feature.fromJson(loadJsonFixture(CIRCLE_IN)); Polygon polygon = TurfTransformation.circle((Point) feature.geometry(), feature.getNumberProperty("radius").doubleValue()); FeatureCollection featureCollection = FeatureCollection.fromJson(loadJsonFixture(CIRCLE_OUT)); compareJson(featureCollection.features().get(1).geometry().toJson(), polygon.toJson()); } }