本文整理汇总了C++中OGRLinearRing::get_Area方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRLinearRing::get_Area方法的具体用法?C++ OGRLinearRing::get_Area怎么用?C++ OGRLinearRing::get_Area使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRLinearRing
的用法示例。
在下文中一共展示了OGRLinearRing::get_Area方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: simplify
void Polygon::simplify(double distance_tolerance, double area_tolerance)
{
throwNoGeos();
auto deleteSmallRings = [area_tolerance](OGRGeometry *geom)
{
// Missing until GDAL 2.3.
// OGRPolygon *poly = geom->toPolygon();
OGRPolygon *poly = static_cast<OGRPolygon *>(geom);
std::vector<int> deleteRings;
for (int i = 0; i < poly->getNumInteriorRings(); ++i)
{
OGRLinearRing *lr = poly->getInteriorRing(i);
if (lr->get_Area() < area_tolerance)
deleteRings.push_back(i + 1);
}
// Note that interior rings are in a list with the exterior ring,
// which is why the ring numbers are offset by one when used in
// this context (what a mess).
for (auto i : deleteRings)
// Missing until 2.3
// poly->removeRing(i, true);
OGR_G_RemoveGeometry(gdal::toHandle(poly), i, true);
};
OGRGeometry *g = m_geom->SimplifyPreserveTopology(distance_tolerance);
m_geom.reset(g);
OGRwkbGeometryType t = m_geom->getGeometryType();
if (t == wkbPolygon || t == wkbPolygon25D)
deleteSmallRings(m_geom.get());
else if (t == wkbMultiPolygon || t == wkbMultiPolygon25D)
{
// Missing until 2.3
/**
OGRMultiPolygon *mpoly = m_geom->toMultiPolygon();
for (auto it = mpoly->begin(); it != mpoly->end(); ++it)
deleteSmallRings(*it);
**/
OGRMultiPolygon *mpoly = static_cast<OGRMultiPolygon *>(m_geom.get());
for (int i = 0; i < mpoly->getNumGeometries(); ++i)
deleteSmallRings(mpoly->getGeometryRef(i));
}
}
示例2: LoadGeometryPolygon
//.........这里部分代码省略.........
/* build rings */
poLinearRingList.clear();
int i = 1;
for (PointListArray::const_iterator iRing = poRingList.begin(), eRing = poRingList.end();
iRing != eRing; ++iRing) {
OGRPoint *poPoint;
PointList *poList = *iRing;
poLinearRingList.push_back(new OGRLinearRing());
poOgrRing = poLinearRingList.back();
CPLAssert(NULL != poOgrRing);
for (PointList::iterator iPoint = poList->begin(), ePoint = poList->end();
iPoint != ePoint; ++iPoint) {
poPoint = &(*iPoint);
poOgrRing->addPoint(poPoint);
}
i++;
}
/* find exterior ring */
if (poLinearRingList.size() > 1) {
double dArea, dMaxArea;
std::vector<OGRLinearRing *>::iterator exteriorRing;
exteriorRing = poLinearRingList.begin();
dMaxArea = -1.;
for (std::vector<OGRLinearRing *>::iterator iRing = poLinearRingList.begin(),
eRing = poLinearRingList.end(); iRing != eRing; ++iRing) {
poOgrRing = *iRing;
if (!IsRingClosed(poOgrRing))
continue; /* skip unclosed rings */
dArea = poOgrRing->get_Area();
if (dArea > dMaxArea) {
dMaxArea = dArea;
exteriorRing = iRing;
}
}
if (exteriorRing != poLinearRingList.begin()) {
std::swap(*poLinearRingList.begin(), *exteriorRing);
}
}
/* build polygon from rings */
for (std::vector<OGRLinearRing *>::iterator iRing = poLinearRingList.begin(),
eRing = poLinearRingList.end(); iRing != eRing; ++iRing) {
poOgrRing = *iRing;
/* check if ring is closed */
if (IsRingClosed(poOgrRing)) {
ogrPolygon.addRing(poOgrRing);
}
else {
if (poOgrRing->getNumPoints() == 2) {
CPLDebug("OGR-VFK", "%s: Polygon (fid = %ld) bridge removed",
m_pszName, iFID);
nBridges++;
}
else {
CPLDebug("OGR-VFK",
"%s: Polygon (fid = %ld) unclosed ring skipped",
m_pszName, iFID);
}
}
delete poOgrRing;