/** * Computes a buffer area around this geometry having the given width. The * buffer of a Geometry is the Minkowski sum or difference of the geometry * with a disc of radius <code>abs(distance)</code>. * <p> * Mathematically-exact buffer area boundaries can contain circular arcs. * To represent these arcs using linear geometry they must be approximated with line segments. * The buffer geometry is constructed using 8 segments per quadrant to approximate * the circular arcs. * The end cap style is <code>CAP_ROUND</code>. * <p> * The buffer operation always returns a polygonal result. The negative or * zero-distance buffer of lines and points is always an empty {@link Polygon}. * This is also the result for the buffers of degenerate (zero-area) polygons. * * @param distance * the width of the buffer (may be positive, negative or 0) * @return a polygonal geometry representing the buffer region (which may be * empty) * * @throws TopologyException * if a robustness error occurs * * @see #buffer(double, int) * @see #buffer(double, int, int) */ public Geometry buffer(double distance) { return BufferOp.bufferOp(this, distance); }
/** * Computes the buffer of a geometry for a given buffer distance. * * @param g the geometry to buffer * @param distance the buffer distance * @return the buffer of the input geometry */ public static Geometry bufferOp(Geometry g, double distance) { BufferOp gBuf = new BufferOp(g); Geometry geomBuf = gBuf.getResultGeometry(distance); //BufferDebug.saveBuffer(geomBuf); //BufferDebug.runCount++; return geomBuf; }
private void computeGeometry() { bufferOriginalPrecision(); if (resultGeometry != null) return; PrecisionModel argPM = argGeom.getFactory().getPrecisionModel(); if (argPM.getType() == PrecisionModel.FIXED) bufferFixedPrecision(argPM); else bufferReducedPrecision(); }
/** * Comutes the buffer for a geometry for a given buffer distance * and accuracy of approximation. * * @param g the geometry to buffer * @param distance the buffer distance * @param quadrantSegments the number of segments used to approximate a quarter circle * @return the buffer of the input geometry * */ public static Geometry bufferOp(Geometry g, double distance, int quadrantSegments) { BufferOp bufOp = new BufferOp(g); bufOp.setQuadrantSegments(quadrantSegments); Geometry geomBuf = bufOp.getResultGeometry(distance); return geomBuf; }
/** * Comutes the buffer for a geometry for a given buffer distance * and accuracy of approximation. * * @param g the geometry to buffer * @param distance the buffer distance * @param quadrantSegments the number of segments used to approximate a quarter circle * @param endCapStyle the end cap style to use * @return the buffer of the input geometry * */ public static Geometry bufferOp(Geometry g, double distance, int quadrantSegments, int endCapStyle) { BufferOp bufOp = new BufferOp(g); bufOp.setQuadrantSegments(quadrantSegments); bufOp.setEndCapStyle(endCapStyle); Geometry geomBuf = bufOp.getResultGeometry(distance); return geomBuf; }
private void bufferReducedPrecision(int precisionDigits) { double sizeBasedScaleFactor = precisionScaleFactor(argGeom, distance, precisionDigits); // System.out.println("recomputing with precision scale factor = " + sizeBasedScaleFactor); PrecisionModel fixedPM = new PrecisionModel(sizeBasedScaleFactor); bufferFixedPrecision(fixedPM); }
/** * Returns the buffer computed for a geometry for a given buffer distance. * * @param distance the buffer distance * @return the buffer of the input geometry */ public Geometry getResultGeometry(double distance) { this.distance = distance; computeGeometry(); return resultGeometry; }
private void bufferReducedPrecision() { // try and compute with decreasing precision for (int precDigits = MAX_PRECISION_DIGITS; precDigits >= 0; precDigits--) { try { bufferReducedPrecision(precDigits); } catch (TopologyException ex) { // update the saved exception to reflect the new input geometry saveException = ex; // don't propagate the exception - it will be detected by fact that resultGeometry is null } if (resultGeometry != null) return; } // tried everything - have to bail throw saveException; }
/** * Comutes the buffer for a geometry for a given buffer distance * and accuracy of approximation. * * @param g the geometry to buffer * @param distance the buffer distance * @param quadrantSegments the number of segments used to approximate a quarter circle * @param endCapStyle the end cap style to use * @return the buffer of the input geometry * */ public static Geometry bufferOp(Geometry g, double distance, int quadrantSegments, int endCapStyle) { BufferOp bufOp = new BufferOp(g); bufOp.setQuadrantSegments(quadrantSegments); bufOp.setEndCapStyle(endCapStyle); Geometry geomBuf = bufOp.getResultGeometry(distance); return geomBuf; }
/** * Comutes the buffer for a geometry for a given buffer distance * and accuracy of approximation. * * @param g the geometry to buffer * @param distance the buffer distance * @param quadrantSegments the number of segments used to approximate a quarter circle * @return the buffer of the input geometry * */ public static Geometry bufferOp(Geometry g, double distance, int quadrantSegments) { BufferOp bufOp = new BufferOp(g); bufOp.setQuadrantSegments(quadrantSegments); Geometry geomBuf = bufOp.getResultGeometry(distance); return geomBuf; }
private void bufferReducedPrecision(int precisionDigits) { double sizeBasedScaleFactor = precisionScaleFactor(argGeom, distance, precisionDigits); // System.out.println("recomputing with precision scale factor = " + sizeBasedScaleFactor); PrecisionModel fixedPM = new PrecisionModel(sizeBasedScaleFactor); bufferFixedPrecision(fixedPM); }
/** * Returns the buffer computed for a geometry for a given buffer distance. * * @param distance the buffer distance * @return the buffer of the input geometry */ public Geometry getResultGeometry(double distance) { this.distance = distance; computeGeometry(); return resultGeometry; }
private void bufferReducedPrecision() { // try and compute with decreasing precision for (int precDigits = MAX_PRECISION_DIGITS; precDigits >= 0; precDigits--) { try { bufferReducedPrecision(precDigits); } catch (TopologyException ex) { // update the saved exception to reflect the new input geometry saveException = ex; // don't propagate the exception - it will be detected by fact that resultGeometry is null } if (resultGeometry != null) return; } // tried everything - have to bail throw saveException; }
/** * Comutes the buffer for a geometry for a given buffer distance * and accuracy of approximation. * * @param g the geometry to buffer * @param distance the buffer distance * @param params the buffer parameters to use * @return the buffer of the input geometry * */ public static Geometry bufferOp(Geometry g, double distance, BufferParameters params) { BufferOp bufOp = new BufferOp(g, params); Geometry geomBuf = bufOp.getResultGeometry(distance); return geomBuf; }
return BufferOp.bufferOp(this, distance, quadrantSegments);
private void computeGeometry() { bufferOriginalPrecision(); if (resultGeometry != null) return; PrecisionModel argPM = argGeom.getFactory().getPrecisionModel(); if (argPM.getType() == PrecisionModel.FIXED) bufferFixedPrecision(argPM); else bufferReducedPrecision(); }
/** * Computes the buffer of a geometry for a given buffer distance. * * @param g the geometry to buffer * @param distance the buffer distance * @return the buffer of the input geometry */ public static Geometry bufferOp(Geometry g, double distance) { BufferOp gBuf = new BufferOp(g); Geometry geomBuf = gBuf.getResultGeometry(distance); //BufferDebug.saveBuffer(geomBuf); //BufferDebug.runCount++; return geomBuf; }
return BufferOp.bufferOp(this, distance, quadrantSegments, endCapStyle);
/** * Comutes the buffer for a geometry for a given buffer distance * and accuracy of approximation. * * @param g the geometry to buffer * @param distance the buffer distance * @param params the buffer parameters to use * @return the buffer of the input geometry * */ public static Geometry bufferOp(Geometry g, double distance, BufferParameters params) { BufferOp bufOp = new BufferOp(g, params); Geometry geomBuf = bufOp.getResultGeometry(distance); return geomBuf; }
/** * Calculate the ring buffer * * @param geom * @param bufferSize * @param bufferParameters * @return * @throws SQLException */ public static Geometry runBuffer(final Geometry geom, final double bufferSize, final BufferParameters bufferParameters) throws SQLException { return BufferOp.bufferOp(geom, bufferSize, bufferParameters); } }