本文整理汇总了C++中GeometryCollection::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ GeometryCollection::empty方法的具体用法?C++ GeometryCollection::empty怎么用?C++ GeometryCollection::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeometryCollection
的用法示例。
在下文中一共展示了GeometryCollection::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: classifyRings
std::vector<GeometryCollection> classifyRings(const GeometryCollection& rings) {
std::vector<GeometryCollection> polygons;
std::size_t len = rings.size();
if (len <= 1) {
polygons.push_back(rings);
return polygons;
}
GeometryCollection polygon;
int8_t ccw = 0;
for (std::size_t i = 0; i < len; i++) {
double area = signedArea(rings[i]);
if (area == 0)
continue;
if (ccw == 0)
ccw = (area < 0 ? -1 : 1);
if (ccw == (area < 0 ? -1 : 1) && !polygon.empty()) {
polygons.push_back(polygon);
polygon.clear();
}
polygon.push_back(rings[i]);
}
if (!polygon.empty())
polygons.push_back(polygon);
return polygons;
}
示例2: clipLines
GeometryCollection clipLines(const GeometryCollection &lines,
const int16_t x1, const int16_t y1, const int16_t x2, const int16_t y2) {
GeometryCollection clippedLines;
for (auto& line : lines) {
if (line.empty())
continue;
auto end = line.end() - 1;
for (auto it = line.begin(); it != end; it++) {
GeometryCoordinate p0 = *(it);
GeometryCoordinate p1 = *(it + 1);
if (p0.x < x1 && p1.x < x1) {
continue;
} else if (p0.x < x1) {
p0 = { x1, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x)))) };
} else if (p1.x < x1) {
p1 = { x1, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x1 - p0.x) / (p1.x - p0.x)))) };
}
if (p0.y < y1 && p1.y < y1) {
continue;
} else if (p0.y < y1) {
p0 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y)))), y1 };
} else if (p1.y < y1) {
p1 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y1 - p0.y) / (p1.y - p0.y)))), y1 };
}
if (p0.x >= x2 && p1.x >= x2) {
continue;
} else if (p0.x >= x2) {
p0 = { x2, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x)))) };
} else if (p1.x >= x2) {
p1 = { x2, static_cast<int16_t>(::round(p0.y + (p1.y - p0.y) * ((float)(x2 - p0.x) / (p1.x - p0.x)))) };
}
if (p0.y >= y2 && p1.y >= y2) {
continue;
} else if (p0.y >= y2) {
p0 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y)))), y2 };
} else if (p1.y >= y2) {
p1 = { static_cast<int16_t>(::round(p0.x + (p1.x - p0.x) * ((float)(y2 - p0.y) / (p1.y - p0.y)))), y2 };
}
if (clippedLines.empty() || (!clippedLines.back().empty() && !(p0 == clippedLines.back().back()))) {
clippedLines.emplace_back();
clippedLines.back().push_back(p0);
}
clippedLines.back().push_back(p1);
}
}
return clippedLines;
}