geom buffer制作
1. auto buffer_geom = line_string->buffer(15);//buffer //这个是x和y各扩大段15个单位
auto buffer_geom = line_string->buffer(15);//buffer //这个是x和y各扩大段15米
获取buffer坐标
auto boundary = buffer_geom->getBoundary();
auto boundary_coords = boundary->getCoordinates();
int numVertices = boundary_coords->size();
double minX = boundary_coords->getAt(0).x;
double maxX = boundary_coords->getAt(0).x;
double minY = boundary_coords->getAt(0).y;
double maxY = boundary_coords->getAt(0).y;
for (int i = 1; i < numVertices; ++i) {
auto coord = boundary_coords->getAt(i);
double x = coord.x;
double y = coord.y;
if (x < minX) minX = x;
if (x > maxX) maxX = x;
if (y < minY) minY = y;
if (y > maxY) maxY = y;
}
std::cout << "Min X: " << minX << ", Max X: " << maxX << std::endl;
std::cout << "Min Y: " << minY << ", Max Y: " << maxY << std::endl;
2. 这个才是沿着这条线段向两侧扩展15个单位
auto line_string = geos::geom::GeometryFactory::getDefaultInstance()->createLineString(std::move(coordinate_seq));
geos::operation::buffer::BufferParameters para;
para.setJoinStyle(geos::operation::buffer::BufferParameters::JOIN_MITRE);
para.setEndCapStyle(geos::operation::buffer::BufferParameters::CAP_FLAT);
geos::operation::buffer::BufferOp bufferOp(line_string.get(), para);
sp<geos::geom::Geometry> buffer_geom;
buffer_geom.reset(bufferOp.getResultGeometry(15));
原文地址:https://blog.csdn.net/C18304057755/article/details/140244513
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!