本文整理汇总了C++中Geometry::Union方法的典型用法代码示例。如果您正苦于以下问题:C++ Geometry::Union方法的具体用法?C++ Geometry::Union怎么用?C++ Geometry::Union使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geometry
的用法示例。
在下文中一共展示了Geometry::Union方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: polygonize
std::vector<std::string> polygonize(const std::string &input1, const std::string &input2)
{
std::vector<std::string> result;
WKTReader wktr;
WKTWriter wktw;
Geometry *line1 = wktr.read(input1);
Geometry *line2 = wktr.read(input2);
// Unioning the linestrings inserts nodes for polygonization
Geometry *nodedLineStrings = line1->Union(line2);
// Add additional lineStrings to each end to close them off
LineString *ls1 = dynamic_cast<LineString*>(line1);
LineString *ls2 = dynamic_cast<LineString*>(line2);
Point *sp1 = ls1->getStartPoint();
Point *sp2 = ls2->getStartPoint();
Point *ep1 = ls1->getEndPoint();
Point *ep2 = ls2->getEndPoint();
Geometry *smallests = smallestSegment(sp1, ep1, sp2, ep2);
nodedLineStrings = nodedLineStrings->Union(smallests);
// Use GEOS to polygonize the strings
geos::operation::polygonize::Polygonizer polygonizer;
polygonizer.add(nodedLineStrings);
std::vector<Polygon*> *polygons = polygonizer.getPolygons();
for(int inx = 0; inx < polygons->size(); inx++){
result.push_back(wktw.write((*polygons)[inx]));
}
return result;
}