Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: S-101 driver 4 : * Purpose: Implements OGRS101LayerFeatureType 5 : * Author: Even Rouault <even dot rouault at spatialys.com> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2026, Even Rouault <even dot rouault at spatialys.com> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #include "ogr_s101.h" 14 : 15 : /************************************************************************/ 16 : /* OGRS101LayerFeatureType() */ 17 : /************************************************************************/ 18 : 19 282 : OGRS101LayerFeatureType::OGRS101LayerFeatureType( 20 : OGRS101Dataset &oDS, const DDFRecordIndex &oIndex, 21 : const std::vector<int> &anRecordIndices, 22 282 : OGRFeatureDefnRefCountedPtr poFeatureDefn) 23 282 : : OGRS101Layer(oDS, oIndex, std::move(poFeatureDefn)), 24 282 : m_anRecordIndices(anRecordIndices) 25 : { 26 282 : } 27 : 28 : /************************************************************************/ 29 : /* OGRS101LayerFeatureType::GetNextRawFeature() */ 30 : /************************************************************************/ 31 : 32 1134 : OGRFeature *OGRS101LayerFeatureType::GetNextRawFeature() 33 : { 34 1134 : if (m_nRecordIdx >= static_cast<int>(m_anRecordIndices.size())) 35 446 : return nullptr; 36 688 : ++m_nRecordIdx; 37 688 : return GetFeature(m_nRecordIdx); 38 : } 39 : 40 : /************************************************************************/ 41 : /* OGRS101LayerFeatureType::GetFeatureCount() */ 42 : /************************************************************************/ 43 : 44 146 : GIntBig OGRS101LayerFeatureType::GetFeatureCount(int bForce) 45 : { 46 146 : if (m_poAttrQuery || m_poFilterGeom) 47 56 : return OGRLayer::GetFeatureCount(bForce); 48 90 : return static_cast<GIntBig>(m_anRecordIndices.size()); 49 : } 50 : 51 : /************************************************************************/ 52 : /* OGRS101LayerFeatureType::GetFeature() */ 53 : /************************************************************************/ 54 : 55 737 : OGRFeature *OGRS101LayerFeatureType::GetFeature(GIntBig nFID) 56 : { 57 737 : if (nFID < 1 || nFID > static_cast<GIntBig>(m_anRecordIndices.size())) 58 30 : return nullptr; 59 1414 : auto poFeature = std::make_unique<OGRFeature>(m_poFeatureDefn.get()); 60 1414 : if (!m_oDS.GetReader().FillFeatureFeatureType( 61 707 : m_oIndex, m_anRecordIndices[static_cast<size_t>(nFID) - 1], 62 707 : *poFeature)) 63 : { 64 9 : return nullptr; 65 : } 66 698 : poFeature->SetFID(nFID); 67 : 68 698 : return poFeature.release(); 69 : }