Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: S-101 driver 4 : * Purpose: Implements OGRS101LayerPoint 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 : /* OGRS101LayerPoint() */ 17 : /************************************************************************/ 18 : 19 150 : OGRS101LayerPoint::OGRS101LayerPoint(OGRS101Dataset &oDS, 20 : const DDFRecordIndex &oIndex, 21 : const std::vector<int> &anRecordIndices, 22 150 : OGRFeatureDefnRefCountedPtr poFeatureDefn) 23 150 : : OGRS101Layer(oDS, oIndex, std::move(poFeatureDefn)), 24 150 : m_anRecordIndices(anRecordIndices) 25 : { 26 150 : } 27 : 28 : /************************************************************************/ 29 : /* OGRS101LayerPoint::GetNextRawFeature() */ 30 : /************************************************************************/ 31 : 32 1035 : OGRFeature *OGRS101LayerPoint::GetNextRawFeature() 33 : { 34 1035 : if (m_nRecordIdx >= static_cast<int>(m_anRecordIndices.size())) 35 362 : return nullptr; 36 673 : ++m_nRecordIdx; 37 673 : return GetFeature(m_nRecordIdx); 38 : } 39 : 40 : /************************************************************************/ 41 : /* OGRS101LayerPoint::GetFeatureCount() */ 42 : /************************************************************************/ 43 : 44 135 : GIntBig OGRS101LayerPoint::GetFeatureCount(int bForce) 45 : { 46 135 : if (m_poAttrQuery || m_poFilterGeom) 47 54 : return OGRLayer::GetFeatureCount(bForce); 48 81 : return static_cast<GIntBig>(m_anRecordIndices.size()); 49 : } 50 : 51 : /************************************************************************/ 52 : /* OGRS101LayerPoint::GetFeature() */ 53 : /************************************************************************/ 54 : 55 718 : OGRFeature *OGRS101LayerPoint::GetFeature(GIntBig nFID) 56 : { 57 718 : if (nFID < 1 || nFID > static_cast<GIntBig>(m_anRecordIndices.size())) 58 27 : return nullptr; 59 1382 : auto poFeature = std::make_unique<OGRFeature>(m_poFeatureDefn.get()); 60 1382 : if (!m_oDS.GetReader().FillFeaturePoint( 61 691 : m_oIndex, m_anRecordIndices[static_cast<int>(nFID) - 1], 62 691 : *poFeature)) 63 : { 64 5 : return nullptr; 65 : } 66 686 : poFeature->SetFID(nFID); 67 : 68 686 : return poFeature.release(); 69 : }