public static Geometry bufferWithSegments(Geometry arg0, Double arg1, Integer arg2) { if (arg0 == null || arg1 == null || arg2 == null) return null; Geometry _this = arg0; return _this.buffer(arg1, arg2); }
public static Geometry buffer(Geometry arg0, Double arg1) { if (arg0 == null || arg1 == null) return null; Geometry _this = arg0; return _this.buffer(arg1); }
@Override public Geometry applyInset(Geometry footprint, Geometry granuleBounds, double inset) { if (footprint == null) { return null; } return footprint.buffer(-inset); } },
public Geometry buffer(double distance, int quadrantSegments) { return geometry.buffer(distance, quadrantSegments); }
public Geometry buffer(double distance, int quadrantSegments, int endCapStyle) { return geometry.buffer(distance, quadrantSegments, endCapStyle); }
public Geometry buffer(double distance) { return geometry.buffer(distance); }
private Geometry buffer(List<? extends Geometry> geometries, double distance) { List<Geometry> polygons = new ArrayList<Geometry>(); for (Geometry g : geometries) { Geometry buffered = g.buffer(distance); polygons.add(buffered); } return CascadedPolygonUnion.union(polygons); }
static Geometry repairInvalidPolygon(Geometry p) { if (p instanceof Polygon || p instanceof MultiPolygon) { // apply zero buffer trick Geometry ret = p.buffer(0); if (ret.getArea() > 0) { return ret; } LOGGER.fine("unable to repair invalid polygon"); return null; } return p; }
@Override public JtsGeometry getBuffered(double distance, SpatialContext ctx) { //TODO doesn't work correctly across the dateline. The buffering needs to happen // when it's transiently unrolled, prior to being sliced. return this.ctx.makeShape(geom.buffer(distance), true, true); }
@Override public Shape build() { Geometry geom = buildLineStringGeom(); if (bufDistance != 0.0) { geom = geom.buffer(bufDistance); } return makeShape(geom); }
private Geometry getConflictBounds(Geometry bounds, int spaceAround) { // apply the space around (with a negative one we might end up with nothing as the result) Geometry conflictBounds = bounds; if (spaceAround != 0) { conflictBounds = bounds.buffer(spaceAround); if (conflictBounds.isEmpty() || conflictBounds.getArea() == 0) { conflictBounds = null; } else { conflictBounds = new MinimumDiameter(conflictBounds).getMinimumRectangle(); } } return conflictBounds; }
private Geometry getGeometryBounds( Icon icon, Mark mark, Shape shape, double markSize, Object feature) { Geometry bounds; if (icon != null) { bounds = new GeometryBuilder().box(0, 0, icon.getIconWidth(), icon.getIconHeight()); } else { // the shape can be very complicated, go for the MBR. Wanted to use ShapeReader, but it // blindly assumes the shape is a polygon, while it may not be. Building a multipoint // instead AffineTransform at = AffineTransform.getScaleInstance(markSize, -markSize); Shape ts = at.createTransformedShape(shape); Geometry shapeGeometry = JTS.toGeometry(ts); bounds = new MinimumDiameter(shapeGeometry).getMinimumRectangle(); } // grow by the stroke size, if this is a mark if (icon == null && mark != null) { Stroke stroke = factory.getStroke(mark.getStroke(), feature); if (stroke instanceof BasicStroke) { float width = ((BasicStroke) stroke).getLineWidth() / 2 + 1; if (width > 0) { Geometry buffered = bounds.buffer(width); bounds = new MinimumDiameter(buffered).getMinimumRectangle(); } } } return bounds; }
/** Converts a distance buffer op to an intersects againt the buffered input geometry */ private Object visitDistanceBufferOperator( DistanceBufferOperator filter, boolean truth, Object extraData) { // SDE can assert only one way, we need to invert from contains to within in case the // assertion is the other way around PropertyName property; Literal literal; { Expression expression1 = filter.getExpression1(); Expression expression2 = filter.getExpression2(); if (expression1 instanceof PropertyName && expression2 instanceof Literal) { property = (PropertyName) expression1; literal = (Literal) expression2; } else if (expression2 instanceof PropertyName && expression1 instanceof Literal) { property = (PropertyName) expression2; literal = (Literal) expression1; } else { // not supported throw new IllegalArgumentException( "expected propertyname/literal, got " + expression1 + "/" + expression2); } } final Geometry geom = literal.evaluate(null, Geometry.class); final double distance = filter.getDistance(); final Geometry buffer = geom.buffer(distance); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(); BinarySpatialOperator intersects = ff.intersects(property, ff.literal(buffer)); addSpatialFilter(intersects, SeFilter.METHOD_II_OR_ET, truth, extraData); return extraData; }
if (quadrantSegments == null) quadrantSegments = BufferParameters.DEFAULT_QUADRANT_SEGMENTS; if (capStyle == null) capStyle = BufferCapStyle.Round; return geom.buffer(distance, quadrantSegments, capStyle.value);
g = new GeometrySnapper(g).snapTo(g, tol).buffer(0); roiGeometry = new ROIGeometry(g, setupJAIHints(hints)); roi = roi.intersect(roiGeometry); if (!isValid) { double tol = GeometrySnapper.computeOverlaySnapTolerance(g); g = new GeometrySnapper(g).snapTo(g, tol).buffer(0); roi = new ROIGeometry(g, setupJAIHints(hints)); roi = roi.intersect(roiGeometry);
public boolean hasNext() { while (next == null && delegate.hasNext()) { SimpleFeature f = delegate.next(); for (Object value : f.getAttributes()) { if (value instanceof Geometry) { Double fDistance = distance; if (this.attribute != null) { fDistance = Converters.convert( f.getAttribute(this.attribute), Double.class); } if (fDistance != null && fDistance != 0.0) { value = ((Geometry) value).buffer(fDistance); } } fb.add(value); } next = fb.buildFeature("" + count); count++; fb.reset(); } return next != null; }
@Test public void testInsidePolygon() throws Exception { Geometry g = wkt.read("POINT(5 5)").buffer(2); Geometry clipped = clipper.clip(g, false); assertTrue(g.equalsExact(clipped)); showResult("Polygon inside", g, clipped); }
@Test public void testOutsidePolygon() throws Exception { Geometry g = wkt.read("POINT(5 5)").buffer(10); Geometry clipped = clipper.clip(g, false); assertTrue(boundsPoly.equalsTopo(clipped)); showResult("Polygon outside", g, clipped); }
while (fi.hasNext()) { SimpleFeature f = fi.next(); fb.add(((Geometry) f.getDefaultGeometry()).buffer(distance)); result.add(fb.buildFeature(null));