/src/gdal/ogr/ogrsf_frmts/ili/ogrili2layer.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: Interlis 2 Translator |
4 | | * Purpose: Implements OGRILI2Layer class. |
5 | | * Author: Markus Schnider, Sourcepole AG |
6 | | * |
7 | | ****************************************************************************** |
8 | | * Copyright (c) 2004, Pirmin Kalberer, Sourcepole AG |
9 | | * Copyright (c) 2008-2012, Even Rouault <even dot rouault at spatialys.com> |
10 | | * |
11 | | * SPDX-License-Identifier: MIT |
12 | | ****************************************************************************/ |
13 | | |
14 | | #include "cpl_conv.h" |
15 | | #include "cpl_string.h" |
16 | | #include "ogr_ili2.h" |
17 | | |
18 | | /************************************************************************/ |
19 | | /* OGRILI2Layer() */ |
20 | | /************************************************************************/ |
21 | | |
22 | | OGRILI2Layer::OGRILI2Layer(OGRFeatureDefn *poFeatureDefnIn, |
23 | | const GeomFieldInfos &oGeomFieldInfosIn, |
24 | | OGRILI2DataSource *poDSIn) |
25 | 949 | : poFeatureDefn(poFeatureDefnIn), oGeomFieldInfos(oGeomFieldInfosIn), |
26 | 949 | poDS(poDSIn) |
27 | 949 | { |
28 | 949 | SetDescription(poFeatureDefn->GetName()); |
29 | 949 | poFeatureDefn->Reference(); |
30 | | |
31 | 949 | listFeatureIt = listFeature.begin(); |
32 | 949 | } |
33 | | |
34 | | /************************************************************************/ |
35 | | /* ~OGRILI2Layer() */ |
36 | | /************************************************************************/ |
37 | | |
38 | | OGRILI2Layer::~OGRILI2Layer() |
39 | 949 | { |
40 | 949 | if (poFeatureDefn) |
41 | 949 | poFeatureDefn->Release(); |
42 | | |
43 | 949 | listFeatureIt = listFeature.begin(); |
44 | 11.3k | while (listFeatureIt != listFeature.end()) |
45 | 10.3k | { |
46 | 10.3k | OGRFeature *poFeature = *(listFeatureIt++); |
47 | 10.3k | delete poFeature; |
48 | 10.3k | } |
49 | 949 | } |
50 | | |
51 | | /************************************************************************/ |
52 | | /* AddFeature() */ |
53 | | /************************************************************************/ |
54 | | |
55 | | void OGRILI2Layer::AddFeature(OGRFeature *poFeature) |
56 | 10.3k | { |
57 | 10.3k | poFeature->SetFID(static_cast<GIntBig>(1 + listFeature.size())); |
58 | 10.3k | listFeature.push_back(poFeature); |
59 | 10.3k | } |
60 | | |
61 | | /************************************************************************/ |
62 | | /* ResetReading() */ |
63 | | /************************************************************************/ |
64 | | |
65 | | void OGRILI2Layer::ResetReading() |
66 | 948 | { |
67 | 948 | listFeatureIt = listFeature.begin(); |
68 | 948 | } |
69 | | |
70 | | /************************************************************************/ |
71 | | /* GetNextFeature() */ |
72 | | /************************************************************************/ |
73 | | |
74 | | OGRFeature *OGRILI2Layer::GetNextFeature() |
75 | 8.92k | { |
76 | 8.92k | while (listFeatureIt != listFeature.end()) |
77 | 8.29k | { |
78 | 8.29k | OGRFeature *poFeature = *(listFeatureIt++); |
79 | | // apply filters |
80 | 8.29k | if ((m_poFilterGeom == nullptr || |
81 | 8.29k | FilterGeometry(poFeature->GetGeometryRef())) && |
82 | 8.29k | (m_poAttrQuery == nullptr || m_poAttrQuery->Evaluate(poFeature))) |
83 | 8.29k | return poFeature->Clone(); |
84 | 8.29k | } |
85 | 626 | return nullptr; |
86 | 8.92k | } |
87 | | |
88 | | /************************************************************************/ |
89 | | /* GetFeatureCount() */ |
90 | | /************************************************************************/ |
91 | | |
92 | | GIntBig OGRILI2Layer::GetFeatureCount(int bForce) |
93 | 0 | { |
94 | 0 | if (m_poFilterGeom == nullptr && m_poAttrQuery == nullptr) |
95 | 0 | { |
96 | 0 | return listFeature.size(); |
97 | 0 | } |
98 | 0 | else |
99 | 0 | { |
100 | 0 | return OGRLayer::GetFeatureCount(bForce); |
101 | 0 | } |
102 | 0 | } |
103 | | |
104 | | /************************************************************************/ |
105 | | /* TestCapability() */ |
106 | | /************************************************************************/ |
107 | | |
108 | | int OGRILI2Layer::TestCapability(CPL_UNUSED const char *pszCap) |
109 | 0 | { |
110 | 0 | if (EQUAL(pszCap, OLCCurveGeometries)) |
111 | 0 | return TRUE; |
112 | 0 | else if (EQUAL(pszCap, OLCZGeometries)) |
113 | 0 | return TRUE; |
114 | | |
115 | 0 | return FALSE; |
116 | 0 | } |
117 | | |
118 | | /************************************************************************/ |
119 | | /* GetDataset() */ |
120 | | /************************************************************************/ |
121 | | |
122 | | GDALDataset *OGRILI2Layer::GetDataset() |
123 | 0 | { |
124 | 0 | return poDS; |
125 | 0 | } |