LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/generic - ogrunionlayer.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 2 2 100.0 %
Date: 2025-01-18 12:42:00 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  OpenGIS Simple Features Reference Implementation
       4             :  * Purpose:  Defines OGRUnionLayer class
       5             :  * Author:   Even Rouault, even dot rouault at spatialys.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2012-2014, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #ifndef OGRUNIONLAYER_H_INCLUDED
      14             : #define OGRUNIONLAYER_H_INCLUDED
      15             : 
      16             : #ifndef DOXYGEN_SKIP
      17             : 
      18             : #include "ogrsf_frmts.h"
      19             : 
      20             : /************************************************************************/
      21             : /*                      OGRUnionLayerGeomFieldDefn                      */
      22             : /************************************************************************/
      23             : 
      24             : class CPL_DLL OGRUnionLayerGeomFieldDefn final : public OGRGeomFieldDefn
      25             : {
      26             :   public:
      27             :     int bGeomTypeSet = false;
      28             :     int bSRSSet = false;
      29             :     OGREnvelope sStaticEnvelope{};
      30             : 
      31             :     OGRUnionLayerGeomFieldDefn(const char *pszName, OGRwkbGeometryType eType);
      32             :     explicit OGRUnionLayerGeomFieldDefn(const OGRGeomFieldDefn *poSrc);
      33             :     explicit OGRUnionLayerGeomFieldDefn(
      34             :         const OGRUnionLayerGeomFieldDefn *poSrc);
      35             :     ~OGRUnionLayerGeomFieldDefn();
      36             : };
      37             : 
      38             : /************************************************************************/
      39             : /*                         OGRUnionLayer                                */
      40             : /************************************************************************/
      41             : 
      42             : typedef enum
      43             : {
      44             :     FIELD_FROM_FIRST_LAYER,
      45             :     FIELD_UNION_ALL_LAYERS,
      46             :     FIELD_INTERSECTION_ALL_LAYERS,
      47             :     FIELD_SPECIFIED,
      48             : } FieldUnionStrategy;
      49             : 
      50             : class CPL_DLL OGRUnionLayer final : public OGRLayer
      51             : {
      52             :     CPL_DISALLOW_COPY_ASSIGN(OGRUnionLayer)
      53             : 
      54             :   protected:
      55             :     CPLString osName{};
      56             :     int nSrcLayers = 0;
      57             :     OGRLayer **papoSrcLayers = nullptr;
      58             :     int bHasLayerOwnership = false;
      59             : 
      60             :     OGRFeatureDefn *poFeatureDefn = nullptr;
      61             :     int nFields = 0;
      62             :     OGRFieldDefn **papoFields = nullptr;
      63             :     int nGeomFields = 0;
      64             :     OGRUnionLayerGeomFieldDefn **papoGeomFields = nullptr;
      65             :     FieldUnionStrategy eFieldStrategy = FIELD_UNION_ALL_LAYERS;
      66             :     CPLString osSourceLayerFieldName{};
      67             : 
      68             :     int bPreserveSrcFID = false;
      69             : 
      70             :     GIntBig nFeatureCount = -1;
      71             : 
      72             :     int iCurLayer = -1;
      73             :     char *pszAttributeFilter = nullptr;
      74             :     int nNextFID = 0;
      75             :     int *panMap = nullptr;
      76             :     CPLStringList m_aosIgnoredFields{};
      77             :     int bAttrFilterPassThroughValue = -1;
      78             :     int *pabModifiedLayers = nullptr;
      79             :     int *pabCheckIfAutoWrap = nullptr;
      80             :     const OGRSpatialReference *poGlobalSRS = nullptr;
      81             : 
      82             :     void AutoWarpLayerIfNecessary(int iSubLayer);
      83             :     OGRFeature *TranslateFromSrcLayer(OGRFeature *poSrcFeature);
      84             :     void ApplyAttributeFilterToSrcLayer(int iSubLayer);
      85             :     int GetAttrFilterPassThroughValue();
      86             :     void ConfigureActiveLayer();
      87             :     void SetSpatialFilterToSourceLayer(OGRLayer *poSrcLayer);
      88             : 
      89             :   public:
      90             :     OGRUnionLayer(
      91             :         const char *pszName, int nSrcLayers, /* must be >= 1 */
      92             :         OGRLayer *
      93             :             *papoSrcLayers, /* array itself ownership always transferred, layer
      94             :                                ownership depending on bTakeLayerOwnership */
      95             :         int bTakeLayerOwnership);
      96             : 
      97             :     virtual ~OGRUnionLayer();
      98             : 
      99             :     /* All the following non virtual methods must be called just after the
     100             :      * constructor */
     101             :     /* and before any virtual method */
     102             :     void SetFields(
     103             :         FieldUnionStrategy eFieldStrategy, int nFields,
     104             :         OGRFieldDefn **papoFields, /* duplicated by the method */
     105             :         int nGeomFields, /* maybe -1 to explicitly disable geometry fields */
     106             :         OGRUnionLayerGeomFieldDefn *
     107             :             *papoGeomFields /* duplicated by the method */);
     108             :     void SetSourceLayerFieldName(const char *pszSourceLayerFieldName);
     109             :     void SetPreserveSrcFID(int bPreserveSrcFID);
     110             :     void SetFeatureCount(int nFeatureCount);
     111             : 
     112         270 :     virtual const char *GetName() override
     113             :     {
     114         270 :         return osName.c_str();
     115             :     }
     116             : 
     117             :     virtual OGRwkbGeometryType GetGeomType() override;
     118             : 
     119             :     virtual void ResetReading() override;
     120             :     virtual OGRFeature *GetNextFeature() override;
     121             : 
     122             :     virtual OGRFeature *GetFeature(GIntBig nFeatureId) override;
     123             : 
     124             :     virtual OGRErr ICreateFeature(OGRFeature *poFeature) override;
     125             : 
     126             :     virtual OGRErr ISetFeature(OGRFeature *poFeature) override;
     127             : 
     128             :     virtual OGRErr IUpsertFeature(OGRFeature *poFeature) override;
     129             : 
     130             :     OGRErr IUpdateFeature(OGRFeature *poFeature, int nUpdatedFieldsCount,
     131             :                           const int *panUpdatedFieldsIdx,
     132             :                           int nUpdatedGeomFieldsCount,
     133             :                           const int *panUpdatedGeomFieldsIdx,
     134             :                           bool bUpdateStyleString) override;
     135             : 
     136             :     virtual OGRFeatureDefn *GetLayerDefn() override;
     137             : 
     138             :     virtual OGRSpatialReference *GetSpatialRef() override;
     139             : 
     140             :     virtual GIntBig GetFeatureCount(int) override;
     141             : 
     142             :     virtual OGRErr SetAttributeFilter(const char *) override;
     143             : 
     144             :     virtual int TestCapability(const char *) override;
     145             : 
     146             :     virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent,
     147             :                              int bForce = TRUE) override;
     148             :     virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce) override;
     149             : 
     150             :     virtual void SetSpatialFilter(OGRGeometry *poGeomIn) override;
     151             :     virtual void SetSpatialFilter(int iGeomField, OGRGeometry *) override;
     152             : 
     153             :     virtual OGRErr SetIgnoredFields(CSLConstList papszFields) override;
     154             : 
     155             :     virtual OGRErr SyncToDisk() override;
     156             : };
     157             : 
     158             : #endif /* #ifndef DOXYGEN_SKIP */
     159             : 
     160             : #endif  // OGRUNIONLAYER_H_INCLUDED

Generated by: LCOV version 1.14