接着上一篇文章继续:(1247条消息) geometry 常用方法使用记录(一)_qiaobing1226的博客-优快云博客
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-简单要素标准
本文介绍了geometry中关键的操作方法,包括两个几何体的差集计算、不同样式下的缓冲区创建及覆盖几何体的生成等。详细解释了缓冲区创建时的参数调整方法,并提供了具体的示例代码。
1089

被折叠的 条评论
为什么被折叠?



