@Test public void ellipse() throws Exception { Polygon p = builder.ellipse( RECT_ENV.getMinX(), RECT_ENV.getMinY(), RECT_ENV.getMaxX(), RECT_ENV.getMaxY(), getNumSides(RECT_ENV)); assertBounds(RECT_ENV, p.getEnvelopeInternal(), 0.01); }
public Polygon ellipse(double x1, double y1, double x2, double y2, int nsides) { double rx = Math.abs(x2 - x1) / 2; double ry = Math.abs(y2 - y1) / 2; double cx = Math.min(x1, x2) + rx; double cy = Math.min(y1, y2) + ry; double[] ord = new double[2 * nsides + 2]; double angInc = 2 * Math.PI / nsides; for (int i = 0; i < nsides; i++) { double ang = -(i * angInc); ord[2 * i] = cx + rx * Math.cos(ang); ord[2 * i + 1] = cy + ry * Math.sin(ang); } ord[2 * nsides] = ord[0]; ord[2 * nsides + 1] = ord[1]; return polygon(ord); }
GeometryBuilder { public Polygon ellipse(double x1, double y1, double x2, double y2, int nsides) { double rx = Math.abs(x2 - x1) / 2; double ry = Math.abs(y2 - y1) / 2; double cx = Math.min(x1, x2) + rx; double cy = Math.min(y1, y2) + ry; double[] ord = new double[2 * nsides + 2]; double angInc = 2 * Math.PI / nsides; for (int i = 0; i < nsides; i++) { double ang = -(i * angInc); ord[2 * i] = cx + rx * Math.cos(ang); ord[2 * i + 1] = cy + ry * Math.sin(ang); } ord[2 * nsides] = ord[0]; ord[2 * nsides + 1] = ord[1]; return polygon(ord); } }
GeometryBuilder { public Polygon ellipse(double x1, double y1, double x2, double y2, int nsides) { double rx = Math.abs(x2 - x1) / 2; double ry = Math.abs(y2 - y1) / 2; double cx = Math.min(x1, x2) + rx; double cy = Math.min(y1, y2) + ry; double[] ord = new double[2 * nsides + 2]; double angInc = 2 * Math.PI / nsides; for (int i = 0; i < nsides; i++) { double ang = -(i * angInc); ord[2 * i] = cx + rx * Math.cos(ang); ord[2 * i + 1] = cy + ry * Math.sin(ang); } ord[2 * nsides] = ord[0]; ord[2 * nsides + 1] = ord[1]; return polygon(ord); } GeometryBuilder();  GeometryBuilder(GeometryFactory geomFact); }
GeometryBuilder { public Polygon ellipse(double x1, double y1, double x2, double y2, int nsides) { double rx = Math.abs(x2 - x1) / 2; double ry = Math.abs(y2 - y1) / 2; double cx = Math.min(x1, x2) + rx; double cy = Math.min(y1, y2) + ry; double[] ord = new double[2 * nsides + 2]; double angInc = 2 * Math.PI / nsides; for (int i = 0; i < nsides; i++) { double ang = -(i * angInc); ord[2 * i] = cx + rx * Math.cos(ang); ord[2 * i + 1] = cy + ry * Math.sin(ang); } ord[2 * nsides] = ord[0]; ord[2 * nsides + 1] = ord[1]; return polygon(ord); } GeometryBuilder();  GeometryBuilder(GeometryFactory geomFact); Point point(); Point pointZ(); Point point(double x); Point point(double x, double y); Point pointZ(double x, double y, double z); LineString lineString(); LineString lineStringZ(); LineString lineString(double... ord); LineString lineStringZ(double... ord); LinearRing linearRing(); LinearRing linearRingZ(); LinearRing linearRing(double... ord); LinearRing linearRingZ(double... ord); Polygon polygon(); Polygon polygonZ(); Polygon polygon(double... ord); Polygon polygonZ(double... ord); Polygon polygon(LinearRing shell); Polygon polygon(LinearRing shell, LinearRing hole); Polygon polygon(Polygon shell, Polygon hole); Polygon box(double x1, double y1, double x2, double y2); Polygon boxZ(double x1, double y1, double x2, double y2, double z); Polygon ellipse(double x1, double y1, double x2, double y2, int nsides); Polygon circle(double x, double y, double radius, int nsides); MultiPoint multiPoint(double x1, double y1, double x2, double y2); MultiPoint multiPointZ(
            double x1, double y1, double z1, double x2, double y2, double z2); MultiLineString multiLineString(LineString... lines); MultiPolygon multiPolygon(Polygon... polys); GeometryCollection geometryCollection(Geometry... geoms); }
GeometryBuilder { public Polygon ellipse(double x1, double y1, double x2, double y2, int nsides) { double rx = Math.abs(x2 - x1) / 2; double ry = Math.abs(y2 - y1) / 2; double cx = Math.min(x1, x2) + rx; double cy = Math.min(y1, y2) + ry; double[] ord = new double[2 * nsides + 2]; double angInc = 2 * Math.PI / nsides; for (int i = 0; i < nsides; i++) { double ang = -(i * angInc); ord[2 * i] = cx + rx * Math.cos(ang); ord[2 * i + 1] = cy + ry * Math.sin(ang); } ord[2 * nsides] = ord[0]; ord[2 * nsides + 1] = ord[1]; return polygon(ord); } GeometryBuilder();  GeometryBuilder(GeometryFactory geomFact); Point point(); Point pointZ(); Point point(double x); Point point(double x, double y); Point pointZ(double x, double y, double z); LineString lineString(); LineString lineStringZ(); LineString lineString(double... ord); LineString lineStringZ(double... ord); LinearRing linearRing(); LinearRing linearRingZ(); LinearRing linearRing(double... ord); LinearRing linearRingZ(double... ord); Polygon polygon(); Polygon polygonZ(); Polygon polygon(double... ord); Polygon polygonZ(double... ord); Polygon polygon(LinearRing shell); Polygon polygon(LinearRing shell, LinearRing hole); Polygon polygon(Polygon shell, Polygon hole); Polygon box(double x1, double y1, double x2, double y2); Polygon boxZ(double x1, double y1, double x2, double y2, double z); Polygon ellipse(double x1, double y1, double x2, double y2, int nsides); Polygon circle(double x, double y, double radius, int nsides); MultiPoint multiPoint(double x1, double y1, double x2, double y2); MultiPoint multiPointZ(
            double x1, double y1, double z1, double x2, double y2, double z2); MultiLineString multiLineString(LineString... lines); MultiPolygon multiPolygon(Polygon... polys); GeometryCollection geometryCollection(Geometry... geoms);  }