本文整理汇总了C++中Polygon::Add_Inner_Boundary方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygon::Add_Inner_Boundary方法的具体用法?C++ Polygon::Add_Inner_Boundary怎么用?C++ Polygon::Add_Inner_Boundary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon
的用法示例。
在下文中一共展示了Polygon::Add_Inner_Boundary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse_Polygon
Polygon* Polygon_Reader::Parse_Polygon(string line)
{
size_t start, end, pos;
std::string head_str, gml_str;
std::vector<std::string> temp_str_array;
std::vector<std::string> coord_array;
pos = line.find_first_of("<");
head_str = line.substr(0, pos);
split(head_str,':',temp_str_array);
gml_str = line.substr(pos);
start = gml_str.find_first_of("<");
end= gml_str.find_first_of(">");
std::string tag = gml_str.substr(start, end - start);
std::string tag_name = "";
start = tag.find_first_of("<");
tag_name = tag_name + tag.substr(start, tag.find_first_of(" ") - start);
tag_name = tag_name + ">";
tag_name.insert(1, "/");
start = end + 1;
end = gml_str.find(tag_name);
gml_str = gml_str.substr(start, end - start); //get rid of polygon tag
start = gml_str.find_first_of("<");
end = gml_str.find_first_of(">");
tag = gml_str.substr(start, end - start + 1);
tag_name = tag;
tag_name.insert(1, "/");
//remove the tags of the outerBoundary
start = end + 1;
end = gml_str.find(tag_name);
std::string tag_value = gml_str.substr(start, end - start);
gml_str = gml_str.substr(gml_str.find(tag_name) + tag_name.length()); //rest of the string after remove the outer Boundary part
start = tag_value.find("<gml:coordinates");
end = tag_value.find("</gml:coordinates");
std::string tmp_str = tag_value.substr(start, end - start);
std::string Coord = tmp_str.substr(tmp_str.find_first_of(">") + 1);
split(Coord, ' ', coord_array);
std::vector<std::string> xy_array;
LinearRing* lr_OB = new LinearRing();
for (std::string xy : coord_array){
split(xy, ',', xy_array);
lr_OB->Add_Point(new Point(stod(xy_array[0]), stod(xy_array[1])));
xy_array.clear();
}
OuterBoundary* OB = new OuterBoundary(lr_OB);
Polygon* poly = new Polygon(stoi(temp_str_array[1]), stoi(temp_str_array[2]), OB);
xy_array.clear();
coord_array.clear();
while (gml_str != "")
{
start = gml_str.find_first_of("<");
end = gml_str.find_first_of(">");
tag = gml_str.substr(start, end - start + 1);
if (tag.find("innerBoundaryIs")!= 0){
tag_name = tag;
tag_name.insert(1, "/");
start = end + 1;
end = gml_str.find(tag_name);
std::string tag_value = gml_str.substr(start, end - start);
gml_str = gml_str.substr(gml_str.find(tag_name) + tag_name.length());
start = tag_value.find("<gml:coordinates");
end = tag_value.find("</gml:coordinates");
tmp_str = tag_value.substr(start, end - start);
Coord = tmp_str.substr(tmp_str.find_first_of(">") + 1);
split(Coord, ' ', coord_array);
LinearRing* lr_IB = new LinearRing();
for (std::string xy: coord_array){
split(xy, ',', xy_array);
lr_IB->Add_Point(new Point(stod(xy_array[0]), stod(xy_array[1])));
xy_array.clear();
}
poly->Add_Inner_Boundary(new InnerBoundary(lr_IB));
xy_array.clear();
coord_array.clear();
}
}
return poly;
}