接着上一篇文章继续:(1247条消息) geometry 常用方法使用记录(一)_qiaobing1226的博客-CSDN博客
18. 两个几何的差集
public Geometry symDifference(Geometry other) {
if (this.isEmpty() || other.isEmpty()) {
if (this.isEmpty() && other.isEmpty()) {
return OverlayOp.createEmptyResult(4, this, other, this.factory);
}
if (this.isEmpty()) {
return other.copy();
}
if (other.isEmpty()) {
return this.copy();
}
}
checkNotGeometryCollection(this);
checkNotGeometryCollection(other);
return SnapIfNeededOverlayOp.overlayOp(this, other, 4);
}
19.返回几何体的缓冲区(一)
默认样式
public Geometry buffer(double distance) {
return BufferOp.bufferOp(this, distance);
}
20.返回几何体的缓冲区(二)
参数分别是:缓冲区宽度、端点圆弧样式
//线段末端样式 public static final int CAP_ROUND = 1; public static final int CAP_FLAT = 2; public static final int CAP_SQUARE = 3; //quadrantSegments 圆弧处,线段数量 public static final int JOIN_ROUND = 1; (默认)一个半圆 public static final int JOIN_MITRE = 2; 一条垂直于末端的直线 public static final int JOIN_BEVEL = 3; public static final int DEFAULT_QUADRANT_SEGMENTS = 8;
//源方法
public Geometry buffer(double distance, int quadrantSegments) {
return BufferOp.bufferOp(this, distance, quadrantSegments);
}
//调用示例
Geometry buffer = laneToQuery.buffer(bufferDis, BufferParameters.DEFAULT_QUADRANT_SEGMENTS);
圆弧线段数
quadrantSegments参数示例:JOIN_ROUND = 1
quadrantSegments参数示例:JOIN_ROUND = 2
quadrantSegments参数示例:JOIN_ROUND = 3
quadrantSegments参数示例:DEFAULT_QUADRANT_SEGMENTS = 8
21.返回几何体的缓冲区(三)
//源方法
public Geometry buffer(double distance, int quadrantSegments, int endCapStyle) {
return BufferOp.bufferOp(this, distance, quadrantSegments, endCapStyle);
}
//调用示例
Geometry buffer = laneToQuery.buffer(bufferDis, BufferParameters.DEFAULT_QUADRANT_SEGMENTS, BufferParameters.CAP_FLAT);
设置线段末尾端点样式
endCapStyle参数示例:CAP_ROUND = 1 (默认)一个半圆
endCapStyle参数示例:CAP_FLAT = 2 一条垂直于末端的直线
endCapStyle参数示例:CAP_SQUARE = 3
22.返回当前的几何的覆盖面几何
public Geometry convexHull() {
return (new ConvexHull(this)).getConvexHull();
}
23. 获取当前几何的边界
LinearRing boundary = (LinearRing) polygon.getBoundary();
参考:SFS-简单要素标准