| 1598 | /************************************************************************/ |
| 1599 | |
| 1600 | static 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 |
no test coverage detected