MCPcopy Create free account
hub / github.com/OSGeo/gdal / ProcessVectorZonesByFeature

Function ProcessVectorZonesByFeature

alg/zonal.cpp:1644–1897  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1642 }
1643
1644 bool ProcessVectorZonesByFeature(GDALProgressFunc pfnProgress,
1645 void *pProgressData)
1646 {
1647 if (!Init())
1648 {
1649 return false;
1650 }
1651
1652 OGREnvelope oGeomExtent;
1653 GDALRasterWindow oWindow;
1654
1655 std::unique_ptr<GDALDataset> poAlignedWeightsDS;
1656 // Align the weighting dataset to the values.
1657 if (m_weights)
1658 {
1659 bool resampled = false;
1660 poAlignedWeightsDS = GetVRT(*m_weights, m_src, resampled);
1661 if (!poAlignedWeightsDS)
1662 {
1663 return false;
1664 }
1665 if (resampled)
1666 {
1667 CPLError(CE_Warning, CPLE_AppDefined,
1668 "Resampled weights to match source raster using "
1669 "average resampling.");
1670 }
1671 }
1672
1673 size_t nBufSize = 0;
1674 size_t nBufXSize = 0;
1675 size_t nBufYSize = 0;
1676
1677 OGRLayer *poSrcLayer = std::get<OGRLayer *>(m_zones);
1678 OGRLayer *poDstLayer = GetOutputLayer(false);
1679 if (!poDstLayer)
1680 return false;
1681 size_t i = 0;
1682 auto nFeatures = poSrcLayer->GetFeatureCount();
1683 GDALRasterWindow oRasterWindow;
1684 oRasterWindow.nXOff = 0;
1685 oRasterWindow.nYOff = 0;
1686 oRasterWindow.nXSize = m_src.GetRasterXSize();
1687 oRasterWindow.nYSize = m_src.GetRasterYSize();
1688 const OGREnvelope oRasterExtent = ToEnvelope(oRasterWindow);
1689
1690 for (const auto &poFeature : *poSrcLayer)
1691 {
1692 const auto *poGeom = poFeature->GetGeometryRef();
1693
1694 oWindow.nXSize = 0;
1695 oWindow.nYSize = 0;
1696 if (poGeom == nullptr || poGeom->IsEmpty())
1697 {
1698 // do nothing
1699 }
1700 else if (poGeom->getDimension() != 2)
1701 {

Callers 1

ProcessFunction · 0.85

Calls 15

InitFunction · 0.85
GetVRTFunction · 0.85
CPLErrorFunction · 0.85
GetOutputLayerFunction · 0.85
ToEnvelopeFunction · 0.85
CreateStatsFunction · 0.85
SetStatFieldsFunction · 0.85
ReallocFunction · 0.85
CalculateCellCentersFunction · 0.85
CalculateCoverageFunction · 0.85
ReadWindowFunction · 0.85
UpdateStatsFunction · 0.85

Tested by

no test coverage detected