GDAL
ogrunionlayer.h
00001 /******************************************************************************
00002  * $Id: ogrunionlayer.h 36501 2016-11-25 14:09:24Z rouault $
00003  *
00004  * Project:  OpenGIS Simple Features Reference Implementation
00005  * Purpose:  Defines OGRUnionLayer class
00006  * Author:   Even Rouault, even dot rouault at mines dash paris dot org
00007  *
00008  ******************************************************************************
00009  * Copyright (c) 2012-2014, Even Rouault <even dot rouault at mines-paris dot org>
00010  *
00011  * Permission is hereby granted, free of charge, to any person obtaining a
00012  * copy of this software and associated documentation files (the "Software"),
00013  * to deal in the Software without restriction, including without limitation
00014  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00015  * and/or sell copies of the Software, and to permit persons to whom the
00016  * Software is furnished to do so, subject to the following conditions:
00017  *
00018  * The above copyright notice and this permission notice shall be included
00019  * in all copies or substantial portions of the Software.
00020  *
00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00022  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00023  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00024  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00025  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00026  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00027  * DEALINGS IN THE SOFTWARE.
00028  ****************************************************************************/
00029 
00030 #ifndef OGRUNIONLAYER_H_INCLUDED
00031 #define OGRUNIONLAYER_H_INCLUDED
00032 
00033 #ifndef DOXYGEN_SKIP
00034 
00035 #include "ogrsf_frmts.h"
00036 
00037 /************************************************************************/
00038 /*                      OGRUnionLayerGeomFieldDefn                      */
00039 /************************************************************************/
00040 
00041 class OGRUnionLayerGeomFieldDefn: public OGRGeomFieldDefn
00042 {
00043     public:
00044 
00045     int             bGeomTypeSet;
00046     int             bSRSSet;
00047     OGREnvelope     sStaticEnvelope;
00048 
00049             OGRUnionLayerGeomFieldDefn(const char* pszName, OGRwkbGeometryType eType);
00050    explicit OGRUnionLayerGeomFieldDefn(OGRGeomFieldDefn* poSrc);
00051    explicit OGRUnionLayerGeomFieldDefn(OGRUnionLayerGeomFieldDefn* poSrc);
00052            ~OGRUnionLayerGeomFieldDefn();
00053 };
00054 
00055 /************************************************************************/
00056 /*                         OGRUnionLayer                                */
00057 /************************************************************************/
00058 
00059 typedef enum
00060 {
00061     FIELD_FROM_FIRST_LAYER,
00062     FIELD_UNION_ALL_LAYERS,
00063     FIELD_INTERSECTION_ALL_LAYERS,
00064     FIELD_SPECIFIED,
00065 } FieldUnionStrategy;
00066 
00067 class OGRUnionLayer : public OGRLayer
00068 {
00069   protected:
00070     CPLString           osName;
00071     int                 nSrcLayers;
00072     OGRLayer          **papoSrcLayers;
00073     int                 bHasLayerOwnership;
00074 
00075     OGRFeatureDefn     *poFeatureDefn;
00076     int                 nFields;
00077     OGRFieldDefn      **papoFields;
00078     int                 nGeomFields;
00079     OGRUnionLayerGeomFieldDefn **papoGeomFields;
00080     FieldUnionStrategy eFieldStrategy;
00081     CPLString           osSourceLayerFieldName;
00082 
00083     int                 bPreserveSrcFID;
00084 
00085     GIntBig             nFeatureCount;
00086 
00087     int                 iCurLayer;
00088     char               *pszAttributeFilter;
00089     int                 nNextFID;
00090     int                *panMap;
00091     char              **papszIgnoredFields;
00092     int                 bAttrFilterPassThroughValue;
00093     int                *pabModifiedLayers;
00094     int                *pabCheckIfAutoWrap;
00095     OGRSpatialReference *poGlobalSRS;
00096 
00097     void                AutoWarpLayerIfNecessary(int iSubLayer);
00098     OGRFeature         *TranslateFromSrcLayer(OGRFeature* poSrcFeature);
00099     void                ApplyAttributeFilterToSrcLayer(int iSubLayer);
00100     int                 GetAttrFilterPassThroughValue();
00101     void                ConfigureActiveLayer();
00102     void                SetSpatialFilterToSourceLayer(OGRLayer* poSrcLayer);
00103 
00104   public:
00105                         OGRUnionLayer( const char* pszName,
00106                                        int nSrcLayers, /* must be >= 1 */
00107                                        OGRLayer** papoSrcLayers, /* array itself ownership always transferred, layer ownership depending on bTakeLayerOwnership */
00108                                        int bTakeLayerOwnership);
00109 
00110     virtual             ~OGRUnionLayer();
00111 
00112     /* All the following non virtual methods must be called just after the constructor */
00113     /* and before any virtual method */
00114     void                SetFields(FieldUnionStrategy eFieldStrategy,
00115                                   int nFields,
00116                                   OGRFieldDefn** papoFields,  /* duplicated by the method */
00117                                   int nGeomFields, /* maybe -1 to explicitly disable geometry fields */
00118                                   OGRUnionLayerGeomFieldDefn** papoGeomFields  /* duplicated by the method */);
00119     void                SetSourceLayerFieldName(const char* pszSourceLayerFieldName);
00120     void                SetPreserveSrcFID(int bPreserveSrcFID);
00121     void                SetFeatureCount(int nFeatureCount);
00122     virtual const char  *GetName() override { return osName.c_str(); }
00123     virtual OGRwkbGeometryType GetGeomType() override;
00124 
00125     virtual void        ResetReading() override;
00126     virtual OGRFeature *GetNextFeature() override;
00127 
00128     virtual OGRFeature *GetFeature( GIntBig nFeatureId ) override;
00129 
00130     virtual OGRErr      ICreateFeature( OGRFeature* poFeature ) override;
00131 
00132     virtual OGRErr      ISetFeature( OGRFeature* poFeature ) override;
00133 
00134     virtual OGRFeatureDefn *GetLayerDefn() override;
00135 
00136     virtual OGRSpatialReference *GetSpatialRef() override;
00137 
00138     virtual GIntBig     GetFeatureCount( int ) override;
00139 
00140     virtual OGRErr      SetAttributeFilter( const char * ) override;
00141 
00142     virtual int         TestCapability( const char * ) override;
00143 
00144     virtual OGRErr      GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce = TRUE) override;
00145     virtual OGRErr      GetExtent( OGREnvelope *psExtent, int bForce ) override;
00146 
00147     virtual void        SetSpatialFilter( OGRGeometry * poGeomIn ) override;
00148     virtual void        SetSpatialFilter( int iGeomField, OGRGeometry * ) override;
00149 
00150     virtual OGRErr      SetIgnoredFields( const char **papszFields ) override;
00151 
00152     virtual OGRErr      SyncToDisk() override;
00153 };
00154 
00155 #endif /* #ifndef DOXYGEN_SKIP */
00156 
00157 #endif // OGRUNIONLAYER_H_INCLUDED

Generated for GDAL by doxygen 1.7.6.1.