/src/gdal/ogr/ogrsf_frmts/generic/ogrlayerpool.cpp
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: OpenGIS Simple Features Reference Implementation |
4 | | * Purpose: Defines OGRLayerPool and OGRProxiedLayer class |
5 | | * Author: Even Rouault, even dot rouault at spatialys.com |
6 | | * |
7 | | ****************************************************************************** |
8 | | * Copyright (c) 2012-2013, Even Rouault <even dot rouault at spatialys.com> |
9 | | * |
10 | | * SPDX-License-Identifier: MIT |
11 | | ****************************************************************************/ |
12 | | |
13 | | #ifndef DOXYGEN_SKIP |
14 | | |
15 | | #include "ogrlayerpool.h" |
16 | | #include "ogr_recordbatch.h" |
17 | | |
18 | | /************************************************************************/ |
19 | | /* OGRAbstractProxiedLayer() */ |
20 | | /************************************************************************/ |
21 | | |
22 | | OGRAbstractProxiedLayer::OGRAbstractProxiedLayer(OGRLayerPool *poPoolIn) |
23 | 0 | : poPrevLayer(nullptr), poNextLayer(nullptr), poPool(poPoolIn) |
24 | 0 | { |
25 | 0 | CPLAssert(poPoolIn != nullptr); |
26 | 0 | } |
27 | | |
28 | | /************************************************************************/ |
29 | | /* ~OGRAbstractProxiedLayer() */ |
30 | | /************************************************************************/ |
31 | | |
32 | | OGRAbstractProxiedLayer::~OGRAbstractProxiedLayer() |
33 | 0 | { |
34 | | /* Remove us from the list of LRU layers if necessary */ |
35 | 0 | poPool->UnchainLayer(this); |
36 | 0 | } |
37 | | |
38 | | /************************************************************************/ |
39 | | /* OGRLayerPool() */ |
40 | | /************************************************************************/ |
41 | | |
42 | | OGRLayerPool::OGRLayerPool(int nMaxSimultaneouslyOpenedIn) |
43 | 0 | : poMRULayer(nullptr), poLRULayer(nullptr), nMRUListSize(0), |
44 | 0 | nMaxSimultaneouslyOpened(nMaxSimultaneouslyOpenedIn) |
45 | 0 | { |
46 | 0 | } |
47 | | |
48 | | /************************************************************************/ |
49 | | /* ~OGRLayerPool() */ |
50 | | /************************************************************************/ |
51 | | |
52 | | OGRLayerPool::~OGRLayerPool() |
53 | 0 | { |
54 | 0 | CPLAssert(poMRULayer == nullptr); |
55 | 0 | CPLAssert(poLRULayer == nullptr); |
56 | 0 | CPLAssert(nMRUListSize == 0); |
57 | 0 | } |
58 | | |
59 | | /************************************************************************/ |
60 | | /* SetLastUsedLayer() */ |
61 | | /************************************************************************/ |
62 | | |
63 | | void OGRLayerPool::SetLastUsedLayer(OGRAbstractProxiedLayer *poLayer) |
64 | 0 | { |
65 | | /* If we are already the MRU layer, nothing to do */ |
66 | 0 | if (poLayer == poMRULayer) |
67 | 0 | return; |
68 | | |
69 | | // CPLDebug("OGR", "SetLastUsedLayer(%s)", poLayer->GetName()); |
70 | | |
71 | 0 | if (poLayer->poPrevLayer != nullptr || poLayer->poNextLayer != nullptr) |
72 | 0 | { |
73 | | /* Remove current layer from its current place in the list */ |
74 | 0 | UnchainLayer(poLayer); |
75 | 0 | } |
76 | 0 | else if (nMRUListSize == nMaxSimultaneouslyOpened) |
77 | 0 | { |
78 | | /* If we have reached the maximum allowed number of layers */ |
79 | | /* simultaneously opened, then close the LRU one that */ |
80 | | /* was still active until now */ |
81 | 0 | CPLAssert(poLRULayer != nullptr); |
82 | | |
83 | 0 | poLRULayer->CloseUnderlyingLayer(); |
84 | 0 | UnchainLayer(poLRULayer); |
85 | 0 | } |
86 | | |
87 | | /* Put current layer on top of MRU list */ |
88 | 0 | CPLAssert(poLayer->poPrevLayer == nullptr); |
89 | 0 | CPLAssert(poLayer->poNextLayer == nullptr); |
90 | 0 | poLayer->poNextLayer = poMRULayer; |
91 | 0 | if (poMRULayer != nullptr) |
92 | 0 | { |
93 | 0 | CPLAssert(poMRULayer->poPrevLayer == nullptr); |
94 | 0 | poMRULayer->poPrevLayer = poLayer; |
95 | 0 | } |
96 | 0 | poMRULayer = poLayer; |
97 | 0 | if (poLRULayer == nullptr) |
98 | 0 | poLRULayer = poLayer; |
99 | 0 | nMRUListSize++; |
100 | 0 | } |
101 | | |
102 | | /************************************************************************/ |
103 | | /* UnchainLayer() */ |
104 | | /************************************************************************/ |
105 | | |
106 | | void OGRLayerPool::UnchainLayer(OGRAbstractProxiedLayer *poLayer) |
107 | 0 | { |
108 | 0 | OGRAbstractProxiedLayer *poPrevLayer = poLayer->poPrevLayer; |
109 | 0 | OGRAbstractProxiedLayer *poNextLayer = poLayer->poNextLayer; |
110 | |
|
111 | 0 | CPLAssert(poPrevLayer == nullptr || poPrevLayer->poNextLayer == poLayer); |
112 | 0 | CPLAssert(poNextLayer == nullptr || poNextLayer->poPrevLayer == poLayer); |
113 | | |
114 | 0 | if (poPrevLayer != nullptr || poNextLayer != nullptr || |
115 | 0 | poLayer == poMRULayer) |
116 | 0 | nMRUListSize--; |
117 | |
|
118 | 0 | if (poLayer == poMRULayer) |
119 | 0 | poMRULayer = poNextLayer; |
120 | 0 | if (poLayer == poLRULayer) |
121 | 0 | poLRULayer = poPrevLayer; |
122 | 0 | if (poPrevLayer != nullptr) |
123 | 0 | poPrevLayer->poNextLayer = poNextLayer; |
124 | 0 | if (poNextLayer != nullptr) |
125 | 0 | poNextLayer->poPrevLayer = poPrevLayer; |
126 | 0 | poLayer->poPrevLayer = nullptr; |
127 | 0 | poLayer->poNextLayer = nullptr; |
128 | 0 | } |
129 | | |
130 | | /************************************************************************/ |
131 | | /* OGRProxiedLayer() */ |
132 | | /************************************************************************/ |
133 | | |
134 | | static void ReleaseDelete(OGRLayer *poLayer, void *) |
135 | 0 | { |
136 | 0 | delete poLayer; |
137 | 0 | } |
138 | | |
139 | | OGRProxiedLayer::OGRProxiedLayer(OGRLayerPool *poPoolIn, |
140 | | OpenLayerFunc pfnOpenLayerIn, |
141 | | FreeUserDataFunc pfnFreeUserDataIn, |
142 | | void *pUserDataIn) |
143 | 0 | : OGRAbstractProxiedLayer(poPoolIn), pfnOpenLayer(pfnOpenLayerIn), |
144 | 0 | pfnReleaseLayer(ReleaseDelete), pfnFreeUserData(pfnFreeUserDataIn), |
145 | 0 | pUserData(pUserDataIn), poUnderlyingLayer(nullptr), |
146 | 0 | poFeatureDefn(nullptr), poSRS(nullptr) |
147 | 0 | { |
148 | 0 | CPLAssert(pfnOpenLayerIn != nullptr); |
149 | 0 | } |
150 | | |
151 | | /************************************************************************/ |
152 | | /* OGRProxiedLayer() */ |
153 | | /************************************************************************/ |
154 | | |
155 | | OGRProxiedLayer::OGRProxiedLayer(OGRLayerPool *poPoolIn, |
156 | | OpenLayerFunc pfnOpenLayerIn, |
157 | | ReleaseLayerFunc pfnReleaseLayerIn, |
158 | | FreeUserDataFunc pfnFreeUserDataIn, |
159 | | void *pUserDataIn) |
160 | 0 | : OGRAbstractProxiedLayer(poPoolIn), pfnOpenLayer(pfnOpenLayerIn), |
161 | 0 | pfnReleaseLayer(pfnReleaseLayerIn), pfnFreeUserData(pfnFreeUserDataIn), |
162 | 0 | pUserData(pUserDataIn), poUnderlyingLayer(nullptr), |
163 | 0 | poFeatureDefn(nullptr), poSRS(nullptr) |
164 | 0 | { |
165 | 0 | CPLAssert(pfnOpenLayerIn != nullptr); |
166 | 0 | } |
167 | | |
168 | | /************************************************************************/ |
169 | | /* ~OGRProxiedLayer() */ |
170 | | /************************************************************************/ |
171 | | |
172 | | OGRProxiedLayer::~OGRProxiedLayer() |
173 | 0 | { |
174 | 0 | OGRProxiedLayer::CloseUnderlyingLayer(); |
175 | |
|
176 | 0 | if (poSRS) |
177 | 0 | poSRS->Release(); |
178 | |
|
179 | 0 | if (poFeatureDefn) |
180 | 0 | poFeatureDefn->Release(); |
181 | |
|
182 | 0 | if (pfnFreeUserData != nullptr) |
183 | 0 | pfnFreeUserData(pUserData); |
184 | 0 | } |
185 | | |
186 | | /************************************************************************/ |
187 | | /* OpenUnderlyingLayer() */ |
188 | | /************************************************************************/ |
189 | | |
190 | | int OGRProxiedLayer::OpenUnderlyingLayer() const |
191 | 0 | { |
192 | 0 | std::lock_guard oLock(m_oMutex); |
193 | 0 | if (poUnderlyingLayer == nullptr) |
194 | 0 | { |
195 | 0 | CPLDebug("OGR", "OpenUnderlyingLayer(%p)", this); |
196 | 0 | poPool->SetLastUsedLayer(const_cast<OGRProxiedLayer *>(this)); |
197 | 0 | poUnderlyingLayer = pfnOpenLayer(pUserData); |
198 | 0 | if (poUnderlyingLayer == nullptr) |
199 | 0 | { |
200 | 0 | CPLError(CE_Failure, CPLE_FileIO, "Cannot open underlying layer"); |
201 | 0 | } |
202 | 0 | } |
203 | 0 | return poUnderlyingLayer != nullptr; |
204 | 0 | } |
205 | | |
206 | | /************************************************************************/ |
207 | | /* CloseUnderlyingLayer() */ |
208 | | /************************************************************************/ |
209 | | |
210 | | void OGRProxiedLayer::CloseUnderlyingLayer() |
211 | 0 | { |
212 | 0 | CPLDebug("OGR", "CloseUnderlyingLayer(%p)", this); |
213 | 0 | if (poUnderlyingLayer) |
214 | 0 | { |
215 | 0 | pfnReleaseLayer(poUnderlyingLayer, pUserData); |
216 | 0 | } |
217 | 0 | poUnderlyingLayer = nullptr; |
218 | 0 | } |
219 | | |
220 | | /************************************************************************/ |
221 | | /* GetUnderlyingLayer() */ |
222 | | /************************************************************************/ |
223 | | |
224 | | OGRLayer *OGRProxiedLayer::GetUnderlyingLayer() |
225 | 0 | { |
226 | 0 | if (poUnderlyingLayer == nullptr) |
227 | 0 | { |
228 | | // If the open fails, poUnderlyingLayer will still be a nullptr |
229 | | // and the user will be warned by the open call. |
230 | 0 | CPL_IGNORE_RET_VAL(OpenUnderlyingLayer()); |
231 | 0 | } |
232 | 0 | return poUnderlyingLayer; |
233 | 0 | } |
234 | | |
235 | | /************************************************************************/ |
236 | | /* GetSpatialFilter() */ |
237 | | /************************************************************************/ |
238 | | |
239 | | OGRGeometry *OGRProxiedLayer::GetSpatialFilter() |
240 | 0 | { |
241 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
242 | 0 | return nullptr; |
243 | 0 | return poUnderlyingLayer->GetSpatialFilter(); |
244 | 0 | } |
245 | | |
246 | | /************************************************************************/ |
247 | | /* ISetSpatialFilter() */ |
248 | | /************************************************************************/ |
249 | | |
250 | | OGRErr OGRProxiedLayer::ISetSpatialFilter(int iGeomField, |
251 | | const OGRGeometry *poGeom) |
252 | 0 | { |
253 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
254 | 0 | return OGRERR_FAILURE; |
255 | 0 | return poUnderlyingLayer->SetSpatialFilter(iGeomField, poGeom); |
256 | 0 | } |
257 | | |
258 | | /************************************************************************/ |
259 | | /* SetAttributeFilter() */ |
260 | | /************************************************************************/ |
261 | | |
262 | | OGRErr OGRProxiedLayer::SetAttributeFilter(const char *poAttrFilter) |
263 | 0 | { |
264 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
265 | 0 | return OGRERR_FAILURE; |
266 | 0 | return poUnderlyingLayer->SetAttributeFilter(poAttrFilter); |
267 | 0 | } |
268 | | |
269 | | /************************************************************************/ |
270 | | /* ResetReading() */ |
271 | | /************************************************************************/ |
272 | | |
273 | | void OGRProxiedLayer::ResetReading() |
274 | 0 | { |
275 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
276 | 0 | return; |
277 | 0 | poUnderlyingLayer->ResetReading(); |
278 | 0 | } |
279 | | |
280 | | /************************************************************************/ |
281 | | /* GetNextFeature() */ |
282 | | /************************************************************************/ |
283 | | |
284 | | OGRFeature *OGRProxiedLayer::GetNextFeature() |
285 | 0 | { |
286 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
287 | 0 | return nullptr; |
288 | 0 | return poUnderlyingLayer->GetNextFeature(); |
289 | 0 | } |
290 | | |
291 | | /************************************************************************/ |
292 | | /* GDALDataset() */ |
293 | | /************************************************************************/ |
294 | | |
295 | | GDALDataset *OGRProxiedLayer::GetDataset() |
296 | 0 | { |
297 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
298 | 0 | return nullptr; |
299 | 0 | return poUnderlyingLayer->GetDataset(); |
300 | 0 | } |
301 | | |
302 | | /************************************************************************/ |
303 | | /* GetArrowStream() */ |
304 | | /************************************************************************/ |
305 | | |
306 | | bool OGRProxiedLayer::GetArrowStream(struct ArrowArrayStream *out_stream, |
307 | | CSLConstList papszOptions) |
308 | 0 | { |
309 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
310 | 0 | { |
311 | 0 | memset(out_stream, 0, sizeof(*out_stream)); |
312 | 0 | return false; |
313 | 0 | } |
314 | 0 | return poUnderlyingLayer->GetArrowStream(out_stream, papszOptions); |
315 | 0 | } |
316 | | |
317 | | /************************************************************************/ |
318 | | /* SetNextByIndex() */ |
319 | | /************************************************************************/ |
320 | | |
321 | | OGRErr OGRProxiedLayer::SetNextByIndex(GIntBig nIndex) |
322 | 0 | { |
323 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
324 | 0 | return OGRERR_FAILURE; |
325 | 0 | return poUnderlyingLayer->SetNextByIndex(nIndex); |
326 | 0 | } |
327 | | |
328 | | /************************************************************************/ |
329 | | /* GetFeature() */ |
330 | | /************************************************************************/ |
331 | | |
332 | | OGRFeature *OGRProxiedLayer::GetFeature(GIntBig nFID) |
333 | 0 | { |
334 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
335 | 0 | return nullptr; |
336 | 0 | return poUnderlyingLayer->GetFeature(nFID); |
337 | 0 | } |
338 | | |
339 | | /************************************************************************/ |
340 | | /* ISetFeature() */ |
341 | | /************************************************************************/ |
342 | | |
343 | | OGRErr OGRProxiedLayer::ISetFeature(OGRFeature *poFeature) |
344 | 0 | { |
345 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
346 | 0 | return OGRERR_FAILURE; |
347 | 0 | return poUnderlyingLayer->SetFeature(poFeature); |
348 | 0 | } |
349 | | |
350 | | /************************************************************************/ |
351 | | /* ISetFeatureUniqPtr() */ |
352 | | /************************************************************************/ |
353 | | |
354 | | OGRErr |
355 | | OGRProxiedLayer::ISetFeatureUniqPtr(std::unique_ptr<OGRFeature> poFeature) |
356 | 0 | { |
357 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
358 | 0 | return OGRERR_FAILURE; |
359 | 0 | return poUnderlyingLayer->SetFeature(std::move(poFeature)); |
360 | 0 | } |
361 | | |
362 | | /************************************************************************/ |
363 | | /* ICreateFeature() */ |
364 | | /************************************************************************/ |
365 | | |
366 | | OGRErr OGRProxiedLayer::ICreateFeature(OGRFeature *poFeature) |
367 | 0 | { |
368 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
369 | 0 | return OGRERR_FAILURE; |
370 | 0 | return poUnderlyingLayer->CreateFeature(poFeature); |
371 | 0 | } |
372 | | |
373 | | /************************************************************************/ |
374 | | /* ICreateFeatureUniqPtr() */ |
375 | | /************************************************************************/ |
376 | | |
377 | | OGRErr |
378 | | OGRProxiedLayer::ICreateFeatureUniqPtr(std::unique_ptr<OGRFeature> poFeature, |
379 | | GIntBig *pnFID) |
380 | 0 | { |
381 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
382 | 0 | return OGRERR_FAILURE; |
383 | 0 | return poUnderlyingLayer->CreateFeature(std::move(poFeature), pnFID); |
384 | 0 | } |
385 | | |
386 | | /************************************************************************/ |
387 | | /* IUpsertFeature() */ |
388 | | /************************************************************************/ |
389 | | |
390 | | OGRErr OGRProxiedLayer::IUpsertFeature(OGRFeature *poFeature) |
391 | 0 | { |
392 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
393 | 0 | return OGRERR_FAILURE; |
394 | 0 | return poUnderlyingLayer->UpsertFeature(poFeature); |
395 | 0 | } |
396 | | |
397 | | /************************************************************************/ |
398 | | /* IUpdateFeature() */ |
399 | | /************************************************************************/ |
400 | | |
401 | | OGRErr OGRProxiedLayer::IUpdateFeature(OGRFeature *poFeature, |
402 | | int nUpdatedFieldsCount, |
403 | | const int *panUpdatedFieldsIdx, |
404 | | int nUpdatedGeomFieldsCount, |
405 | | const int *panUpdatedGeomFieldsIdx, |
406 | | bool bUpdateStyleString) |
407 | 0 | { |
408 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
409 | 0 | return OGRERR_FAILURE; |
410 | 0 | return poUnderlyingLayer->UpdateFeature( |
411 | 0 | poFeature, nUpdatedFieldsCount, panUpdatedFieldsIdx, |
412 | 0 | nUpdatedGeomFieldsCount, panUpdatedGeomFieldsIdx, bUpdateStyleString); |
413 | 0 | } |
414 | | |
415 | | /************************************************************************/ |
416 | | /* DeleteFeature() */ |
417 | | /************************************************************************/ |
418 | | |
419 | | OGRErr OGRProxiedLayer::DeleteFeature(GIntBig nFID) |
420 | 0 | { |
421 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
422 | 0 | return OGRERR_FAILURE; |
423 | 0 | return poUnderlyingLayer->DeleteFeature(nFID); |
424 | 0 | } |
425 | | |
426 | | /************************************************************************/ |
427 | | /* GetName() */ |
428 | | /************************************************************************/ |
429 | | |
430 | | const char *OGRProxiedLayer::GetName() const |
431 | 0 | { |
432 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
433 | 0 | return ""; |
434 | 0 | return poUnderlyingLayer->GetName(); |
435 | 0 | } |
436 | | |
437 | | /************************************************************************/ |
438 | | /* GetGeomType() */ |
439 | | /************************************************************************/ |
440 | | |
441 | | OGRwkbGeometryType OGRProxiedLayer::GetGeomType() const |
442 | 0 | { |
443 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
444 | 0 | return wkbUnknown; |
445 | 0 | return poUnderlyingLayer->GetGeomType(); |
446 | 0 | } |
447 | | |
448 | | /************************************************************************/ |
449 | | /* GetLayerDefn() */ |
450 | | /************************************************************************/ |
451 | | |
452 | | const OGRFeatureDefn *OGRProxiedLayer::GetLayerDefn() const |
453 | 0 | { |
454 | 0 | std::lock_guard oLock(m_oMutex); |
455 | 0 | if (poFeatureDefn != nullptr) |
456 | 0 | return poFeatureDefn; |
457 | | |
458 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
459 | 0 | { |
460 | 0 | poFeatureDefn = new OGRFeatureDefn(""); |
461 | 0 | } |
462 | 0 | else |
463 | 0 | { |
464 | 0 | poFeatureDefn = poUnderlyingLayer->GetLayerDefn(); |
465 | 0 | } |
466 | |
|
467 | 0 | poFeatureDefn->Reference(); |
468 | |
|
469 | 0 | return poFeatureDefn; |
470 | 0 | } |
471 | | |
472 | | /************************************************************************/ |
473 | | /* GetSpatialRef() */ |
474 | | /************************************************************************/ |
475 | | |
476 | | const OGRSpatialReference *OGRProxiedLayer::GetSpatialRef() const |
477 | 0 | { |
478 | 0 | std::lock_guard oLock(m_oMutex); |
479 | 0 | if (poSRS != nullptr) |
480 | 0 | return poSRS; |
481 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
482 | 0 | return nullptr; |
483 | 0 | OGRSpatialReference *l_poSRS = |
484 | 0 | const_cast<OGRSpatialReference *>(poUnderlyingLayer->GetSpatialRef()); |
485 | 0 | if (l_poSRS != nullptr) |
486 | 0 | { |
487 | 0 | l_poSRS->Reference(); |
488 | 0 | poSRS = l_poSRS; |
489 | 0 | } |
490 | 0 | return poSRS; |
491 | 0 | } |
492 | | |
493 | | /************************************************************************/ |
494 | | /* GetFeatureCount() */ |
495 | | /************************************************************************/ |
496 | | |
497 | | GIntBig OGRProxiedLayer::GetFeatureCount(int bForce) |
498 | 0 | { |
499 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
500 | 0 | return 0; |
501 | 0 | return poUnderlyingLayer->GetFeatureCount(bForce); |
502 | 0 | } |
503 | | |
504 | | /************************************************************************/ |
505 | | /* IGetExtent() */ |
506 | | /************************************************************************/ |
507 | | |
508 | | OGRErr OGRProxiedLayer::IGetExtent(int iGeomField, OGREnvelope *psExtent, |
509 | | bool bForce) |
510 | 0 | { |
511 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
512 | 0 | return OGRERR_FAILURE; |
513 | 0 | return poUnderlyingLayer->GetExtent(iGeomField, psExtent, bForce); |
514 | 0 | } |
515 | | |
516 | | /************************************************************************/ |
517 | | /* TestCapability() */ |
518 | | /************************************************************************/ |
519 | | |
520 | | int OGRProxiedLayer::TestCapability(const char *pszCapability) const |
521 | 0 | { |
522 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
523 | 0 | return FALSE; |
524 | 0 | return poUnderlyingLayer->TestCapability(pszCapability); |
525 | 0 | } |
526 | | |
527 | | /************************************************************************/ |
528 | | /* CreateField() */ |
529 | | /************************************************************************/ |
530 | | |
531 | | OGRErr OGRProxiedLayer::CreateField(const OGRFieldDefn *poField, int bApproxOK) |
532 | 0 | { |
533 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
534 | 0 | return OGRERR_FAILURE; |
535 | 0 | return poUnderlyingLayer->CreateField(poField, bApproxOK); |
536 | 0 | } |
537 | | |
538 | | /************************************************************************/ |
539 | | /* DeleteField() */ |
540 | | /************************************************************************/ |
541 | | |
542 | | OGRErr OGRProxiedLayer::DeleteField(int iField) |
543 | 0 | { |
544 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
545 | 0 | return OGRERR_FAILURE; |
546 | 0 | return poUnderlyingLayer->DeleteField(iField); |
547 | 0 | } |
548 | | |
549 | | /************************************************************************/ |
550 | | /* ReorderFields() */ |
551 | | /************************************************************************/ |
552 | | |
553 | | OGRErr OGRProxiedLayer::ReorderFields(int *panMap) |
554 | 0 | { |
555 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
556 | 0 | return OGRERR_FAILURE; |
557 | 0 | return poUnderlyingLayer->ReorderFields(panMap); |
558 | 0 | } |
559 | | |
560 | | /************************************************************************/ |
561 | | /* AlterFieldDefn() */ |
562 | | /************************************************************************/ |
563 | | |
564 | | OGRErr OGRProxiedLayer::AlterFieldDefn(int iField, OGRFieldDefn *poNewFieldDefn, |
565 | | int nFlagsIn) |
566 | 0 | { |
567 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
568 | 0 | return OGRERR_FAILURE; |
569 | 0 | return poUnderlyingLayer->AlterFieldDefn(iField, poNewFieldDefn, nFlagsIn); |
570 | 0 | } |
571 | | |
572 | | /************************************************************************/ |
573 | | /* AlterGeomFieldDefn() */ |
574 | | /************************************************************************/ |
575 | | |
576 | | OGRErr OGRProxiedLayer::AlterGeomFieldDefn( |
577 | | int iGeomField, const OGRGeomFieldDefn *poNewGeomFieldDefn, int nFlagsIn) |
578 | 0 | { |
579 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
580 | 0 | return OGRERR_FAILURE; |
581 | 0 | return poUnderlyingLayer->AlterGeomFieldDefn(iGeomField, poNewGeomFieldDefn, |
582 | 0 | nFlagsIn); |
583 | 0 | } |
584 | | |
585 | | /************************************************************************/ |
586 | | /* SyncToDisk() */ |
587 | | /************************************************************************/ |
588 | | |
589 | | OGRErr OGRProxiedLayer::SyncToDisk() |
590 | 0 | { |
591 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
592 | 0 | return OGRERR_FAILURE; |
593 | 0 | return poUnderlyingLayer->SyncToDisk(); |
594 | 0 | } |
595 | | |
596 | | /************************************************************************/ |
597 | | /* GetStyleTable() */ |
598 | | /************************************************************************/ |
599 | | |
600 | | OGRStyleTable *OGRProxiedLayer::GetStyleTable() |
601 | 0 | { |
602 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
603 | 0 | return nullptr; |
604 | 0 | return poUnderlyingLayer->GetStyleTable(); |
605 | 0 | } |
606 | | |
607 | | /************************************************************************/ |
608 | | /* SetStyleTableDirectly() */ |
609 | | /************************************************************************/ |
610 | | |
611 | | void OGRProxiedLayer::SetStyleTableDirectly(OGRStyleTable *poStyleTable) |
612 | 0 | { |
613 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
614 | 0 | return; |
615 | 0 | return poUnderlyingLayer->SetStyleTableDirectly(poStyleTable); |
616 | 0 | } |
617 | | |
618 | | /************************************************************************/ |
619 | | /* SetStyleTable() */ |
620 | | /************************************************************************/ |
621 | | |
622 | | void OGRProxiedLayer::SetStyleTable(OGRStyleTable *poStyleTable) |
623 | 0 | { |
624 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
625 | 0 | return; |
626 | 0 | return poUnderlyingLayer->SetStyleTable(poStyleTable); |
627 | 0 | } |
628 | | |
629 | | /************************************************************************/ |
630 | | /* StartTransaction() */ |
631 | | /************************************************************************/ |
632 | | |
633 | | OGRErr OGRProxiedLayer::StartTransaction() |
634 | 0 | { |
635 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
636 | 0 | return OGRERR_FAILURE; |
637 | 0 | return poUnderlyingLayer->StartTransaction(); |
638 | 0 | } |
639 | | |
640 | | /************************************************************************/ |
641 | | /* CommitTransaction() */ |
642 | | /************************************************************************/ |
643 | | |
644 | | OGRErr OGRProxiedLayer::CommitTransaction() |
645 | 0 | { |
646 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
647 | 0 | return OGRERR_FAILURE; |
648 | 0 | return poUnderlyingLayer->CommitTransaction(); |
649 | 0 | } |
650 | | |
651 | | /************************************************************************/ |
652 | | /* RollbackTransaction() */ |
653 | | /************************************************************************/ |
654 | | |
655 | | OGRErr OGRProxiedLayer::RollbackTransaction() |
656 | 0 | { |
657 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
658 | 0 | return OGRERR_FAILURE; |
659 | 0 | return poUnderlyingLayer->RollbackTransaction(); |
660 | 0 | } |
661 | | |
662 | | /************************************************************************/ |
663 | | /* GetFIDColumn() */ |
664 | | /************************************************************************/ |
665 | | |
666 | | const char *OGRProxiedLayer::GetFIDColumn() const |
667 | 0 | { |
668 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
669 | 0 | return ""; |
670 | 0 | return poUnderlyingLayer->GetFIDColumn(); |
671 | 0 | } |
672 | | |
673 | | /************************************************************************/ |
674 | | /* GetGeometryColumn() */ |
675 | | /************************************************************************/ |
676 | | |
677 | | const char *OGRProxiedLayer::GetGeometryColumn() const |
678 | 0 | { |
679 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
680 | 0 | return ""; |
681 | 0 | return poUnderlyingLayer->GetGeometryColumn(); |
682 | 0 | } |
683 | | |
684 | | /************************************************************************/ |
685 | | /* SetIgnoredFields() */ |
686 | | /************************************************************************/ |
687 | | |
688 | | OGRErr OGRProxiedLayer::SetIgnoredFields(CSLConstList papszFields) |
689 | 0 | { |
690 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
691 | 0 | return OGRERR_FAILURE; |
692 | 0 | return poUnderlyingLayer->SetIgnoredFields(papszFields); |
693 | 0 | } |
694 | | |
695 | | /************************************************************************/ |
696 | | /* Rename() */ |
697 | | /************************************************************************/ |
698 | | |
699 | | OGRErr OGRProxiedLayer::Rename(const char *pszNewName) |
700 | 0 | { |
701 | 0 | if (poUnderlyingLayer == nullptr && !OpenUnderlyingLayer()) |
702 | 0 | return OGRERR_FAILURE; |
703 | 0 | return poUnderlyingLayer->Rename(pszNewName); |
704 | 0 | } |
705 | | |
706 | | #endif /* #ifndef DOXYGEN_SKIP */ |