/** * Buffer polygons by buffering the individual boundary segments and either unioning or * differencing them. * * @param g * @param distance * @return the buffer geometry */ public static Geometry bufferBySegments(Geometry g, double distance) { Geometry segs = LineHandlingFunctions.extractSegments(g); double posDist = Math.abs(distance); Geometry segBuf = bufferByComponents(segs, posDist); if (distance < 0.0) return g.difference(segBuf); return g.union(segBuf); }
public static Geometry bufferByChains(Geometry g, double distance, int maxChainSize) { if (maxChainSize <= 0) throw new IllegalArgumentException( "Maximum Chain Size must be specified as an input parameter"); Geometry segs = LineHandlingFunctions.extractChains(g, maxChainSize); double posDist = Math.abs(distance); Geometry segBuf = bufferByComponents(segs, posDist); if (distance < 0.0) return g.difference(segBuf); return g.union(segBuf); }