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

Function TestOGRLayerFeatureCount

apps/test_ogrsf.cpp:1600–1768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1598/************************************************************************/
1599
1600static int TestOGRLayerFeatureCount(GDALDataset *poDS, OGRLayer *poLayer,
1601 int bIsSQLLayer)
1602
1603{
1604 int bRet = TRUE;
1605 GIntBig nFC = 0;
1606 GIntBig nClaimedFC = LOG_ACTION(poLayer->GetFeatureCount());
1607 bool bWarnAboutSRS = false;
1608 OGRFeatureDefn *poLayerDefn = LOG_ACTION(poLayer->GetLayerDefn());
1609 int nGeomFieldCount = LOG_ACTION(poLayerDefn->GetGeomFieldCount());
1610
1611 const bool bLayerHasMeasuredGeometriesCapability =
1612 CPL_TO_BOOL(poLayer->TestCapability(ODsCMeasuredGeometries));
1613 const bool bLayerHasCurveGeometriesCapability =
1614 CPL_TO_BOOL(poLayer->TestCapability(OLCCurveGeometries));
1615 const bool bLayerHasZGeometriesCapability =
1616 CPL_TO_BOOL(poLayer->TestCapability(OLCZGeometries));
1617
1618 CPLErrorReset();
1619
1620 for (auto &&poFeature : poLayer)
1621 {
1622 nFC++;
1623
1624 if (poFeature->GetDefnRef() != poLayerDefn)
1625 {
1626 bRet = FALSE;
1627 printf("ERROR: Feature defn differs from layer defn.\n"
1628 "Feature defn = %p\n"
1629 "Layer defn = %p\n",
1630 poFeature->GetDefnRef(), poLayerDefn);
1631 }
1632
1633 for (int iGeom = 0; iGeom < nGeomFieldCount; iGeom++)
1634 {
1635 OGRGeometry *poGeom = poFeature->GetGeomFieldRef(iGeom);
1636
1637 if (poGeom && poGeom->IsMeasured() &&
1638 !bLayerHasMeasuredGeometriesCapability)
1639 {
1640 bRet = FALSE;
1641 printf("FAILURE: Layer has a feature with measured geometries "
1642 "but no ODsCMeasuredGeometries capability!\n");
1643 }
1644 if (poGeom && poGeom->hasCurveGeometry() &&
1645 !bLayerHasCurveGeometriesCapability)
1646 {
1647 bRet = FALSE;
1648 printf("FAILURE: Layer has a feature with curved geometries "
1649 "but no OLCCurveGeometries capability!\n");
1650 }
1651 if (poGeom && poGeom->Is3D() && !bLayerHasZGeometriesCapability)
1652 {
1653 bRet = FALSE;
1654 printf("FAILURE: Layer has a feature with 3D geometries but no "
1655 "OLCZGeometries capability!\n");
1656 }
1657

Callers 1

TestOGRLayerFunction · 0.85

Calls 15

CPL_TO_BOOLFunction · 0.85
CPLStrdupFunction · 0.85
GetLayerNameForSQLFunction · 0.85
DestroyFeatureAndNullifyFunction · 0.85
GetGeomFieldRefMethod · 0.80
PrintfMethod · 0.80
GetFieldAsIntegerMethod · 0.80
GetFieldAsInteger64Method · 0.80
GetFeatureCountMethod · 0.45
GetLayerDefnMethod · 0.45
GetGeomFieldCountMethod · 0.45
TestCapabilityMethod · 0.45

Tested by

no test coverage detected