1 : /******************************************************************************
2 : * $Id: ogrlayer.cpp 23554 2011-12-12 18:10:25Z rouault $
3 : *
4 : * Project: OpenGIS Simple Features Reference Implementation
5 : * Purpose: The generic portions of the OGRSFLayer class.
6 : * Author: Frank Warmerdam, warmerdam@pobox.com
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 1999, Les Technologies SoftMap Inc.
10 : *
11 : * Permission is hereby granted, free of charge, to any person obtaining a
12 : * copy of this software and associated documentation files (the "Software"),
13 : * to deal in the Software without restriction, including without limitation
14 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 : * and/or sell copies of the Software, and to permit persons to whom the
16 : * Software is furnished to do so, subject to the following conditions:
17 : *
18 : * The above copyright notice and this permission notice shall be included
19 : * in all copies or substantial portions of the Software.
20 : *
21 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 : * DEALINGS IN THE SOFTWARE.
28 : ****************************************************************************/
29 :
30 : #include "ogrsf_frmts.h"
31 : #include "ogr_api.h"
32 : #include "ogr_p.h"
33 : #include "ogr_attrind.h"
34 : #include "swq.h"
35 :
36 : CPL_CVSID("$Id: ogrlayer.cpp 23554 2011-12-12 18:10:25Z rouault $");
37 :
38 : /************************************************************************/
39 : /* OGRLayer() */
40 : /************************************************************************/
41 :
42 13541 : OGRLayer::OGRLayer()
43 :
44 : {
45 13541 : m_poStyleTable = NULL;
46 13541 : m_poAttrQuery = NULL;
47 13541 : m_poAttrIndex = NULL;
48 13541 : m_nRefCount = 0;
49 :
50 13541 : m_nFeaturesRead = 0;
51 :
52 13541 : m_poFilterGeom = NULL;
53 13541 : m_bFilterIsEnvelope = FALSE;
54 13541 : }
55 :
56 : /************************************************************************/
57 : /* ~OGRLayer() */
58 : /************************************************************************/
59 :
60 13541 : OGRLayer::~OGRLayer()
61 :
62 : {
63 13541 : if ( m_poStyleTable )
64 : {
65 3 : delete m_poStyleTable;
66 3 : m_poStyleTable = NULL;
67 : }
68 :
69 13541 : if( m_poAttrIndex != NULL )
70 : {
71 26 : delete m_poAttrIndex;
72 26 : m_poAttrIndex = NULL;
73 : }
74 :
75 13541 : if( m_poAttrQuery != NULL )
76 : {
77 28 : delete m_poAttrQuery;
78 28 : m_poAttrQuery = NULL;
79 : }
80 :
81 13541 : if( m_poFilterGeom )
82 : {
83 32 : delete m_poFilterGeom;
84 32 : m_poFilterGeom = NULL;
85 : }
86 13541 : }
87 :
88 : /************************************************************************/
89 : /* Reference() */
90 : /************************************************************************/
91 :
92 0 : int OGRLayer::Reference()
93 :
94 : {
95 0 : return ++m_nRefCount;
96 : }
97 :
98 : /************************************************************************/
99 : /* OGR_L_Reference() */
100 : /************************************************************************/
101 :
102 0 : int OGR_L_Reference( OGRLayerH hLayer )
103 :
104 : {
105 0 : VALIDATE_POINTER1( hLayer, "OGR_L_Reference", 0 );
106 :
107 0 : return ((OGRLayer *) hLayer)->Reference();
108 : }
109 :
110 : /************************************************************************/
111 : /* Dereference() */
112 : /************************************************************************/
113 :
114 0 : int OGRLayer::Dereference()
115 :
116 : {
117 0 : return --m_nRefCount;
118 : }
119 :
120 : /************************************************************************/
121 : /* OGR_L_Dereference() */
122 : /************************************************************************/
123 :
124 0 : int OGR_L_Dereference( OGRLayerH hLayer )
125 :
126 : {
127 0 : VALIDATE_POINTER1( hLayer, "OGR_L_Dereference", 0 );
128 :
129 0 : return ((OGRLayer *) hLayer)->Dereference();
130 : }
131 :
132 : /************************************************************************/
133 : /* GetRefCount() */
134 : /************************************************************************/
135 :
136 13 : int OGRLayer::GetRefCount() const
137 :
138 : {
139 13 : return m_nRefCount;
140 : }
141 :
142 : /************************************************************************/
143 : /* OGR_L_GetRefCount() */
144 : /************************************************************************/
145 :
146 0 : int OGR_L_GetRefCount( OGRLayerH hLayer )
147 :
148 : {
149 0 : VALIDATE_POINTER1( hLayer, "OGR_L_GetRefCount", 0 );
150 :
151 0 : return ((OGRLayer *) hLayer)->GetRefCount();
152 : }
153 :
154 : /************************************************************************/
155 : /* GetFeatureCount() */
156 : /************************************************************************/
157 :
158 393 : int OGRLayer::GetFeatureCount( int bForce )
159 :
160 : {
161 : OGRFeature *poFeature;
162 393 : int nFeatureCount = 0;
163 :
164 393 : if( !bForce )
165 0 : return -1;
166 :
167 393 : ResetReading();
168 213286 : while( (poFeature = GetNextFeature()) != NULL )
169 : {
170 212500 : nFeatureCount++;
171 212500 : delete poFeature;
172 : }
173 393 : ResetReading();
174 :
175 393 : return nFeatureCount;
176 : }
177 :
178 : /************************************************************************/
179 : /* OGR_L_GetFeatureCount() */
180 : /************************************************************************/
181 :
182 489 : int OGR_L_GetFeatureCount( OGRLayerH hLayer, int bForce )
183 :
184 : {
185 489 : VALIDATE_POINTER1( hLayer, "OGR_L_GetFeature", 0 );
186 :
187 489 : return ((OGRLayer *) hLayer)->GetFeatureCount(bForce);
188 : }
189 :
190 : /************************************************************************/
191 : /* GetExtent() */
192 : /************************************************************************/
193 :
194 141 : OGRErr OGRLayer::GetExtent(OGREnvelope *psExtent, int bForce )
195 :
196 : {
197 : OGRFeature *poFeature;
198 141 : OGREnvelope oEnv;
199 141 : GBool bExtentSet = FALSE;
200 :
201 141 : psExtent->MinX = 0.0;
202 141 : psExtent->MaxX = 0.0;
203 141 : psExtent->MinY = 0.0;
204 141 : psExtent->MaxY = 0.0;
205 :
206 : /* -------------------------------------------------------------------- */
207 : /* If this layer has a none geometry type, then we can */
208 : /* reasonably assume there are not extents available. */
209 : /* -------------------------------------------------------------------- */
210 141 : if( GetLayerDefn()->GetGeomType() == wkbNone )
211 34 : return OGRERR_FAILURE;
212 :
213 : /* -------------------------------------------------------------------- */
214 : /* If not forced, we should avoid having to scan all the */
215 : /* features and just return a failure. */
216 : /* -------------------------------------------------------------------- */
217 107 : if( !bForce )
218 0 : return OGRERR_FAILURE;
219 :
220 : /* -------------------------------------------------------------------- */
221 : /* OK, we hate to do this, but go ahead and read through all */
222 : /* the features to collect geometries and build extents. */
223 : /* -------------------------------------------------------------------- */
224 107 : ResetReading();
225 69961 : while( (poFeature = GetNextFeature()) != NULL )
226 : {
227 69747 : OGRGeometry *poGeom = poFeature->GetGeometryRef();
228 69747 : if (poGeom == NULL || poGeom->IsEmpty())
229 : {
230 : /* Do nothing */
231 : }
232 69342 : else if (!bExtentSet)
233 : {
234 99 : poGeom->getEnvelope(psExtent);
235 99 : bExtentSet = TRUE;
236 : }
237 : else
238 : {
239 69243 : poGeom->getEnvelope(&oEnv);
240 69243 : if (oEnv.MinX < psExtent->MinX)
241 169 : psExtent->MinX = oEnv.MinX;
242 69243 : if (oEnv.MinY < psExtent->MinY)
243 2009 : psExtent->MinY = oEnv.MinY;
244 69243 : if (oEnv.MaxX > psExtent->MaxX)
245 225 : psExtent->MaxX = oEnv.MaxX;
246 69243 : if (oEnv.MaxY > psExtent->MaxY)
247 138 : psExtent->MaxY = oEnv.MaxY;
248 : }
249 69747 : delete poFeature;
250 : }
251 107 : ResetReading();
252 :
253 107 : return (bExtentSet ? OGRERR_NONE : OGRERR_FAILURE);
254 : }
255 :
256 : /************************************************************************/
257 : /* OGR_L_GetExtent() */
258 : /************************************************************************/
259 :
260 88 : OGRErr OGR_L_GetExtent( OGRLayerH hLayer, OGREnvelope *psExtent, int bForce )
261 :
262 : {
263 88 : VALIDATE_POINTER1( hLayer, "OGR_L_GetExtent", OGRERR_INVALID_HANDLE );
264 :
265 88 : return ((OGRLayer *) hLayer)->GetExtent( psExtent, bForce );
266 : }
267 :
268 : /************************************************************************/
269 : /* SetAttributeFilter() */
270 : /************************************************************************/
271 :
272 988 : OGRErr OGRLayer::SetAttributeFilter( const char *pszQuery )
273 :
274 : {
275 : /* -------------------------------------------------------------------- */
276 : /* Are we just clearing any existing query? */
277 : /* -------------------------------------------------------------------- */
278 988 : if( pszQuery == NULL || strlen(pszQuery) == 0 )
279 : {
280 653 : if( m_poAttrQuery )
281 : {
282 140 : delete m_poAttrQuery;
283 140 : m_poAttrQuery = NULL;
284 140 : ResetReading();
285 : }
286 653 : return OGRERR_NONE;
287 : }
288 :
289 : /* -------------------------------------------------------------------- */
290 : /* Or are we installing a new query? */
291 : /* -------------------------------------------------------------------- */
292 : OGRErr eErr;
293 :
294 335 : if( !m_poAttrQuery )
295 168 : m_poAttrQuery = new OGRFeatureQuery();
296 :
297 335 : eErr = m_poAttrQuery->Compile( GetLayerDefn(), pszQuery );
298 335 : if( eErr != OGRERR_NONE )
299 : {
300 0 : delete m_poAttrQuery;
301 0 : m_poAttrQuery = NULL;
302 : }
303 :
304 335 : ResetReading();
305 :
306 335 : return eErr;
307 : }
308 :
309 : /************************************************************************/
310 : /* ContainGeomSpecialField() */
311 : /************************************************************************/
312 :
313 122 : static int ContainGeomSpecialField(swq_expr_node* expr,
314 : int nLayerFieldCount)
315 : {
316 122 : if (expr->eNodeType == SNT_COLUMN)
317 : {
318 32 : if( expr->table_index == 0 && expr->field_index != -1 )
319 : {
320 : int nSpecialFieldIdx = expr->field_index -
321 32 : nLayerFieldCount;
322 : return nSpecialFieldIdx == SPF_OGR_GEOMETRY ||
323 : nSpecialFieldIdx == SPF_OGR_GEOM_WKT ||
324 32 : nSpecialFieldIdx == SPF_OGR_GEOM_AREA;
325 : }
326 : }
327 90 : else if (expr->eNodeType == SNT_OPERATION)
328 : {
329 137 : for( int i = 0; i < expr->nSubExprCount; i++ )
330 : {
331 91 : if (ContainGeomSpecialField(expr->papoSubExpr[i],
332 : nLayerFieldCount))
333 0 : return TRUE;
334 : }
335 : }
336 90 : return FALSE;
337 : }
338 :
339 : /************************************************************************/
340 : /* AttributeFilterEvaluationNeedsGeometry() */
341 : /************************************************************************/
342 :
343 31 : int OGRLayer::AttributeFilterEvaluationNeedsGeometry()
344 : {
345 31 : if( !m_poAttrQuery )
346 0 : return FALSE;
347 :
348 31 : swq_expr_node* expr = (swq_expr_node *) m_poAttrQuery->GetSWGExpr();
349 31 : int nLayerFieldCount = GetLayerDefn()->GetFieldCount();
350 :
351 31 : return ContainGeomSpecialField(expr, nLayerFieldCount);
352 : }
353 :
354 : /************************************************************************/
355 : /* OGR_L_SetAttributeFilter() */
356 : /************************************************************************/
357 :
358 203 : OGRErr OGR_L_SetAttributeFilter( OGRLayerH hLayer, const char *pszQuery )
359 :
360 : {
361 203 : VALIDATE_POINTER1( hLayer, "OGR_L_SetAttributeFilter", OGRERR_INVALID_HANDLE );
362 :
363 203 : return ((OGRLayer *) hLayer)->SetAttributeFilter( pszQuery );
364 : }
365 :
366 : /************************************************************************/
367 : /* GetFeature() */
368 : /************************************************************************/
369 :
370 9 : OGRFeature *OGRLayer::GetFeature( long nFID )
371 :
372 : {
373 : OGRFeature *poFeature;
374 :
375 9 : ResetReading();
376 9441 : while( (poFeature = GetNextFeature()) != NULL )
377 : {
378 9432 : if( poFeature->GetFID() == nFID )
379 9 : return poFeature;
380 : else
381 9423 : delete poFeature;
382 : }
383 :
384 0 : return NULL;
385 : }
386 :
387 : /************************************************************************/
388 : /* OGR_L_GetFeature() */
389 : /************************************************************************/
390 :
391 83 : OGRFeatureH OGR_L_GetFeature( OGRLayerH hLayer, long nFeatureId )
392 :
393 : {
394 83 : VALIDATE_POINTER1( hLayer, "OGR_L_GetFeature", NULL );
395 :
396 83 : return (OGRFeatureH) ((OGRLayer *)hLayer)->GetFeature( nFeatureId );
397 : }
398 :
399 : /************************************************************************/
400 : /* SetNextByIndex() */
401 : /************************************************************************/
402 :
403 1 : OGRErr OGRLayer::SetNextByIndex( long nIndex )
404 :
405 : {
406 : OGRFeature *poFeature;
407 :
408 1 : ResetReading();
409 3 : while( nIndex-- > 0 )
410 : {
411 1 : poFeature = GetNextFeature();
412 1 : if( poFeature == NULL )
413 0 : return OGRERR_FAILURE;
414 :
415 1 : delete poFeature;
416 : }
417 :
418 1 : return OGRERR_NONE;
419 : }
420 :
421 : /************************************************************************/
422 : /* OGR_L_SetNextByIndex() */
423 : /************************************************************************/
424 :
425 10 : OGRErr OGR_L_SetNextByIndex( OGRLayerH hLayer, long nIndex )
426 :
427 : {
428 10 : VALIDATE_POINTER1( hLayer, "OGR_L_SetNextByIndex", OGRERR_INVALID_HANDLE );
429 :
430 10 : return ((OGRLayer *)hLayer)->SetNextByIndex( nIndex );
431 : }
432 :
433 : /************************************************************************/
434 : /* OGR_L_GetNextFeature() */
435 : /************************************************************************/
436 :
437 31957 : OGRFeatureH OGR_L_GetNextFeature( OGRLayerH hLayer )
438 :
439 : {
440 31957 : VALIDATE_POINTER1( hLayer, "OGR_L_GetNextFeature", NULL );
441 :
442 31957 : return (OGRFeatureH) ((OGRLayer *)hLayer)->GetNextFeature();
443 : }
444 :
445 : /************************************************************************/
446 : /* SetFeature() */
447 : /************************************************************************/
448 :
449 0 : OGRErr OGRLayer::SetFeature( OGRFeature * )
450 :
451 : {
452 0 : return OGRERR_UNSUPPORTED_OPERATION;
453 : }
454 :
455 : /************************************************************************/
456 : /* OGR_L_SetFeature() */
457 : /************************************************************************/
458 :
459 2043 : OGRErr OGR_L_SetFeature( OGRLayerH hLayer, OGRFeatureH hFeat )
460 :
461 : {
462 2043 : VALIDATE_POINTER1( hLayer, "OGR_L_SetFeature", OGRERR_INVALID_HANDLE );
463 2043 : VALIDATE_POINTER1( hFeat, "OGR_L_SetFeature", OGRERR_INVALID_HANDLE );
464 :
465 2043 : return ((OGRLayer *)hLayer)->SetFeature( (OGRFeature *) hFeat );
466 : }
467 :
468 : /************************************************************************/
469 : /* CreateFeature() */
470 : /************************************************************************/
471 :
472 0 : OGRErr OGRLayer::CreateFeature( OGRFeature * )
473 :
474 : {
475 0 : return OGRERR_UNSUPPORTED_OPERATION;
476 : }
477 :
478 : /************************************************************************/
479 : /* OGR_L_CreateFeature() */
480 : /************************************************************************/
481 :
482 19831 : OGRErr OGR_L_CreateFeature( OGRLayerH hLayer, OGRFeatureH hFeat )
483 :
484 : {
485 19831 : VALIDATE_POINTER1( hLayer, "OGR_L_CreateFeature", OGRERR_INVALID_HANDLE );
486 19831 : VALIDATE_POINTER1( hFeat, "OGR_L_SetFeature", OGRERR_INVALID_HANDLE );
487 :
488 19831 : return ((OGRLayer *) hLayer)->CreateFeature( (OGRFeature *) hFeat );
489 : }
490 :
491 : /************************************************************************/
492 : /* GetInfo() */
493 : /************************************************************************/
494 :
495 0 : const char *OGRLayer::GetInfo( const char * pszTag )
496 :
497 : {
498 : (void) pszTag;
499 0 : return NULL;
500 : }
501 :
502 : /************************************************************************/
503 : /* CreateField() */
504 : /************************************************************************/
505 :
506 0 : OGRErr OGRLayer::CreateField( OGRFieldDefn * poField, int bApproxOK )
507 :
508 : {
509 : (void) poField;
510 : (void) bApproxOK;
511 :
512 : CPLError( CE_Failure, CPLE_NotSupported,
513 0 : "CreateField() not supported by this layer.\n" );
514 :
515 0 : return OGRERR_UNSUPPORTED_OPERATION;
516 : }
517 :
518 : /************************************************************************/
519 : /* OGR_L_CreateField() */
520 : /************************************************************************/
521 :
522 4490 : OGRErr OGR_L_CreateField( OGRLayerH hLayer, OGRFieldDefnH hField,
523 : int bApproxOK )
524 :
525 : {
526 4490 : VALIDATE_POINTER1( hLayer, "OGR_L_CreateField", OGRERR_INVALID_HANDLE );
527 4490 : VALIDATE_POINTER1( hField, "OGR_L_CreateField", OGRERR_INVALID_HANDLE );
528 :
529 : return ((OGRLayer *) hLayer)->CreateField( (OGRFieldDefn *) hField,
530 4490 : bApproxOK );
531 : }
532 :
533 : /************************************************************************/
534 : /* DeleteField() */
535 : /************************************************************************/
536 :
537 0 : OGRErr OGRLayer::DeleteField( int iField )
538 :
539 : {
540 : (void) iField;
541 :
542 : CPLError( CE_Failure, CPLE_NotSupported,
543 0 : "DeleteField() not supported by this layer.\n" );
544 :
545 0 : return OGRERR_UNSUPPORTED_OPERATION;
546 : }
547 :
548 : /************************************************************************/
549 : /* OGR_L_DeleteField() */
550 : /************************************************************************/
551 :
552 28 : OGRErr OGR_L_DeleteField( OGRLayerH hLayer, int iField )
553 :
554 : {
555 28 : VALIDATE_POINTER1( hLayer, "OGR_L_DeleteField", OGRERR_INVALID_HANDLE );
556 :
557 28 : return ((OGRLayer *) hLayer)->DeleteField( iField );
558 : }
559 :
560 : /************************************************************************/
561 : /* ReorderFields() */
562 : /************************************************************************/
563 :
564 0 : OGRErr OGRLayer::ReorderFields( int* panMap )
565 :
566 : {
567 : (void) panMap;
568 :
569 : CPLError( CE_Failure, CPLE_NotSupported,
570 0 : "ReorderFields() not supported by this layer.\n" );
571 :
572 0 : return OGRERR_UNSUPPORTED_OPERATION;
573 : }
574 :
575 : /************************************************************************/
576 : /* OGR_L_ReorderFields() */
577 : /************************************************************************/
578 :
579 15 : OGRErr OGR_L_ReorderFields( OGRLayerH hLayer, int* panMap )
580 :
581 : {
582 15 : VALIDATE_POINTER1( hLayer, "OGR_L_ReorderFields", OGRERR_INVALID_HANDLE );
583 :
584 15 : return ((OGRLayer *) hLayer)->ReorderFields( panMap );
585 : }
586 :
587 : /************************************************************************/
588 : /* ReorderField() */
589 : /************************************************************************/
590 :
591 24 : OGRErr OGRLayer::ReorderField( int iOldFieldPos, int iNewFieldPos )
592 :
593 : {
594 : OGRErr eErr;
595 :
596 24 : int nFieldCount = GetLayerDefn()->GetFieldCount();
597 :
598 24 : if (iOldFieldPos < 0 || iOldFieldPos >= nFieldCount)
599 : {
600 : CPLError( CE_Failure, CPLE_NotSupported,
601 0 : "Invalid field index");
602 0 : return OGRERR_FAILURE;
603 : }
604 24 : if (iNewFieldPos < 0 || iNewFieldPos >= nFieldCount)
605 : {
606 : CPLError( CE_Failure, CPLE_NotSupported,
607 0 : "Invalid field index");
608 0 : return OGRERR_FAILURE;
609 : }
610 24 : if (iNewFieldPos == iOldFieldPos)
611 0 : return OGRERR_NONE;
612 :
613 24 : int* panMap = (int*) CPLMalloc(sizeof(int) * nFieldCount);
614 : int i;
615 24 : if (iOldFieldPos < iNewFieldPos)
616 : {
617 : /* "0","1","2","3","4" (1,3) -> "0","2","3","1","4" */
618 12 : for(i=0;i<iOldFieldPos;i++)
619 3 : panMap[i] = i;
620 24 : for(;i<iNewFieldPos;i++)
621 15 : panMap[i] = i + 1;
622 9 : panMap[iNewFieldPos] = iOldFieldPos;
623 18 : for(i=iNewFieldPos+1;i<nFieldCount;i++)
624 9 : panMap[i] = i;
625 : }
626 : else
627 : {
628 : /* "0","1","2","3","4" (3,1) -> "0","3","1","2","4" */
629 18 : for(i=0;i<iNewFieldPos;i++)
630 3 : panMap[i] = i;
631 15 : panMap[iNewFieldPos] = iOldFieldPos;
632 54 : for(i=iNewFieldPos+1;i<=iOldFieldPos;i++)
633 39 : panMap[i] = i - 1;
634 24 : for(;i<nFieldCount;i++)
635 9 : panMap[i] = i;
636 : }
637 :
638 24 : eErr = ReorderFields(panMap);
639 :
640 24 : CPLFree(panMap);
641 :
642 24 : return eErr;
643 : }
644 :
645 : /************************************************************************/
646 : /* OGR_L_ReorderField() */
647 : /************************************************************************/
648 :
649 24 : OGRErr OGR_L_ReorderField( OGRLayerH hLayer, int iOldFieldPos, int iNewFieldPos )
650 :
651 : {
652 24 : VALIDATE_POINTER1( hLayer, "OGR_L_ReorderField", OGRERR_INVALID_HANDLE );
653 :
654 24 : return ((OGRLayer *) hLayer)->ReorderField( iOldFieldPos, iNewFieldPos );
655 : }
656 :
657 : /************************************************************************/
658 : /* AlterFieldDefn() */
659 : /************************************************************************/
660 :
661 0 : OGRErr OGRLayer::AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn,
662 : int nFlags )
663 :
664 : {
665 : (void) iField;
666 : (void) poNewFieldDefn;
667 : (void) nFlags;
668 :
669 : CPLError( CE_Failure, CPLE_NotSupported,
670 0 : "AlterFieldDefn() not supported by this layer.\n" );
671 :
672 0 : return OGRERR_UNSUPPORTED_OPERATION;
673 : }
674 :
675 : /************************************************************************/
676 : /* OGR_L_AlterFieldDefn() */
677 : /************************************************************************/
678 :
679 32 : OGRErr OGR_L_AlterFieldDefn( OGRLayerH hLayer, int iField, OGRFieldDefnH hNewFieldDefn,
680 : int nFlags )
681 :
682 : {
683 32 : VALIDATE_POINTER1( hLayer, "OGR_L_AlterFieldDefn", OGRERR_INVALID_HANDLE );
684 32 : VALIDATE_POINTER1( hNewFieldDefn, "OGR_L_AlterFieldDefn", OGRERR_INVALID_HANDLE );
685 :
686 32 : return ((OGRLayer *) hLayer)->AlterFieldDefn( iField, (OGRFieldDefn*) hNewFieldDefn, nFlags );
687 : }
688 :
689 : /************************************************************************/
690 : /* StartTransaction() */
691 : /************************************************************************/
692 :
693 728 : OGRErr OGRLayer::StartTransaction()
694 :
695 : {
696 728 : return OGRERR_NONE;
697 : }
698 :
699 : /************************************************************************/
700 : /* OGR_L_StartTransaction() */
701 : /************************************************************************/
702 :
703 61 : OGRErr OGR_L_StartTransaction( OGRLayerH hLayer )
704 :
705 : {
706 61 : VALIDATE_POINTER1( hLayer, "OGR_L_StartTransaction", OGRERR_INVALID_HANDLE );
707 :
708 61 : return ((OGRLayer *)hLayer)->StartTransaction();
709 : }
710 :
711 : /************************************************************************/
712 : /* CommitTransaction() */
713 : /************************************************************************/
714 :
715 728 : OGRErr OGRLayer::CommitTransaction()
716 :
717 : {
718 728 : return OGRERR_NONE;
719 : }
720 :
721 : /************************************************************************/
722 : /* OGR_L_CommitTransaction() */
723 : /************************************************************************/
724 :
725 60 : OGRErr OGR_L_CommitTransaction( OGRLayerH hLayer )
726 :
727 : {
728 60 : VALIDATE_POINTER1( hLayer, "OGR_L_CommitTransaction", OGRERR_INVALID_HANDLE );
729 :
730 60 : return ((OGRLayer *)hLayer)->CommitTransaction();
731 : }
732 :
733 : /************************************************************************/
734 : /* RollbackTransaction() */
735 : /************************************************************************/
736 :
737 0 : OGRErr OGRLayer::RollbackTransaction()
738 :
739 : {
740 0 : return OGRERR_UNSUPPORTED_OPERATION;
741 : }
742 :
743 : /************************************************************************/
744 : /* OGR_L_RollbackTransaction() */
745 : /************************************************************************/
746 :
747 1 : OGRErr OGR_L_RollbackTransaction( OGRLayerH hLayer )
748 :
749 : {
750 1 : VALIDATE_POINTER1( hLayer, "OGR_L_RollbackTransaction", OGRERR_INVALID_HANDLE );
751 :
752 1 : return ((OGRLayer *)hLayer)->RollbackTransaction();
753 : }
754 :
755 : /************************************************************************/
756 : /* OGR_L_GetLayerDefn() */
757 : /************************************************************************/
758 :
759 18901 : OGRFeatureDefnH OGR_L_GetLayerDefn( OGRLayerH hLayer )
760 :
761 : {
762 18901 : VALIDATE_POINTER1( hLayer, "OGR_L_GetLayerDefn", NULL );
763 :
764 18901 : return (OGRFeatureDefnH) ((OGRLayer *)hLayer)->GetLayerDefn();
765 : }
766 :
767 : /************************************************************************/
768 : /* OGR_L_GetSpatialRef() */
769 : /************************************************************************/
770 :
771 235 : OGRSpatialReferenceH OGR_L_GetSpatialRef( OGRLayerH hLayer )
772 :
773 : {
774 235 : VALIDATE_POINTER1( hLayer, "OGR_L_GetSpatialRef", NULL );
775 :
776 235 : return (OGRSpatialReferenceH) ((OGRLayer *) hLayer)->GetSpatialRef();
777 : }
778 :
779 : /************************************************************************/
780 : /* OGR_L_TestCapability() */
781 : /************************************************************************/
782 :
783 96 : int OGR_L_TestCapability( OGRLayerH hLayer, const char *pszCap )
784 :
785 : {
786 96 : VALIDATE_POINTER1( hLayer, "OGR_L_TestCapability", 0 );
787 96 : VALIDATE_POINTER1( pszCap, "OGR_L_TestCapability", 0 );
788 :
789 96 : return ((OGRLayer *) hLayer)->TestCapability( pszCap );
790 : }
791 :
792 : /************************************************************************/
793 : /* GetSpatialFilter() */
794 : /************************************************************************/
795 :
796 75 : OGRGeometry *OGRLayer::GetSpatialFilter()
797 :
798 : {
799 75 : return m_poFilterGeom;
800 : }
801 :
802 : /************************************************************************/
803 : /* OGR_L_GetSpatialFilter() */
804 : /************************************************************************/
805 :
806 0 : OGRGeometryH OGR_L_GetSpatialFilter( OGRLayerH hLayer )
807 :
808 : {
809 0 : VALIDATE_POINTER1( hLayer, "OGR_L_GetSpatialFilter", NULL );
810 :
811 0 : return (OGRGeometryH) ((OGRLayer *) hLayer)->GetSpatialFilter();
812 : }
813 :
814 : /************************************************************************/
815 : /* SetSpatialFilter() */
816 : /************************************************************************/
817 :
818 822 : void OGRLayer::SetSpatialFilter( OGRGeometry * poGeomIn )
819 :
820 : {
821 822 : if( InstallFilter( poGeomIn ) )
822 177 : ResetReading();
823 822 : }
824 :
825 : /************************************************************************/
826 : /* OGR_L_SetSpatialFilter() */
827 : /************************************************************************/
828 :
829 47 : void OGR_L_SetSpatialFilter( OGRLayerH hLayer, OGRGeometryH hGeom )
830 :
831 : {
832 47 : VALIDATE_POINTER0( hLayer, "OGR_L_SetSpatialFilter" );
833 :
834 47 : ((OGRLayer *) hLayer)->SetSpatialFilter( (OGRGeometry *) hGeom );
835 : }
836 :
837 : /************************************************************************/
838 : /* SetSpatialFilterRect() */
839 : /************************************************************************/
840 :
841 39 : void OGRLayer::SetSpatialFilterRect( double dfMinX, double dfMinY,
842 : double dfMaxX, double dfMaxY )
843 :
844 : {
845 39 : OGRLinearRing oRing;
846 39 : OGRPolygon oPoly;
847 :
848 39 : oRing.addPoint( dfMinX, dfMinY );
849 39 : oRing.addPoint( dfMinX, dfMaxY );
850 39 : oRing.addPoint( dfMaxX, dfMaxY );
851 39 : oRing.addPoint( dfMaxX, dfMinY );
852 39 : oRing.addPoint( dfMinX, dfMinY );
853 :
854 39 : oPoly.addRing( &oRing );
855 :
856 39 : SetSpatialFilter( &oPoly );
857 39 : }
858 :
859 : /************************************************************************/
860 : /* OGR_L_SetSpatialFilterRect() */
861 : /************************************************************************/
862 :
863 39 : void OGR_L_SetSpatialFilterRect( OGRLayerH hLayer,
864 : double dfMinX, double dfMinY,
865 : double dfMaxX, double dfMaxY )
866 :
867 : {
868 39 : VALIDATE_POINTER0( hLayer, "OGR_L_SetSpatialFilterRect" );
869 :
870 : ((OGRLayer *) hLayer)->SetSpatialFilterRect( dfMinX, dfMinY,
871 39 : dfMaxX, dfMaxY );
872 : }
873 :
874 : /************************************************************************/
875 : /* InstallFilter() */
876 : /* */
877 : /* This method is only intended to be used from within */
878 : /* drivers, normally from the SetSpatialFilter() method. */
879 : /* It installs a filter, and also tests it to see if it is */
880 : /* rectangular. If so, it this is kept track of alongside the */
881 : /* filter geometry itself so we can do cheaper comparisons in */
882 : /* the FilterGeometry() call. */
883 : /* */
884 : /* Returns TRUE if the newly installed filter differs in some */
885 : /* way from the current one. */
886 : /************************************************************************/
887 :
888 925 : int OGRLayer::InstallFilter( OGRGeometry * poFilter )
889 :
890 : {
891 925 : if( m_poFilterGeom == NULL && poFilter == NULL )
892 697 : return FALSE;
893 :
894 : /* -------------------------------------------------------------------- */
895 : /* Replace the existing filter. */
896 : /* -------------------------------------------------------------------- */
897 228 : if( m_poFilterGeom != NULL )
898 : {
899 128 : delete m_poFilterGeom;
900 128 : m_poFilterGeom = NULL;
901 : }
902 :
903 228 : if( poFilter != NULL )
904 160 : m_poFilterGeom = poFilter->clone();
905 :
906 228 : m_bFilterIsEnvelope = FALSE;
907 :
908 228 : if( m_poFilterGeom == NULL )
909 68 : return TRUE;
910 :
911 160 : if( m_poFilterGeom != NULL )
912 160 : m_poFilterGeom->getEnvelope( &m_sFilterEnvelope );
913 :
914 : /* -------------------------------------------------------------------- */
915 : /* Now try to determine if the filter is really a rectangle. */
916 : /* -------------------------------------------------------------------- */
917 160 : if( wkbFlatten(m_poFilterGeom->getGeometryType()) != wkbPolygon )
918 11 : return TRUE;
919 :
920 149 : OGRPolygon *poPoly = (OGRPolygon *) m_poFilterGeom;
921 :
922 149 : if( poPoly->getNumInteriorRings() != 0 )
923 0 : return TRUE;
924 :
925 149 : OGRLinearRing *poRing = poPoly->getExteriorRing();
926 149 : if (poRing == NULL)
927 0 : return TRUE;
928 :
929 149 : if( poRing->getNumPoints() > 5 || poRing->getNumPoints() < 4 )
930 0 : return TRUE;
931 :
932 : // If the ring has 5 points, the last should be the first.
933 149 : if( poRing->getNumPoints() == 5
934 : && ( poRing->getX(0) != poRing->getX(4)
935 : || poRing->getY(0) != poRing->getY(4) ) )
936 0 : return TRUE;
937 :
938 : // Polygon with first segment in "y" direction.
939 149 : if( poRing->getX(0) == poRing->getX(1)
940 : && poRing->getY(1) == poRing->getY(2)
941 : && poRing->getX(2) == poRing->getX(3)
942 : && poRing->getY(3) == poRing->getY(0) )
943 103 : m_bFilterIsEnvelope = TRUE;
944 :
945 : // Polygon with first segment in "x" direction.
946 149 : if( poRing->getY(0) == poRing->getY(1)
947 : && poRing->getX(1) == poRing->getX(2)
948 : && poRing->getY(2) == poRing->getY(3)
949 : && poRing->getX(3) == poRing->getX(0) )
950 46 : m_bFilterIsEnvelope = TRUE;
951 :
952 149 : return TRUE;
953 : }
954 :
955 : /************************************************************************/
956 : /* FilterGeometry() */
957 : /* */
958 : /* Compare the passed in geometry to the currently installed */
959 : /* filter. Optimize for case where filter is just an */
960 : /* envelope. */
961 : /************************************************************************/
962 :
963 141075 : int OGRLayer::FilterGeometry( OGRGeometry *poGeometry )
964 :
965 : {
966 : /* -------------------------------------------------------------------- */
967 : /* In trivial cases of new filter or target geometry, we accept */
968 : /* an intersection. No geometry is taken to mean "the whole */
969 : /* world". */
970 : /* -------------------------------------------------------------------- */
971 141075 : if( m_poFilterGeom == NULL )
972 28 : return TRUE;
973 :
974 141047 : if( poGeometry == NULL )
975 427 : return TRUE;
976 :
977 : /* -------------------------------------------------------------------- */
978 : /* Compute the target geometry envelope, and if there is no */
979 : /* intersection between the envelopes we are sure not to have */
980 : /* any intersection. */
981 : /* -------------------------------------------------------------------- */
982 140620 : OGREnvelope sGeomEnv;
983 :
984 140620 : poGeometry->getEnvelope( &sGeomEnv );
985 :
986 140620 : if( sGeomEnv.MaxX < m_sFilterEnvelope.MinX
987 : || sGeomEnv.MaxY < m_sFilterEnvelope.MinY
988 : || m_sFilterEnvelope.MaxX < sGeomEnv.MinX
989 : || m_sFilterEnvelope.MaxY < sGeomEnv.MinY )
990 108525 : return FALSE;
991 :
992 :
993 : /* -------------------------------------------------------------------- */
994 : /* If the filter geometry is its own envelope and if the */
995 : /* envelope of the geometry is inside the filter geometry, */
996 : /* the geometry itself is inside the filter geometry */
997 : /* -------------------------------------------------------------------- */
998 32095 : if( m_bFilterIsEnvelope &&
999 : sGeomEnv.MinX >= m_sFilterEnvelope.MinX &&
1000 : sGeomEnv.MinY >= m_sFilterEnvelope.MinY &&
1001 : sGeomEnv.MaxX <= m_sFilterEnvelope.MaxX &&
1002 : sGeomEnv.MaxY <= m_sFilterEnvelope.MaxY)
1003 : {
1004 31964 : return TRUE;
1005 : }
1006 : else
1007 : {
1008 : /* -------------------------------------------------------------------- */
1009 : /* Fallback to full intersect test (using GEOS) if we still */
1010 : /* don't know for sure. */
1011 : /* -------------------------------------------------------------------- */
1012 131 : if( OGRGeometryFactory::haveGEOS() )
1013 131 : return m_poFilterGeom->Intersects( poGeometry );
1014 : else
1015 0 : return TRUE;
1016 : }
1017 : }
1018 :
1019 : /************************************************************************/
1020 : /* OGR_L_ResetReading() */
1021 : /************************************************************************/
1022 :
1023 1460 : void OGR_L_ResetReading( OGRLayerH hLayer )
1024 :
1025 : {
1026 1460 : VALIDATE_POINTER0( hLayer, "OGR_L_ResetReading" );
1027 :
1028 1460 : ((OGRLayer *) hLayer)->ResetReading();
1029 : }
1030 :
1031 : /************************************************************************/
1032 : /* InitializeIndexSupport() */
1033 : /* */
1034 : /* This is only intended to be called by driver layer */
1035 : /* implementations but we don't make it protected so that the */
1036 : /* datasources can do it too if that is more appropriate. */
1037 : /************************************************************************/
1038 :
1039 198 : OGRErr OGRLayer::InitializeIndexSupport( const char *pszFilename )
1040 :
1041 : {
1042 : OGRErr eErr;
1043 :
1044 198 : if (m_poAttrIndex != NULL)
1045 172 : return OGRERR_NONE;
1046 :
1047 26 : m_poAttrIndex = OGRCreateDefaultLayerIndex();
1048 :
1049 26 : eErr = m_poAttrIndex->Initialize( pszFilename, this );
1050 26 : if( eErr != OGRERR_NONE )
1051 : {
1052 0 : delete m_poAttrIndex;
1053 0 : m_poAttrIndex = NULL;
1054 : }
1055 :
1056 26 : return eErr;
1057 : }
1058 :
1059 : /************************************************************************/
1060 : /* SyncToDisk() */
1061 : /************************************************************************/
1062 :
1063 0 : OGRErr OGRLayer::SyncToDisk()
1064 :
1065 : {
1066 0 : return OGRERR_NONE;
1067 : }
1068 :
1069 : /************************************************************************/
1070 : /* OGR_L_SyncToDisk() */
1071 : /************************************************************************/
1072 :
1073 2 : OGRErr OGR_L_SyncToDisk( OGRLayerH hDS )
1074 :
1075 : {
1076 2 : VALIDATE_POINTER1( hDS, "OGR_L_SyncToDisk", OGRERR_INVALID_HANDLE );
1077 :
1078 2 : return ((OGRLayer *) hDS)->SyncToDisk();
1079 : }
1080 :
1081 : /************************************************************************/
1082 : /* DeleteFeature() */
1083 : /************************************************************************/
1084 :
1085 0 : OGRErr OGRLayer::DeleteFeature( long nFID )
1086 :
1087 : {
1088 0 : return OGRERR_UNSUPPORTED_OPERATION;
1089 : }
1090 :
1091 : /************************************************************************/
1092 : /* OGR_L_DeleteFeature() */
1093 : /************************************************************************/
1094 :
1095 19 : OGRErr OGR_L_DeleteFeature( OGRLayerH hDS, long nFID )
1096 :
1097 : {
1098 19 : VALIDATE_POINTER1( hDS, "OGR_L_DeleteFeature", OGRERR_INVALID_HANDLE );
1099 :
1100 19 : return ((OGRLayer *) hDS)->DeleteFeature( nFID );
1101 : }
1102 :
1103 : /************************************************************************/
1104 : /* GetFeaturesRead() */
1105 : /************************************************************************/
1106 :
1107 0 : GIntBig OGRLayer::GetFeaturesRead()
1108 :
1109 : {
1110 0 : return m_nFeaturesRead;
1111 : }
1112 :
1113 : /************************************************************************/
1114 : /* OGR_L_GetFeaturesRead() */
1115 : /************************************************************************/
1116 :
1117 0 : GIntBig OGR_L_GetFeaturesRead( OGRLayerH hLayer )
1118 :
1119 : {
1120 0 : VALIDATE_POINTER1( hLayer, "OGR_L_GetFeaturesRead", 0 );
1121 :
1122 0 : return ((OGRLayer *) hLayer)->GetFeaturesRead();
1123 : }
1124 :
1125 : /************************************************************************/
1126 : /* GetFIDColumn */
1127 : /************************************************************************/
1128 :
1129 18 : const char *OGRLayer::GetFIDColumn()
1130 :
1131 : {
1132 18 : return "";
1133 : }
1134 :
1135 : /************************************************************************/
1136 : /* OGR_L_GetFIDColumn() */
1137 : /************************************************************************/
1138 :
1139 15 : const char *OGR_L_GetFIDColumn( OGRLayerH hLayer )
1140 :
1141 : {
1142 15 : VALIDATE_POINTER1( hLayer, "OGR_L_GetFIDColumn", NULL );
1143 :
1144 15 : return ((OGRLayer *) hLayer)->GetFIDColumn();
1145 : }
1146 :
1147 : /************************************************************************/
1148 : /* GetGeometryColumn() */
1149 : /************************************************************************/
1150 :
1151 19 : const char *OGRLayer::GetGeometryColumn()
1152 :
1153 : {
1154 19 : return "";
1155 : }
1156 :
1157 : /************************************************************************/
1158 : /* OGR_L_GetGeometryColumn() */
1159 : /************************************************************************/
1160 :
1161 20 : const char *OGR_L_GetGeometryColumn( OGRLayerH hLayer )
1162 :
1163 : {
1164 20 : VALIDATE_POINTER1( hLayer, "OGR_L_GetGeometryColumn", NULL );
1165 :
1166 20 : return ((OGRLayer *) hLayer)->GetGeometryColumn();
1167 : }
1168 :
1169 : /************************************************************************/
1170 : /* GetStyleTable() */
1171 : /************************************************************************/
1172 :
1173 80 : OGRStyleTable *OGRLayer::GetStyleTable()
1174 : {
1175 80 : return m_poStyleTable;
1176 : }
1177 :
1178 : /************************************************************************/
1179 : /* SetStyleTableDirectly() */
1180 : /************************************************************************/
1181 :
1182 0 : void OGRLayer::SetStyleTableDirectly( OGRStyleTable *poStyleTable )
1183 : {
1184 0 : if ( m_poStyleTable )
1185 0 : delete m_poStyleTable;
1186 0 : m_poStyleTable = poStyleTable;
1187 0 : }
1188 :
1189 : /************************************************************************/
1190 : /* SetStyleTable() */
1191 : /************************************************************************/
1192 :
1193 80 : void OGRLayer::SetStyleTable(OGRStyleTable *poStyleTable)
1194 : {
1195 80 : if ( m_poStyleTable )
1196 0 : delete m_poStyleTable;
1197 80 : if ( poStyleTable )
1198 0 : m_poStyleTable = poStyleTable->Clone();
1199 80 : }
1200 :
1201 : /************************************************************************/
1202 : /* OGR_L_GetStyleTable() */
1203 : /************************************************************************/
1204 :
1205 0 : OGRStyleTableH OGR_L_GetStyleTable( OGRLayerH hLayer )
1206 :
1207 : {
1208 0 : VALIDATE_POINTER1( hLayer, "OGR_L_GetStyleTable", NULL );
1209 :
1210 0 : return (OGRStyleTableH) ((OGRLayer *) hLayer)->GetStyleTable( );
1211 : }
1212 :
1213 : /************************************************************************/
1214 : /* OGR_L_SetStyleTableDirectly() */
1215 : /************************************************************************/
1216 :
1217 0 : void OGR_L_SetStyleTableDirectly( OGRLayerH hLayer,
1218 : OGRStyleTableH hStyleTable )
1219 :
1220 : {
1221 0 : VALIDATE_POINTER0( hLayer, "OGR_L_SetStyleTableDirectly" );
1222 :
1223 0 : ((OGRLayer *) hLayer)->SetStyleTableDirectly( (OGRStyleTable *) hStyleTable);
1224 : }
1225 :
1226 : /************************************************************************/
1227 : /* OGR_L_SetStyleTable() */
1228 : /************************************************************************/
1229 :
1230 0 : void OGR_L_SetStyleTable( OGRLayerH hLayer,
1231 : OGRStyleTableH hStyleTable )
1232 :
1233 : {
1234 0 : VALIDATE_POINTER0( hLayer, "OGR_L_SetStyleTable" );
1235 0 : VALIDATE_POINTER0( hStyleTable, "OGR_L_SetStyleTable" );
1236 :
1237 0 : ((OGRLayer *) hLayer)->SetStyleTable( (OGRStyleTable *) hStyleTable);
1238 : }
1239 :
1240 : /************************************************************************/
1241 : /* GetName() */
1242 : /************************************************************************/
1243 :
1244 301710 : const char *OGRLayer::GetName()
1245 :
1246 : {
1247 301710 : return GetLayerDefn()->GetName();
1248 : }
1249 :
1250 : /************************************************************************/
1251 : /* OGR_L_GetName() */
1252 : /************************************************************************/
1253 :
1254 1620 : const char* OGR_L_GetName( OGRLayerH hLayer )
1255 :
1256 : {
1257 1620 : VALIDATE_POINTER1( hLayer, "OGR_L_GetName", "" );
1258 :
1259 1620 : return ((OGRLayer *) hLayer)->GetName();
1260 : }
1261 :
1262 : /************************************************************************/
1263 : /* GetGeomType() */
1264 : /************************************************************************/
1265 :
1266 379 : OGRwkbGeometryType OGRLayer::GetGeomType()
1267 : {
1268 379 : return GetLayerDefn()->GetGeomType();
1269 : }
1270 : /************************************************************************/
1271 : /* OGR_L_GetGeomType() */
1272 : /************************************************************************/
1273 :
1274 55 : OGRwkbGeometryType OGR_L_GetGeomType( OGRLayerH hLayer )
1275 :
1276 : {
1277 55 : VALIDATE_POINTER1( hLayer, "OGR_L_GetGeomType", wkbUnknown );
1278 :
1279 55 : return ((OGRLayer *) hLayer)->GetGeomType();
1280 : }
1281 :
1282 : /************************************************************************/
1283 : /* SetIgnoredFields() */
1284 : /************************************************************************/
1285 :
1286 429 : OGRErr OGRLayer::SetIgnoredFields( const char **papszFields )
1287 : {
1288 429 : OGRFeatureDefn *poDefn = GetLayerDefn();
1289 :
1290 : // first set everything as *not* ignored
1291 2476 : for( int iField = 0; iField < poDefn->GetFieldCount(); iField++ )
1292 : {
1293 2047 : poDefn->GetFieldDefn(iField)->SetIgnored( FALSE );
1294 : }
1295 429 : poDefn->SetGeometryIgnored( FALSE );
1296 429 : poDefn->SetStyleIgnored( FALSE );
1297 :
1298 429 : if ( papszFields == NULL )
1299 307 : return OGRERR_NONE;
1300 :
1301 : // ignore some fields
1302 951 : while ( *papszFields )
1303 : {
1304 707 : const char* pszFieldName = *papszFields;
1305 : // check special fields
1306 707 : if ( EQUAL(pszFieldName, "OGR_GEOMETRY") )
1307 0 : poDefn->SetGeometryIgnored( TRUE );
1308 707 : else if ( EQUAL(pszFieldName, "OGR_STYLE") )
1309 0 : poDefn->SetStyleIgnored( TRUE );
1310 : else
1311 : {
1312 : // check ordinary fields
1313 707 : int iField = poDefn->GetFieldIndex(pszFieldName);
1314 707 : if ( iField == -1 )
1315 0 : return OGRERR_FAILURE;
1316 : else
1317 707 : poDefn->GetFieldDefn(iField)->SetIgnored( TRUE );
1318 : }
1319 707 : papszFields++;
1320 : }
1321 :
1322 122 : return OGRERR_NONE;
1323 : }
1324 :
1325 : /************************************************************************/
1326 : /* OGR_L_SetIgnoredFields() */
1327 : /************************************************************************/
1328 :
1329 3 : OGRErr OGR_L_SetIgnoredFields( OGRLayerH hLayer, const char **papszFields )
1330 :
1331 : {
1332 3 : VALIDATE_POINTER1( hLayer, "OGR_L_SetIgnoredFields", OGRERR_INVALID_HANDLE );
1333 :
1334 3 : return ((OGRLayer *) hLayer)->SetIgnoredFields( papszFields );
1335 : }
|