public Polygon lineStringBuffer(LineString ls, double distance) {
if (distance <= 0) {
throw new IllegalArgumentException(
"very little distance in singleLineNoCapBuffer");
}
OverLayOp op = new OverLayOp();
PointBuffer pb = new PointBuffer();
// 开始点的缓冲
Polygon pg = pb.createBuffer(ls.firstPoint(), distance);
for (int i = 0, n = ls.size() - 1; i < n; i++) {
LineSegment lseg = ls.getLineSegment(i);
// 线的缓冲区
Polygon lineBuffer = singleLineNoCapBuffer(lseg, distance);
CPoint point = ls.getPoint(i + 1);
// 结尾点的缓冲
Polygon pointBuffer = pb.createBuffer(point, distance);
pg = op.computeUnion(lineBuffer, pg).getGeometry(0);
// debug
pg.isValid();
pg = op.computeUnion(pointBuffer, pg).getGeometry(0);
// debug
pg.isValid();
}