使用 boost 的多边形联合
Posted
技术标签:
【中文标题】使用 boost 的多边形联合【英文标题】:polygons union using boost 【发布时间】:2014-03-11 09:46:17 【问题描述】:我正在使用 boost::geometry::union_ 来合并一个随机多边形向量,这里是我写的:
#include <iostream>
#include <vector>
#include <fstream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
#include <boost/foreach.hpp>
typedef boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double> > polygon;
void union_polys(std::vector<polygon> In_polys,std::vector<polygon> &Out_polys)
std::vector<polygon> temp_polys;
bool *considered = new bool [In_polys.size()];
for(unsigned i = 0 ; i < In_polys.size() ; i++) considered[i] = false;
for(unsigned i = 0 ; i < In_polys.size()/2; i++)
if(!considered[i])
polygon inetr = In_polys.at(i);
for(unsigned j = i + 1 ; j < In_polys.size() ; j++)
if(!considered[j])
temp_polys.clear();
boost::geometry::union_(inetr, In_polys.at(j) , temp_polys);
if(temp_polys.size() == 1)
inetr = temp_polys.at(0);
considered[j] = true;
j = i;
Out_polys.push_back(inetr);
int main()
std::ifstream file("test01.txt");
polygon *poly;
std::vector<polygon> input;
while(!file.eof())
poly = new polygon;
std::string poly_str;
std::getline(file, poly_str);
boost::geometry::read_wkt(poly_str, *poly);
boost::geometry::correct(*poly);
input.push_back(*poly);
std::cout << " input size is : " << input.size() << std::endl;
std::vector<polygon> output;
union_polys(input, output);
std::cout << " output size is : " << output.size() << std::endl;
int i = 0;
std::cout << "green || blue:" << std::endl;
BOOST_FOREACH(polygon const& p, output)
std::cout << i++ << ": " << boost::geometry::area(p) << std::endl;
system("pause");
return 0;
我用两个不同的多边形集测试了这个函数 union_polys:
test 01 test 02
第一次测试有效,第二次失败,我搜索了但我找不到错误,谁能帮忙?
【问题讨论】:
查看***.com/questions/20080868/… 了解支持的数据类型。 @DieterLücking 这有什么关系? @sehe 2D点正在使用double @DieterLücking 啊。我从来没有真正知道这一点。谢谢。无论如何,这可能不是这里的问题(除非自相交只是明显的/由于/浮点不准确) 关于积分坐标的注释是在谈论 Boost.Polygon,它是一个与 Boost.Geometry 不同的库 【参考方案1】:问题是您的第二个文件包含一个自相交的多边形。这是不允许的。
您可以通过定义来启用调试
#define BOOST_GEOMETRY_DEBUG_HAS_SELF_INTERSECTIONS
在包含 Boost Geometry 标头之前。
文档说:http://www.boost.org/doc/libs/1_55_0/libs/geometry/doc/html/geometry/reference/concepts/concept_polygon.html#geometry.reference.concepts.concept_polygon.rules
规则
除了对编译时进行检查的概念之外,还有一些有效多边形必须满足的其他规则。这遵循开放地理空间规则(参见上面的链接)。
多边形是简单的几何对象(另请参见 wiki,但 Boost.Geometry 多边形中允许有孔)。 如果 ring_type 下的多边形定义为顺时针方向,则外环必须具有顺时针方向,并且任何内环都必须反转 w.r.t。定义的方向(因此:对于顺时针外环,逆时针)。如果 ring_type 是逆时针定义的,反之亦然。 如果 ring_type 下的多边形定义为闭合的,则所有环都必须闭合:第一个点在空间上必须等于最后一个点。 内部是一个连通点集。 不应有自相交,但允许自相切(外环/内环之间)(只要内部是连通点集。 不应有切割线、尖刺或穿孔。 内环应位于外环内。内环不得位于彼此之内。交集、面积、质心、并集等算法不检查有效性。 将有一个算法
is_valid
在运行时检查这些规则的有效性,并且可以在之前(由库用户)调用。
所以目前,自交集仅在库的实现细节中可用
如果您不介意使用这些,例如使用以下方法清除有问题的多边形:
std::string poly_str;
while(std::getline(file, poly_str))
polygon poly;
boost::geometry::read_wkt(poly_str, poly);
boost::geometry::correct(poly);
try
bool ignored = boost::geometry::detail::overlay::has_self_intersections(poly);
// redundant:
if (ignored)
throw boost::geometry::overlay_invalid_input_exception();
input.push_back(std::move(poly));
catch(boost::geometry::overlay_invalid_input_exception const& e)
std::cerr << "Self intersecing polygon ignored: " << boost::geometry::dsv(poly) << "\n";
(注意从代码中删除内存泄漏和固定循环条件)
Self intersecing polygon ignored: (((449719, 4.04975e+06), (449720, 4.04976e+06), (449721, 4.04976e+06), (449727, 4.04976e+06), (449734, 4.04976e+06), (449736, 4.04976e+06), (449739, 4.04975e+06), (449742, 4.04975e+06), (449744, 4.04975e+06), (449745, 4.04974e+06), (449744, 4.04973e+06), (449741, 4.04973e+06), (449737, 4.04973e+06), (449734, 4.04973e+06), (449728, 4.04972e+06), (449725, 4.04972e+06), (449721, 4.04973e+06), (449716, 4.04973e+06), (449712, 4.04973e+06), (449711, 4.04974e+06), (449710, 4.04974e+06), (449711, 4.04975e+06), (449714, 4.04975e+06), (449718, 4.04976e+06), (449721, 4.04975e+06), (449721, 4.04975e+06), (449719, 4.04975e+06), (449718, 4.04974e+06), (449719, 4.04974e+06), (449719, 4.04974e+06), (449721, 4.04974e+06), (449724, 4.04973e+06), (449726, 4.04973e+06), (449728, 4.04973e+06), (449731, 4.04973e+06), (449733, 4.04973e+06), (449734, 4.04974e+06), (449736, 4.04974e+06), (449737, 4.04974e+06), (449736, 4.04975e+06), (449735, 4.04975e+06), (449734, 4.04975e+06), (449732, 4.04975e+06), (449731, 4.04975e+06), (449727, 4.04975e+06), (449724, 4.04975e+06), (449719, 4.04975e+06)))
Self intersecing polygon ignored: (((451355, 4.04939e+06), (451363, 4.0494e+06), (451365, 4.0494e+06), (451368, 4.0494e+06), (451369, 4.04939e+06), (451370, 4.04939e+06), (451368, 4.04938e+06), (451366, 4.04938e+06), (451362, 4.04938e+06), (451359, 4.04938e+06), (451355, 4.04938e+06), (451351, 4.04938e+06), (451347, 4.04938e+06), (451345, 4.04939e+06), (451345, 4.04939e+06), (451346, 4.04939e+06), (451348, 4.0494e+06), (451351, 4.0494e+06), (451355, 4.0494e+06), (451362, 4.0494e+06), (451356, 4.04939e+06), (451357, 4.04939e+06), (451355, 4.04939e+06), (451354, 4.04939e+06), (451354, 4.04939e+06), (451353, 4.04939e+06), (451353, 4.04939e+06), (451354, 4.04939e+06), (451355, 4.04939e+06), (451356, 4.04938e+06), (451358, 4.04938e+06), (451359, 4.04938e+06), (451360, 4.04939e+06), (451361, 4.04939e+06), (451361, 4.04939e+06), (451361, 4.04939e+06), (451361, 4.04939e+06), (451360, 4.04939e+06), (451355, 4.04939e+06)))
Self intersecing polygon ignored: (((451353, 4.04937e+06), (451361, 4.04938e+06), (451360, 4.04938e+06), (451380, 4.04937e+06), (451403, 4.04936e+06), (451427, 4.04936e+06), (451442, 4.04935e+06), (451466, 4.04934e+06), (451489, 4.04933e+06), (451508, 4.04932e+06), (451517, 4.04933e+06), (451518, 4.04933e+06), (451524, 4.04936e+06), (451526, 4.04937e+06), (451534, 4.04939e+06), (451541, 4.04942e+06), (451542, 4.04942e+06), (451557, 4.04944e+06), (451558, 4.04944e+06), (451577, 4.04946e+06), (451579, 4.04946e+06), (451601, 4.04947e+06), (451620, 4.04948e+06), (451630, 4.04949e+06), (451635, 4.0495e+06), (451640, 4.04952e+06), (451645, 4.04955e+06), (451646, 4.04955e+06), (451649, 4.04956e+06), (451654, 4.04959e+06), (451655, 4.04959e+06), (451660, 4.04962e+06), (451664, 4.04964e+06), (451669, 4.04966e+06), (451674, 4.04969e+06), (451675, 4.04969e+06), (451680, 4.04972e+06), (451686, 4.04974e+06), (451688, 4.04975e+06), (451696, 4.04977e+06), (451701, 4.04976e+06), (451696, 4.04975e+06), (451694, 4.04974e+06), (451689, 4.04972e+06), (451683, 4.04969e+06), (451682, 4.04969e+06), (451677, 4.04966e+06), (451673, 4.04964e+06), (451668, 4.04961e+06), (451663, 4.04959e+06), (451661, 4.04958e+06), (451655, 4.04955e+06), (451653, 4.04954e+06), (451653, 4.04954e+06), (451648, 4.04952e+06), (451642, 4.04949e+06), (451636, 4.04948e+06), (451624, 4.04947e+06), (451606, 4.04946e+06), (451584, 4.04945e+06), (451583, 4.04945e+06), (451564, 4.04944e+06), (451550, 4.04942e+06), (451549, 4.04941e+06), (451542, 4.04939e+06), (451535, 4.04937e+06), (451531, 4.04935e+06), (451526, 4.04933e+06), (451521, 4.04932e+06), (451509, 4.04931e+06), (451486, 4.04932e+06), (451463, 4.04933e+06), (451440, 4.04934e+06), (451424, 4.04935e+06), (451400, 4.04936e+06), (451377, 4.04936e+06), (451357, 4.04937e+06), (451353, 4.04937e+06)))
Self intersecing polygon ignored: (((451703, 4.04978e+06), (451693, 4.04978e+06), (451693, 4.04978e+06), (451691, 4.04978e+06), (451688, 4.04978e+06), (451686, 4.04978e+06), (451683, 4.04978e+06), (451681, 4.04978e+06), (451679, 4.04977e+06), (451678, 4.04977e+06), (451679, 4.04977e+06), (451680, 4.04977e+06), (451682, 4.04976e+06), (451685, 4.04976e+06), (451688, 4.04976e+06), (451691, 4.04976e+06), (451693, 4.04976e+06), (451694, 4.04977e+06), (451695, 4.04977e+06), (451693, 4.04978e+06), (451703, 4.04977e+06), (451704, 4.04977e+06), (451702, 4.04976e+06), (451699, 4.04976e+06), (451695, 4.04976e+06), (451689, 4.04975e+06), (451683, 4.04975e+06), (451678, 4.04976e+06), (451673, 4.04976e+06), (451670, 4.04977e+06), (451670, 4.04977e+06), (451672, 4.04978e+06), (451674, 4.04978e+06), (451679, 4.04979e+06), (451685, 4.04979e+06), (451690, 4.04979e+06), (451696, 4.04978e+06), (451700, 4.04978e+06), (451703, 4.04978e+06)))
Self intersecing polygon ignored: (((452873, 4.05001e+06), (452866, 4.05e+06), (452863, 4.05e+06), (452854, 4.04999e+06), (452841, 4.04998e+06), (452818, 4.04997e+06), (452817, 4.04997e+06), (452793, 4.04997e+06), (452783, 4.04997e+06), (452773, 4.04997e+06), (452750, 4.04998e+06), (452741, 4.04999e+06), (452737, 4.04999e+06), (452731, 4.04999e+06), (452719, 4.04998e+06), (452699, 4.04997e+06), (452685, 4.04997e+06), (452680, 4.04997e+06), (452680, 4.04997e+06), (452679, 4.04997e+06), (452679, 4.04996e+06), (452677, 4.04995e+06), (452678, 4.04995e+06), (452687, 4.04994e+06), (452697, 4.04994e+06), (452705, 4.04993e+06), (452713, 4.04992e+06), (452729, 4.04992e+06), (452747, 4.04992e+06), (452762, 4.04991e+06), (452772, 4.04991e+06), (452779, 4.04991e+06), (452770, 4.0499e+06), (452768, 4.0499e+06), (452759, 4.04991e+06), (452746, 4.04991e+06), (452728, 4.04991e+06), (452708, 4.04991e+06), (452699, 4.04992e+06), (452692, 4.04993e+06), (452683, 4.04994e+06), (452674, 4.04994e+06), (452668, 4.04994e+06), (452671, 4.04996e+06), (452670, 4.04997e+06), (452672, 4.04997e+06), (452674, 4.04998e+06), (452684, 4.04998e+06), (452698, 4.04998e+06), (452716, 4.04999e+06), (452729, 4.04999e+06), (452737, 4.05e+06), (452745, 4.04999e+06), (452753, 4.04999e+06), (452753, 4.04999e+06), (452776, 4.04998e+06), (452786, 4.04998e+06), (452793, 4.04998e+06), (452815, 4.04998e+06), (452837, 4.04999e+06), (452848, 4.05e+06), (452861, 4.05001e+06), (452873, 4.05001e+06)))
Self intersecing polygon ignored: (((452726, 4.04987e+06), (452733, 4.04986e+06), (452731, 4.04985e+06), (452730, 4.04985e+06), (452722, 4.04985e+06), (452722, 4.04985e+06), (452726, 4.04987e+06)))
Self intersecing polygon ignored: (((440107, 4.04713e+06), (440102, 4.04714e+06), (440112, 4.04717e+06), (440122, 4.04719e+06), (440132, 4.04721e+06), (440134, 4.04722e+06), (440143, 4.04724e+06), (440153, 4.04726e+06), (440163, 4.04728e+06), (440173, 4.04731e+06), (440183, 4.04733e+06), (440186, 4.04734e+06), (440196, 4.04736e+06), (440206, 4.04738e+06), (440215, 4.04741e+06), (440225, 4.04743e+06), (440227, 4.04744e+06), (440238, 4.04746e+06), (440247, 4.04748e+06), (440255, 4.0475e+06), (440259, 4.04752e+06), (440262, 4.04753e+06), (440267, 4.04754e+06), (440273, 4.04755e+06), (440289, 4.04756e+06), (440311, 4.04757e+06), (440325, 4.04758e+06), (440342, 4.04758e+06), (440346, 4.04759e+06), (440362, 4.0476e+06), (440363, 4.04761e+06), (440374, 4.04762e+06), (440388, 4.04763e+06), (440391, 4.04764e+06), (440392, 4.04765e+06), (440390, 4.04765e+06), (440382, 4.04768e+06), (440381, 4.04768e+06), (440378, 4.04769e+06), (440377, 4.04769e+06), (440376, 4.04769e+06), (440376, 4.04769e+06), (440375, 4.04767e+06), (440372, 4.04767e+06), (440368, 4.04766e+06), (440363, 4.04766e+06), (440356, 4.04766e+06), (440331, 4.04765e+06), (440319, 4.04765e+06), (440304, 4.04765e+06), (440288, 4.04765e+06), (440263, 4.04765e+06), (440253, 4.04765e+06), (440244, 4.04766e+06), (440238, 4.04767e+06), (440237, 4.04768e+06), (440238, 4.04768e+06), (440245, 4.04769e+06), (440258, 4.0477e+06), (440265, 4.04771e+06), (440270, 4.04772e+06), (440272, 4.04772e+06), (440271, 4.04774e+06), (440266, 4.04776e+06), (440266, 4.04777e+06), (440271, 4.04779e+06), (440276, 4.04781e+06), (440278, 4.04782e+06), (440277, 4.04783e+06), (440273, 4.04783e+06), (440266, 4.04784e+06), (440254, 4.04784e+06), (440237, 4.04785e+06), (440217, 4.04786e+06), (440214, 4.04786e+06), (440194, 4.04788e+06), (440191, 4.04788e+06), (440178, 4.0479e+06), (440170, 4.04791e+06), (440164, 4.04792e+06), (440158, 4.04794e+06), (440154, 4.04795e+06), (440147, 4.04795e+06), (440127, 4.04796e+06), (440106, 4.04796e+06), (440082, 4.04797e+06), (440079, 4.04797e+06), (440069, 4.04798e+06), (440061, 4.04798e+06), (440051, 4.04798e+06), (440028, 4.04797e+06), (440018, 4.04797e+06), (440006, 4.04797e+06), (439997, 4.04798e+06), (439986, 4.04798e+06), (439975, 4.04799e+06), (439964, 4.04801e+06), (439952, 4.04803e+06), (439950, 4.04804e+06), (439937, 4.04806e+06), (439931, 4.04807e+06), (439918, 4.04809e+06), (439905, 4.04811e+06), (439902, 4.04812e+06), (439892, 4.04814e+06), (439891, 4.04815e+06), (439893, 4.04816e+06), (439906, 4.04818e+06), (439917, 4.0482e+06), (439930, 4.04822e+06), (439930, 4.04822e+06), (439939, 4.04823e+06), (439953, 4.04824e+06), (439967, 4.04825e+06), (439970, 4.04825e+06), (439972, 4.04826e+06), (439971, 4.04826e+06), (439967, 4.04826e+06), (439951, 4.04827e+06), (439932, 4.04828e+06), (439913, 4.0483e+06), (439893, 4.04831e+06), (439874, 4.04833e+06), (439854, 4.04835e+06), (439845, 4.04835e+06), (439831, 4.04836e+06), (439818, 4.04837e+06), (439813, 4.04838e+06), (439816, 4.04839e+06), (439825, 4.04839e+06), (439835, 4.04839e+06), (439859, 4.04838e+06), (439884, 4.04838e+06), (439889, 4.04838e+06), (439914, 4.04837e+06), (439935, 4.04837e+06), (439959, 4.04836e+06), (439984, 4.04836e+06), (440009, 4.04836e+06), (440034, 4.04835e+06), (440058, 4.04835e+06), (440083, 4.04835e+06), (440108, 4.04834e+06), (440118, 4.04834e+06), (440143, 4.04834e+06), (440152, 4.04834e+06), (440166, 4.04834e+06), (440179, 4.04834e+06), (440200, 4.04835e+06), (440216, 4.04836e+06), (440230, 4.04837e+06), (440240, 4.04838e+06), (440251, 4.04839e+06), (440265, 4.04841e+06), (440265, 4.04841e+06), (440277, 4.04844e+06), (440283, 4.04845e+06), (440294, 4.04847e+06), (440301, 4.04849e+06), (440310, 4.04851e+06), (440319, 4.04853e+06), (440323, 4.04855e+06), (440324, 4.04856e+06), (440323, 4.04858e+06), (440319, 4.04861e+06), (440316, 4.04863e+06), (440310, 4.04865e+06), (440304, 4.04867e+06), (440303, 4.04868e+06), (440296, 4.04871e+06), (440294, 4.04871e+06), (440287, 4.04873e+06), (440281, 4.04874e+06), (440270, 4.04875e+06), (440254, 4.04877e+06), (440254, 4.04877e+06), (440241, 4.04879e+06), (440240, 4.0488e+06), (440235, 4.04881e+06), (440230, 4.04882e+06), (440226, 4.04885e+06), (440225, 4.04885e+06), (440217, 4.04887e+06), (440217, 4.04887e+06), (440206, 4.04889e+06), (440192, 4.04891e+06), (440186, 4.04892e+06), (440172, 4.04894e+06), (440157, 4.04896e+06), (440143, 4.04898e+06), (440136, 4.04899e+06), (440119, 4.04901e+06), (440103, 4.04903e+06), (440087, 4.04905e+06), (440071, 4.04907e+06), (440064, 4.04908e+06), (440047, 4.0491e+06), (440044, 4.0491e+06), (440054, 4.0491e+06), (440070, 4.04908e+06), (440077, 4.04907e+06), (440093, 4.04905e+06), (440110, 4.04904e+06), (440126, 4.04902e+06), (440142, 4.049e+06), (440149, 4.04899e+06), (440164, 4.04897e+06), (440178, 4.04895e+06), (440193, 4.04893e+06), (440199, 4.04892e+06), (440213, 4.0489e+06), (440224, 4.04888e+06), (440225, 4.04888e+06), (440233, 4.04885e+06), (440234, 4.04885e+06), (440238, 4.04883e+06), (440243, 4.04881e+06), (440247, 4.0488e+06), (440260, 4.04878e+06), (440276, 4.04876e+06), (440288, 4.04874e+06), (440294, 4.04873e+06), (440301, 4.04871e+06), (440304, 4.04871e+06), (440311, 4.04868e+06), (440312, 4.04868e+06), (440318, 4.04865e+06), (440324, 4.04863e+06), (440327, 4.04861e+06), (440331, 4.04858e+06), (440332, 4.04856e+06), (440332, 4.04855e+06), (440327, 4.04853e+06), (440327, 4.04853e+06), (440318, 4.0485e+06), (440309, 4.04848e+06), (440301, 4.04847e+06), (440291, 4.04844e+06), (440284, 4.04843e+06), (440272, 4.04841e+06), (440271, 4.04841e+06), (440257, 4.04839e+06), (440246, 4.04837e+06), (440236, 4.04836e+06), (440221, 4.04835e+06), (440203, 4.04834e+06), (440182, 4.04833e+06), (440168, 4.04833e+06), (440152, 4.04833e+06), (440140, 4.04833e+06), (440116, 4.04833e+06), (440107, 4.04834e+06), (440082, 4.04834e+06), (440057, 4.04834e+06), (440032, 4.04835e+06), (440007, 4.04835e+06), (439983, 4.04835e+06), (439958, 4.04836e+06), (439933, 4.04836e+06), (439912, 4.04836e+06), (439887, 4.04837e+06), (439883, 4.04837e+06), (439859, 4.04838e+06), (439834, 4.04838e+06), (439826, 4.04838e+06), (439823, 4.04838e+06), (439822, 4.04838e+06), (439825, 4.04837e+06), (439835, 4.04837e+06), (439849, 4.04836e+06), (439859, 4.04835e+06), (439879, 4.04834e+06), (439898, 4.04832e+06), (439918, 4.0483e+06), (439937, 4.04829e+06), (439955, 4.04828e+06), (439970, 4.04827e+06), (439978, 4.04827e+06), (439980, 4.04826e+06), (439978, 4.04825e+06), (439971, 4.04824e+06), (439957, 4.04823e+06), (439945, 4.04823e+06), (439937, 4.04822e+06), (439937, 4.04822e+06), (439924, 4.04819e+06), (439913, 4.04818e+06), (439901, 4.04816e+06), (439900, 4.04815e+06), (439900, 4.04814e+06), (439909, 4.04812e+06), (439912, 4.04812e+06), (439925, 4.04809e+06), (439939, 4.04807e+06), (439944, 4.04806e+06), (439957, 4.04804e+06), (439958, 4.04804e+06), (439970, 4.04802e+06), (439982, 4.048e+06), (439990, 4.04799e+06), (439999, 4.04798e+06), (440007, 4.04798e+06), (440018, 4.04798e+06), (440027, 4.04798e+06), (440050, 4.04798e+06), (440062, 4.04798e+06), (440071, 4.04798e+06), (440082, 4.04798e+06), (440085, 4.04798e+06), (440108, 4.04797e+06), (440129, 4.04796e+06), (440149, 4.04796e+06), (440159, 4.04796e+06), (440166, 4.04795e+06), (440172, 4.04793e+06), (440178, 4.04791e+06), (440184, 4.0479e+06), (440196, 4.04789e+06), (440199, 4.04789e+06), (440219, 4.04787e+06), (440221, 4.04787e+06), (440241, 4.04785e+06), (440256, 4.04785e+06), (440270, 4.04784e+06), (440279, 4.04784e+06), (440285, 4.04783e+06), (440286, 4.04782e+06), (440284, 4.04781e+06), (440279, 4.04778e+06), (440275, 4.04777e+06), (440275, 4.04776e+06), (440279, 4.04774e+06), (440280, 4.04772e+06), (440278, 4.04771e+06), (440272, 4.0477e+06), (440264, 4.04769e+06), (440250, 4.04768e+06), (440246, 4.04768e+06), (440245, 4.04768e+06), (440246, 4.04767e+06), (440250, 4.04767e+06), (440256, 4.04766e+06), (440264, 4.04766e+06), (440289, 4.04766e+06), (440304, 4.04766e+06), (440318, 4.04766e+06), (440329, 4.04766e+06), (440354, 4.04766e+06), (440359, 4.04767e+06), (440362, 4.04767e+06), (440365, 4.04767e+06), (440367, 4.04768e+06), (440368, 4.04769e+06), (440370, 4.04769e+06), (440376, 4.04769e+06), (440382, 4.04769e+06), (440388, 4.04769e+06), (440390, 4.04768e+06), (440398, 4.04766e+06), (440400, 4.04765e+06), (440399, 4.04764e+06), (440395, 4.04762e+06), (440380, 4.04761e+06), (440369, 4.0476e+06), (440368, 4.0476e+06), (440352, 4.04758e+06), (440345, 4.04757e+06), (440328, 4.04757e+06), (440315, 4.04756e+06), (440294, 4.04755e+06), (440278, 4.04754e+06), (440274, 4.04754e+06), (440270, 4.04753e+06), (440267, 4.04751e+06), (440263, 4.0475e+06), (440255, 4.04748e+06), (440246, 4.04746e+06), (440235, 4.04743e+06), (440232, 4.04743e+06), (440223, 4.0474e+06), (440213, 4.04738e+06), (440204, 4.04736e+06), (440194, 4.04733e+06), (440189, 4.04732e+06), (440179, 4.0473e+06), (440169, 4.04728e+06), (440159, 4.04725e+06), (440149, 4.04723e+06), (440139, 4.04721e+06), (440137, 4.0472e+06), (440127, 4.04718e+06), (440117, 4.04716e+06), (440107, 4.04713e+06)))
Self intersecing polygon ignored: (((440604, 4.04772e+06), (440595, 4.04772e+06), (440593, 4.04772e+06), (440593, 4.04773e+06), (440597, 4.04773e+06), (440601, 4.04774e+06), (440608, 4.04775e+06), (440618, 4.04776e+06), (440628, 4.04776e+06), (440638, 4.04776e+06), (440650, 4.04776e+06), (440642, 4.04775e+06), (440637, 4.04775e+06), (440630, 4.04775e+06), (440623, 4.04775e+06), (440615, 4.04774e+06), (440608, 4.04773e+06), (440603, 4.04773e+06), (440601, 4.04772e+06), (440601, 4.04772e+06), (440604, 4.04772e+06)))
Self intersecing polygon ignored: (((448423, 4.04808e+06), (448424, 4.04809e+06), (448446, 4.0481e+06), (448458, 4.04811e+06), (448479, 4.04812e+06), (448485, 4.04812e+06), (448504, 4.04814e+06), (448510, 4.04815e+06), (448525, 4.04817e+06), (448533, 4.04818e+06), (448546, 4.0482e+06), (448559, 4.04822e+06), (448572, 4.04824e+06), (448578, 4.04825e+06), (448582, 4.04822e+06), (448584, 4.04821e+06), (448595, 4.04819e+06), (448598, 4.04819e+06), (448613, 4.04817e+06), (448623, 4.04815e+06), (448643, 4.04814e+06), (448664, 4.04812e+06), (448671, 4.04812e+06), (448692, 4.0481e+06), (448712, 4.04809e+06), (448734, 4.04808e+06), (448756, 4.04807e+06), (448778, 4.04806e+06), (448800, 4.04804e+06), (448807, 4.04804e+06), (448798, 4.04804e+06), (448796, 4.04804e+06), (448774, 4.04805e+06), (448752, 4.04806e+06), (448730, 4.04807e+06), (448708, 4.04808e+06), (448687, 4.0481e+06), (448666, 4.04811e+06), (448658, 4.04812e+06), (448637, 4.04813e+06), (448617, 4.04815e+06), (448605, 4.04816e+06), (448591, 4.04818e+06), (448587, 4.04819e+06), (448576, 4.04821e+06), (448573, 4.04823e+06), (448568, 4.04825e+06), (448565, 4.04824e+06), (448557, 4.04822e+06), (448548, 4.04819e+06), (448540, 4.04817e+06), (448531, 4.04816e+06), (448516, 4.04814e+06), (448509, 4.04813e+06), (448490, 4.04812e+06), (448483, 4.04811e+06), (448462, 4.0481e+06), (448445, 4.04809e+06), (448423, 4.04808e+06)))
Self intersecing polygon ignored: (((448741, 4.04925e+06), (448751, 4.04925e+06), (448753, 4.04924e+06), (448755, 4.04923e+06), (448752, 4.04922e+06), (448747, 4.04922e+06), (448739, 4.04921e+06), (448729, 4.04921e+06), (448722, 4.04922e+06), (448715, 4.04922e+06), (448710, 4.04923e+06), (448708, 4.04924e+06), (448711, 4.04924e+06), (448716, 4.04925e+06), (448724, 4.04926e+06), (448733, 4.04926e+06), (448742, 4.04926e+06), (448750, 4.04925e+06), (448741, 4.04925e+06), (448738, 4.04925e+06), (448732, 4.04925e+06), (448727, 4.04925e+06), (448722, 4.04925e+06), (448718, 4.04924e+06), (448717, 4.04924e+06), (448718, 4.04923e+06), (448720, 4.04923e+06), (448726, 4.04923e+06), (448732, 4.04922e+06), (448736, 4.04922e+06), (448741, 4.04922e+06), (448745, 4.04923e+06), (448746, 4.04923e+06), (448745, 4.04924e+06), (448741, 4.04925e+06)))
Self intersecing polygon ignored: (((451354, 4.04907e+06), (451363, 4.04908e+06), (451384, 4.04907e+06), (451406, 4.04905e+06), (451427, 4.04904e+06), (451427, 4.04904e+06), (451432, 4.04902e+06), (451420, 4.04901e+06), (451403, 4.04903e+06), (451386, 4.04904e+06), (451385, 4.04905e+06), (451364, 4.04906e+06), (451362, 4.04906e+06), (451340, 4.04907e+06), (451325, 4.04909e+06), (451320, 4.0491e+06), (451305, 4.04912e+06), (451289, 4.04914e+06), (451288, 4.04914e+06), (451288, 4.04915e+06), (451287, 4.04916e+06), (451288, 4.04917e+06), (451296, 4.04917e+06), (451295, 4.04916e+06), (451296, 4.04914e+06), (451297, 4.04914e+06), (451311, 4.04912e+06), (451327, 4.0491e+06), (451330, 4.0491e+06), (451345, 4.04908e+06), (451366, 4.04907e+06), (451370, 4.04907e+06), (451390, 4.04905e+06), (451403, 4.04904e+06), (451420, 4.04902e+06), (451423, 4.04902e+06), (451420, 4.04903e+06), (451418, 4.04904e+06), (451397, 4.04905e+06), (451375, 4.04906e+06), (451354, 4.04907e+06)))
Self intersecing polygon ignored: (((455315, 4.04068e+06), (455309, 4.04068e+06), (455309, 4.04068e+06), (455284, 4.04068e+06), (455277, 4.04068e+06), (455252, 4.04068e+06), (455227, 4.04069e+06), (455203, 4.04069e+06), (455184, 4.04069e+06), (455160, 4.0407e+06), (455135, 4.0407e+06), (455111, 4.04071e+06), (455090, 4.04071e+06), (455065, 4.04072e+06), (455041, 4.04072e+06), (455026, 4.04073e+06), (455001, 4.04073e+06), (454976, 4.04073e+06), (454951, 4.04074e+06), (454929, 4.04074e+06), (454905, 4.04074e+06), (454880, 4.04075e+06), (454855, 4.04075e+06), (454830, 4.04075e+06), (454805, 4.04076e+06), (454791, 4.04076e+06), (454766, 4.04076e+06), (454758, 4.04076e+06), (454733, 4.04076e+06), (454717, 4.04076e+06), (454692, 4.04075e+06), (454667, 4.04075e+06), (454642, 4.04075e+06), (454618, 4.04075e+06), (454593, 4.04075e+06), (454568, 4.04074e+06), (454564, 4.04074e+06), (454539, 4.04074e+06), (454537, 4.04074e+06), (454512, 4.04074e+06), (454487, 4.04074e+06), (454462, 4.04074e+06), (454437, 4.04075e+06), (454412, 4.04075e+06), (454387, 4.04075e+06), (454362, 4.04075e+06), (454337, 4.04075e+06), (454313, 4.04075e+06), (454309, 4.04075e+06), (454285, 4.04075e+06), (454282, 4.04075e+06), (454258, 4.04076e+06), (454233, 4.04076e+06), (454208, 4.04076e+06), (454184, 4.04077e+06), (454176, 4.04077e+06), (454152, 4.04078e+06), (454131, 4.04078e+06), (454108, 4.04079e+06), (454084, 4.0408e+06), (454061, 4.04081e+06), (454050, 4.04081e+06), (454026, 4.04082e+06), (454003, 4.04083e+06), (453980, 4.04084e+06), (453956, 4.04085e+06), (453933, 4.04086e+06), (453910, 4.04087e+06), (453887, 4.04088e+06), (453863, 4.04089e+06), (453861, 4.04089e+06), (453838, 4.04089e+06), (453815, 4.0409e+06), (453791, 4.04091e+06), (453776, 4.04092e+06), (453784, 4.04092e+06), (453794, 4.04092e+06), (453818, 4.04091e+06), (453841, 4.0409e+06), (453864, 4.04089e+06), (453887, 4.04088e+06), (453911, 4.04088e+06), (453934, 4.04087e+06), (453957, 4.04086e+06), (453981, 4.04085e+06), (454004, 4.04084e+06), (454027, 4.04083e+06), (454051, 4.04082e+06), (454063, 4.04082e+06), (454087, 4.04081e+06), (454110, 4.0408e+06), (454133, 4.04079e+06), (454154, 4.04078e+06), (454178, 4.04078e+06), (454185, 4.04078e+06), (454210, 4.04077e+06), (454234, 4.04077e+06), (454259, 4.04076e+06), (454283, 4.04076e+06), (454285, 4.04076e+06), (454310, 4.04076e+06), (454313, 4.04076e+06), (454338, 4.04076e+06), (454363, 4.04076e+06), (454387, 4.04075e+06), (454412, 4.04075e+06), (454437, 4.04075e+06), (454462, 4.04075e+06), (454487, 4.04075e+06), (454512, 4.04075e+06), (454537, 4.04075e+06), (454538, 4.04075e+06), (454563, 4.04075e+06), (454567, 4.04075e+06), (454592, 4.04076e+06), (454617, 4.04076e+06), (454617, 4.04076e+06), (454642, 4.04076e+06), (454667, 4.04076e+06), (454692, 4.04076e+06), (454717, 4.04076e+06), (454733, 4.04077e+06), (454758, 4.04077e+06), (454767, 4.04077e+06), (454792, 4.04077e+06), (454806, 4.04076e+06), (454831, 4.04076e+06), (454856, 4.04076e+06), (454881, 4.04075e+06), (454906, 4.04075e+06), (454930, 4.04075e+06), (454953, 4.04074e+06), (454978, 4.04074e+06), (455002, 4.04074e+06), (455027, 4.04073e+06), (455042, 4.04073e+06), (455066, 4.04073e+06), (455091, 4.04072e+06), (455113, 4.04072e+06), (455137, 4.04071e+06), (455161, 4.04071e+06), (455186, 4.0407e+06), (455204, 4.0407e+06), (455228, 4.04069e+06), (455253, 4.04069e+06), (455278, 4.04069e+06), (455285, 4.04069e+06), (455310, 4.04068e+06), (455315, 4.04068e+06)))
【讨论】:
是的。修复输入,我想 所以在 boost 中没有什么可以自己做,好的。无论如何谢谢^^ @Mezmouz 我添加了一个基于库详细信息的简单想法。希望这会有所帮助(PS我已经解决了另外两个不相关的代码问题) @Mezmouz Boost 1.56.0 将is_valid
添加到 API itnerface以上是关于使用 boost 的多边形联合的主要内容,如果未能解决你的问题,请参考以下文章
Boost 多边形联合结果在 windows 和 linux 之间是不同的