本文整理汇总了Java中com.vividsolutions.jts.operation.buffer.BufferParameters类的典型用法代码示例。如果您正苦于以下问题:Java BufferParameters类的具体用法?Java BufferParameters怎么用?Java BufferParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BufferParameters类属于com.vividsolutions.jts.operation.buffer包,在下文中一共展示了BufferParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
@Override
public Geometry call() {
bufferedGeom =PolygonOp.removeInteriorRing(bufferedGeom);
if(!bufferedGeom.isValid()){
bufferedGeom=JTSUtil.repair(bufferedGeom);
//System.out.println(Arrays.toString(bufferedGeom.getCoordinates()));
/*PrecisionModel pm=new PrecisionModel(PrecisionModel.FLOATING_SINGLE);
GeometryFactory gf = new GeometryFactory(pm);
Coordinate[]cc=new Coordinate[bufferedGeom.getCoordinates().length+1];
for(int i=0;i<bufferedGeom.getCoordinates().length;i++){
cc[i]=bufferedGeom.getCoordinates()[i];
}
cc[cc.length-1]=cc[0];
bufferedGeom=gf.createPolygon(cc);*/
}
bufferedGeom =BufferOp.bufferOp(bufferedGeom,bufferingDistance,BufferParameters.CAP_SQUARE,BufferParameters.DEFAULT_QUADRANT_SEGMENTS);
return bufferedGeom;
}
示例2: buffer
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
public IGeometry buffer(IGeometry geom, double distance, int nSegments,
int cap, int join) {
try {
Geometry jtsGeom = JtsGeOxygene.makeJtsGeom(geom);
BufferParameters bufferParam = new BufferParameters(nSegments, cap, join,
BufferParameters.DEFAULT_MITRE_LIMIT);
Geometry jtsBuffer = BufferOp.bufferOp(jtsGeom, distance, bufferParam);
return JtsGeOxygene.makeGeOxygeneGeom(jtsBuffer);
} catch (Exception e) {
JtsAlgorithms.logger.error(I18N.getString("JtsAlgorithms.BufferError")); //$NON-NLS-1$
if (JtsAlgorithms.logger.isDebugEnabled()) {
JtsAlgorithms.logger.debug(I18N
.getString("JtsAlgorithms.BufferDistance") + distance); //$NON-NLS-1$
JtsAlgorithms.logger.debug(I18N
.getString("JtsAlgorithms.BufferSegments") + nSegments); //$NON-NLS-1$
JtsAlgorithms.logger.debug(I18N.getString("JtsAlgorithms.Cap") + cap); //$NON-NLS-1$
JtsAlgorithms.logger
.debug(I18N.getString("JtsAlgorithms.Geometry") + ((geom != null) ? geom.toString() : I18N.getString("JtsAlgorithms.NullGeometry"))); //$NON-NLS-1$ //$NON-NLS-2$
JtsAlgorithms.logger.debug(e.getMessage());
}
e.printStackTrace();
return null;
}
}
示例3: cap
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
public static ILineString cap(ILineString line, double distance, boolean start) {
double d = Math.abs(distance);
try {
// removing duplicate coordinates from the input linestring.
LineString lineString = JtsAlgorithms
.getLineStringWithoutDuplicates((LineString) JtsGeOxygene
.makeJtsGeom(line));
Geometry buffer = lineString.buffer(d, 4, BufferParameters.CAP_ROUND);
Polygon polygon = null;
if (!(buffer instanceof Polygon)) {
JtsAlgorithms.logger.error("Can't compute offsetcurve of " + //$NON-NLS-1$
buffer.getGeometryType());
return null;
}
polygon = (Polygon) buffer;
// build the offset curve for the exterior ring
GM_LineString r = JtsAlgorithms.getCapFromRing(polygon.getExteriorRing(),
lineString, d, start);
return r;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例4: CurveBuilder
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
public CurveBuilder() {
BufferParameters bufferParameters = new BufferParameters();
bufferParameters.setEndCapStyle(BufferParameters.CAP_FLAT);
bufferParameters.setJoinStyle(BufferParameters.JOIN_ROUND);
/*
* Sets the number of line segments used to approximate an angle fillet.
*
* If quadSegs >= 1, joins are round, and quadSegs indicates the number of segments to use to approximate a quarter-circle.
* If quadSegs = 0, joins are bevelled (flat)
* If quadSegs < 0, joins are mitred, and the value of qs indicates the mitre ration limit as
* mitreLimit = |quadSegs|
*
* For round joins, quadSegs determines the maximum error in the approximation to the true buffer curve.
* The default value of 8 gives less than 2% max error in the buffer distance. For a max error of < 1%,
* use QS = 12. For a max error of < 0.1%, use QS = 18. The error is always less than the buffer distance
* (in other words, the computed buffer curve is always inside the true curve).
*/
bufferParameters.setQuadrantSegments(18);
this.curveBuilder = new OffsetCurveBuilder(new PrecisionModel(), bufferParameters);
}
示例5: addRoughOffsetCurves
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
private void addRoughOffsetCurves(Collection offsetCurves, Geometry sourceCurve, BufferParameters parameters, Double offsetDistance) {
OffsetCurveBuilder builder = new OffsetCurveBuilder(
sourceCurve.getFactory().getPrecisionModel(), parameters);
for (int i = 0; i < sourceCurve.getNumGeometries(); i++) {
if (sourceCurve.getGeometryN(i) instanceof LineString) {
LineString lineString = (LineString) sourceCurve.getGeometryN(i);
Coordinate[] cc = lineString.getCoordinates();
if (lineString.isClosed()) {
offsetCurves.add(lineString.getFactory().createLineString(
builder.getRingCurve(cc,
offsetDistance > 0 ? Position.LEFT : Position.RIGHT,
Math.abs(offsetDistance))));
} else {
offsetCurves.add(lineString.getFactory().createLineString(
builder.getOffsetCurve(cc, offsetDistance)));
}
}
}
}
示例6: bufferWithParams
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
/**
* Returns a buffered geometry with old shapes in the center of new ones. If
* the buffer is issued at single side then a negative offset renders the
* shape on the left while a positive offset on the right
*/
public static Geometry bufferWithParams(Geometry geometry, Double offset, Boolean singleSided, Integer quadrantSegments, Integer capStyle, Integer joinStyle, Double mitreLimit) {
double d = 0.0D;
if (offset != null) {
d = offset.doubleValue();
}
Boolean ss = false;
if (singleSided != null) {
ss = singleSided;
}
BufferParameters bufferparameters = new BufferParameters();
//Custom code to be able to draw only on the side of the offset curve
bufferparameters.setSingleSided(ss);
if (quadrantSegments != null) {
bufferparameters.setQuadrantSegments(quadrantSegments.intValue());
}
if (capStyle != null) {
bufferparameters.setEndCapStyle(capStyle.intValue());
}
if (joinStyle != null) {
bufferparameters.setJoinStyle(joinStyle.intValue());
}
if (mitreLimit != null) {
bufferparameters.setMitreLimit(mitreLimit.doubleValue());
}
return BufferOp.bufferOp(geometry, d, bufferparameters);
}
示例7: buffer
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
public static IGeometry buffer(IGeometry geom, int quad, int cap, int join,
double mitre, double distance) {
BufferBuilder bb = new BufferBuilder(
new BufferParameters(quad, cap, join, mitre));
IGeometry geom_ = null;
try {
geom_ = AdapterFactory.toGM_Object(bb.buffer(
AdapterFactory.toGeometry(new GeometryFactory(), geom), distance));
} catch (Exception e) {
e.printStackTrace();
}
return geom_;
}
示例8: buffer
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
public Shape buffer(Shape shape, Double distance, Map<String, Object> params) {
Geometry geometry = toGeometry(shape);
BufferParameters parameters = new BufferParameters();
if (params != null) {
bindParameters(parameters, params);
}
BufferOp ops = new BufferOp(geometry, parameters);
return toShape(ops.getResultGeometry(distance));
}
示例9: bindCap
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
private void bindCap(BufferParameters parameters, Map<String, Object> params) {
String endCap = (String) params.get("endCap");
if (endCap != null) {
Integer style = capStyles.get(endCap);
if (style != null) {
parameters.setEndCapStyle(style);
}
}
}
示例10: bindJoin
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
private void bindJoin(BufferParameters parameters, Map<String, Object> params) {
String join = (String) params.get("join");
if (join != null) {
Integer style = OShapeBuilder.join.get(join);
if (style != null) {
parameters.setJoinStyle(style);
}
}
}
示例11: bindMitre
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
private void bindMitre(BufferParameters parameters, Map<String, Object> params) {
Number mitre = (Number) params.get("mitre");
if (mitre != null) {
parameters.setMitreLimit(mitre.doubleValue());
}
}
示例12: bindQuad
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
private void bindQuad(BufferParameters parameters, Map<String, Object> params) {
Number quadSegs = (Number) params.get("quadSegs");
if (quadSegs != null) {
parameters.setQuadrantSegments(quadSegs.intValue());
}
}
示例13: getClippedTracesWithinBufferOf
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
public List<GpsTracePart> getClippedTracesWithinBufferOf(StreetSegment s) {
List<GpsTracePart> partList = new ArrayList<GpsTracePart>();
try {
double bufferDis = Double.valueOf(p.getProperty("streetBufferDistance"));
int bufferCap;
if (p.getProperty("bufferCap").equals("CAP_FLAT")){
bufferCap = BufferParameters.CAP_FLAT;
}else{
bufferCap = BufferParameters.CAP_ROUND;
}
Geometry buffer = s.getGeom().buffer(bufferDis, 5, bufferCap);
buffer.setSRID(4326);
pst.setBytes(1, wkbWriter.write(buffer));
pst.setBytes(2, wkbWriter.write(buffer));
pst.setInt(3, s.getId());
pst.setBytes(4, wkbWriter.write(buffer));
ResultSet rs1 = pst.executeQuery();
while (rs1.next()) {
int gpsId = rs1.getInt(p.getProperty("t_PpGpxIdCol"));
int trkId = rs1.getInt(p.getProperty("t_PpGpxTrkIdCol"));
int partId = rs1.getInt(p.getProperty("t_PpGpxPartIdCol"));
MultiLineString geom = Util.parseJson(rs1.getString(p.getProperty("t_PpGpxGeomCol")));
MultiLineString geomSmoothed = Util.parseJson(rs1.getString(p.getProperty("t_PpGpxGeomColSmoothed")));
partList.add(new GpsTracePart(gpsId, trkId, partId, geom, geomSmoothed));
}
} catch (SQLException e) {
e.printStackTrace();
}
return partList;
}
示例14: operand
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
@operator (
value = "clean",
category = { IOperatorCategory.SPATIAL, IOperatorCategory.SP_TRANSFORMATIONS },
concept = { IConcept.GEOMETRY, IConcept.SPATIAL_COMPUTATION, IConcept.SPATIAL_TRANSFORMATION })
@doc (
value = "A geometry corresponding to the cleaning of the operand (geometry, agent, point)",
comment = "The cleaning corresponds to a buffer with a distance of 0.0",
examples = { @example (
value = "clean(self)",
equals = "returns the geometry resulting from the cleaning of the geometry of the agent applying the operator.",
test = false) })
public static IShape clean(final IScope scope, final IShape g) {
if (g == null || g.getInnerGeometry() == null) { return g; }
if (g.getInnerGeometry() instanceof Polygon) { return new GamaShape(g, g.getInnerGeometry().buffer(0.0,
BufferParameters.DEFAULT_QUADRANT_SEGMENTS, BufferParameters.CAP_FLAT)); }
if (g.getInnerGeometry() instanceof MultiPolygon) {
final MultiPolygon mp = (MultiPolygon) g.getInnerGeometry();
final int nb = mp.getNumGeometries();
final Polygon[] polys = new Polygon[nb];
for (int i = 0; i < nb; i++) {
polys[i] = (Polygon) mp.getGeometryN(i).buffer(0.0, BufferParameters.DEFAULT_QUADRANT_SEGMENTS,
BufferParameters.CAP_FLAT);
}
return new GamaShape(g, GeometryUtils.GEOMETRY_FACTORY.createMultiPolygon(polys));
}
return g.copy(scope);
}
示例15: getCapAsInt
import com.vividsolutions.jts.operation.buffer.BufferParameters; //导入依赖的package包/类
public int getCapAsInt(){
int cap = -1;
if(bufferCap.equals(bufferCaps[0]))
cap = BufferParameters.CAP_FLAT;
if(bufferCap.equals(bufferCaps[1]))
cap = BufferParameters.CAP_ROUND;
if(bufferCap.equals(bufferCaps[2]))
cap = BufferParameters.CAP_SQUARE;
return cap;
}