LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/ntf - ogrntffeatureclasslayer.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 0 47 0.0 %
Date: 2025-02-20 10:14:44 Functions: 0 8 0.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  UK NTF Reader
       4             :  * Purpose:  Implements OGRNTFFeatureClassLayer class.
       5             :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 1999, Frank Warmerdam
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "ntf.h"
      14             : #include "cpl_conv.h"
      15             : 
      16             : /************************************************************************/
      17             : /*                      OGRNTFFeatureClassLayer()                       */
      18             : /*                                                                      */
      19             : /*      Note that the OGRNTFLayer assumes ownership of the passed       */
      20             : /*      OGRFeatureDefn object.                                          */
      21             : /************************************************************************/
      22             : 
      23           0 : OGRNTFFeatureClassLayer::OGRNTFFeatureClassLayer(OGRNTFDataSource *poDSIn)
      24           0 :     : poFeatureDefn(new OGRFeatureDefn("FEATURE_CLASSES")),
      25           0 :       poFilterGeom(nullptr), poDS(poDSIn), iCurrentFC(0)
      26             : {
      27             :     /* -------------------------------------------------------------------- */
      28             :     /*      Establish the schema.                                           */
      29             :     /* -------------------------------------------------------------------- */
      30           0 :     SetDescription(poFeatureDefn->GetName());
      31           0 :     poFeatureDefn->SetGeomType(wkbNone);
      32           0 :     poFeatureDefn->Reference();
      33             : 
      34           0 :     OGRFieldDefn oFCNum("FEAT_CODE", OFTString);
      35             : 
      36           0 :     oFCNum.SetWidth(4);
      37           0 :     poFeatureDefn->AddFieldDefn(&oFCNum);
      38             : 
      39           0 :     OGRFieldDefn oFCName("FC_NAME", OFTString);
      40             : 
      41           0 :     oFCNum.SetWidth(80);
      42           0 :     poFeatureDefn->AddFieldDefn(&oFCName);
      43           0 : }
      44             : 
      45             : /************************************************************************/
      46             : /*                      ~OGRNTFFeatureClassLayer()                      */
      47             : /************************************************************************/
      48             : 
      49           0 : OGRNTFFeatureClassLayer::~OGRNTFFeatureClassLayer()
      50             : 
      51             : {
      52           0 :     if (poFeatureDefn)
      53           0 :         poFeatureDefn->Release();
      54             : 
      55           0 :     if (poFilterGeom != nullptr)
      56           0 :         delete poFilterGeom;
      57           0 : }
      58             : 
      59             : /************************************************************************/
      60             : /*                            ResetReading()                            */
      61             : /************************************************************************/
      62             : 
      63           0 : void OGRNTFFeatureClassLayer::ResetReading()
      64             : 
      65             : {
      66           0 :     iCurrentFC = 0;
      67           0 : }
      68             : 
      69             : /************************************************************************/
      70             : /*                           GetNextFeature()                           */
      71             : /************************************************************************/
      72             : 
      73           0 : OGRFeature *OGRNTFFeatureClassLayer::GetNextFeature()
      74             : 
      75             : {
      76           0 :     if (iCurrentFC >= GetFeatureCount())
      77           0 :         return nullptr;
      78             : 
      79           0 :     return GetFeature((long)iCurrentFC++);
      80             : }
      81             : 
      82             : /************************************************************************/
      83             : /*                             GetFeature()                             */
      84             : /************************************************************************/
      85             : 
      86           0 : OGRFeature *OGRNTFFeatureClassLayer::GetFeature(GIntBig nFeatureId)
      87             : 
      88             : {
      89             :     char *pszFCName, *pszFCId;
      90             : 
      91           0 :     if (nFeatureId < 0 || nFeatureId >= poDS->GetFCCount())
      92           0 :         return nullptr;
      93             : 
      94           0 :     poDS->GetFeatureClass((int)nFeatureId, &pszFCId, &pszFCName);
      95             : 
      96             :     /* -------------------------------------------------------------------- */
      97             :     /*      Create a corresponding feature.                                 */
      98             :     /* -------------------------------------------------------------------- */
      99           0 :     OGRFeature *poFeature = new OGRFeature(poFeatureDefn);
     100             : 
     101           0 :     poFeature->SetField(0, pszFCId);
     102           0 :     poFeature->SetField(1, pszFCName);
     103           0 :     poFeature->SetFID(nFeatureId);
     104             : 
     105           0 :     return poFeature;
     106             : }
     107             : 
     108             : /************************************************************************/
     109             : /*                          GetFeatureCount()                           */
     110             : /*                                                                      */
     111             : /*      If a spatial filter is in effect, we turn control over to       */
     112             : /*      the generic counter.  Otherwise we return the total count.      */
     113             : /*      Eventually we should consider implementing a more efficient     */
     114             : /*      way of counting features matching a spatial query.              */
     115             : /************************************************************************/
     116             : 
     117           0 : GIntBig OGRNTFFeatureClassLayer::GetFeatureCount(CPL_UNUSED int bForce)
     118             : {
     119           0 :     return poDS->GetFCCount();
     120             : }
     121             : 
     122             : /************************************************************************/
     123             : /*                           TestCapability()                           */
     124             : /************************************************************************/
     125             : 
     126           0 : int OGRNTFFeatureClassLayer::TestCapability(const char *pszCap)
     127             : 
     128             : {
     129           0 :     if (EQUAL(pszCap, OLCRandomRead))
     130           0 :         return TRUE;
     131             : 
     132           0 :     else if (EQUAL(pszCap, OLCSequentialWrite) || EQUAL(pszCap, OLCRandomWrite))
     133           0 :         return FALSE;
     134             : 
     135           0 :     else if (EQUAL(pszCap, OLCFastFeatureCount))
     136           0 :         return TRUE;
     137             : 
     138           0 :     else if (EQUAL(pszCap, OLCFastSpatialFilter))
     139           0 :         return TRUE;
     140             : 
     141             :     else
     142           0 :         return FALSE;
     143             : }

Generated by: LCOV version 1.14