public Geometry buffer(double distance) { return point.buffer(distance); }
public Geometry buffer(double distance, int quadrantSegments, int endCapStyle) { return point.buffer(distance, quadrantSegments, endCapStyle); }
public Geometry buffer(double distance, int quadrantSegments) { return point.buffer(distance, quadrantSegments); }
@Override public Polygon getBuffer(double distance) { // convert to the target unit distance = converter.convert(distance); // buffer and return return (Polygon) center.buffer(distance, quadrantSegments); } }
private LineString circleArcInBounds( double x, double y, double radius, ReferencedEnvelope bounds) { Point center = gf.createPoint(new Coordinate(x, y)); Polygon buffered = (Polygon) center.buffer(radius, 64); Polygon mask = JTS.toGeometry(bounds); Geometry intersection = buffered.getExteriorRing().intersection(mask); return (LineString) intersection; }
@Test public void testFullyOutsideCircle() throws Exception { Point p = (Point) wkt.read("POINT(5 5)"); LineString ls = ((Polygon) p.buffer(10)).getExteriorRing(); Geometry clipped = clipper.clip(ls, false); assertNull(clipped); showResult("Circle around", ls, clipped); }
@Test public void testCrossingCircle() throws Exception { Point p = (Point) wkt.read("POINT(5 5)"); LineString ls = ((Polygon) p.buffer(6)).getExteriorRing(); MultiLineString clipped = (MultiLineString) clipper.clip(ls, false); assertEquals(4, clipped.getNumGeometries()); showResult("Circle around", ls, clipped); }
Geometry ptBuf = line.getPointN(i).buffer(dist); parts.add(ptBuf);
/** * Gets a geometry which represents the Minimum Bounding Circle. * If the input is degenerate (empty or a single unique point), * this method will return an empty geometry or a single Point geometry. * Otherwise, a Polygon will be returned which approximates the * Minimum Bounding Circle. * (Note that because the computed polygon is only an approximation, * it may not precisely contain all the input points.) * * @return a Geometry representing the Minimum Bounding Circle. */ public Geometry getCircle() { //TODO: ensure the output circle contains the extermal points. //TODO: or maybe even ensure that the returned geometry contains ALL the input points? compute(); if (centre == null) return input.getFactory().createPolygon(); Point centrePoint = input.getFactory().createPoint(centre); if (radius == 0.0) return centrePoint; return centrePoint.buffer(radius); }
private Coordinate[] createTestPoints(int nPts) { Point pt = geomFact.createPoint(new Coordinate(baseX, baseY)); Geometry circle = pt.buffer(2 * rectSize, nPts/4); return circle.getCoordinates(); }
private Coordinate[] createTestPoints(int nPts) { Point pt = geomFact.createPoint(new Coordinate(baseX, baseY)); Geometry circle = pt.buffer(2 * rectSize, nPts/4); return circle.getCoordinates(); }
@Test public void testCircles() throws Exception { if (isOSX) { System.out.println("skipping testCircles on OSX"); } else { final int buffers[] = new int[]{3, 5, 7, 8, 10, 15, 20}; for (int i = 0; i < buffers.length; i++) { Point p = new GeometryFactory().createPoint(new Coordinate(10, 10)); Geometry buffer = p.buffer(buffers[i]); ROIGeometry g = new ROIGeometry(buffer); ROIShape shape = getEquivalentROIShape(g); assertROIEquivalent(g, shape, "Circle"); } } }
@Test public void testXor() throws Exception { if (isOSX) { System.out.println("skipping testXor on OSX"); } else { Point p1 = new GeometryFactory().createPoint(new Coordinate(10, 10)); Point p2 = new GeometryFactory().createPoint(new Coordinate(20, 10)); Geometry buffer1 = p1.buffer(15); Geometry buffer2 = p2.buffer(15); ROIGeometry rg1 = new ROIGeometry(buffer1); ROIGeometry rg2 = new ROIGeometry(buffer2); ROI rgXor = rg1.exclusiveOr(rg2); ROIShape rs1 = getEquivalentROIShape(rg1); ROIShape rs2 = getEquivalentROIShape(rg2); ROI rsXor = rs1.exclusiveOr(rs2); assertROIEquivalent(rgXor, rsXor, "Xor"); } }
@Test @Ignore("not working on any platform ?") public void testUnion() throws Exception { Point p1 = new GeometryFactory().createPoint(new Coordinate(10, 10)); Point p2 = new GeometryFactory().createPoint(new Coordinate(20, 10)); Geometry buffer1 = p1.buffer(15); Geometry buffer2 = p2.buffer(15); ROIGeometry rg1 = new ROIGeometry(buffer1); ROIGeometry rg2 = new ROIGeometry(buffer2); ROIShape rs1 = getEquivalentROIShape(rg1); ROIShape rs2 = getEquivalentROIShape(rg2); assertROIEquivalent(rg1, rs1, "circle 1 ROIG, circle 1 ROIS"); assertROIEquivalent(rg2, rs2, "circle 2 ROIG, circle 2 ROIS"); }
@Test public void testSubtract() throws Exception { Point p1 = new GeometryFactory().createPoint(new Coordinate(10, 10)); Point p2 = new GeometryFactory().createPoint(new Coordinate(20, 10)); Geometry buffer1 = p1.buffer(15); Geometry buffer2 = p2.buffer(15); ROIGeometry rg1 = new ROIGeometry(buffer1); ROIGeometry rg2 = new ROIGeometry(buffer2); ROI rgSubtract = rg1.subtract(rg2); ROIShape rs1 = getEquivalentROIShape(rg1); ROIShape rs2 = getEquivalentROIShape(rg2); ROI rsSubtract = rs1.subtract(rs2); assertROIEquivalent(rgSubtract, rsSubtract, "Subtract"); }
@Test @Ignore("not working on any platform ?") public void testIntersect() throws Exception { Point p1 = new GeometryFactory().createPoint(new Coordinate(10, 10)); Point p2 = new GeometryFactory().createPoint(new Coordinate(20, 10)); Geometry buffer1 = p1.buffer(15); Geometry buffer2 = p2.buffer(15); ROIGeometry rg1 = new ROIGeometry(buffer1); ROIGeometry rg2 = new ROIGeometry(buffer2); ROI rgIntersection = rg1.intersect(rg2); ROIShape rs1 = getEquivalentROIShape(rg1); ROIShape rs2 = getEquivalentROIShape(rg2); ROI rsIntersection = rs1.intersect(rs2); assertROIEquivalent(rgIntersection, rsIntersection, "Intersection"); }