ogrunionlayer.h

00001 /******************************************************************************
00002  * $Id: ogrunionlayer.h 24640 2012-07-01 19:37:38Z 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, Even Rouault <even dot rouault at mines dash 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 #include "ogrsf_frmts.h"
00034 
00035 /************************************************************************/
00036 /*                         OGRUnionLayer                                */
00037 /************************************************************************/
00038 
00039 typedef enum
00040 {
00041     FIELD_FROM_FIRST_LAYER,
00042     FIELD_UNION_ALL_LAYERS,
00043     FIELD_INTERSECTION_ALL_LAYERS,
00044     FIELD_SPECIFIED,
00045 } FieldUnionStrategy;
00046 
00047 typedef enum
00048 {
00049     GEOMTYPE_FROM_FIRST_LAYER,
00050     GEOMTYPE_UNION_ALL_LAYERS,
00051     GEOMTYPE_SPECIFIED,
00052 } GeometryTypeUnionStrategy;
00053 
00054 class OGRUnionLayer : public OGRLayer
00055 {
00056   protected:
00057     CPLString           osName;
00058     int                 nSrcLayers;
00059     OGRLayer          **papoSrcLayers;
00060     int                 bHasLayerOwnership;
00061 
00062     OGRFeatureDefn     *poFeatureDefn;
00063     int                 nFields;
00064     OGRFieldDefn      **papoFields;
00065     FieldUnionStrategy eFieldStrategy;
00066     CPLString           osSourceLayerFieldName;
00067 
00068     OGRwkbGeometryType  eGeomType;
00069     GeometryTypeUnionStrategy eGeometryTypeStrategy;
00070 
00071     int                 bPreserveSrcFID;
00072 
00073     OGRSpatialReference *poSRS;
00074     int                  bSRSSet;
00075 
00076     int                 nFeatureCount;
00077     OGREnvelope         sStaticEnvelope;
00078 
00079     int                 iCurLayer;
00080     char               *pszAttributeFilter;
00081     int                 nNextFID;
00082     int                *panMap;
00083     char              **papszIgnoredFields;
00084     int                 bAttrFilterPassThroughValue;
00085     int                *pabModifiedLayers;
00086     int                *pabCheckIfAutoWrap;
00087 
00088     void                AutoWarpLayerIfNecessary(int iSubLayer);
00089     OGRFeature         *TranslateFromSrcLayer(OGRFeature* poSrcFeature);
00090     void                ApplyAttributeFilterToSrcLayer(int iSubLayer);
00091     int                 GetAttrFilterPassThroughValue();
00092     void                ConfigureActiveLayer();
00093 
00094   public:
00095                         OGRUnionLayer( const char* pszName,
00096                                        int nSrcLayers, /* must be >= 1 */
00097                                        OGRLayer** papoSrcLayers, /* array itself ownership always transfered, layer ownership depending on bTakeLayerOwnership */
00098                                        int bTakeLayerOwnership);
00099 
00100     virtual             ~OGRUnionLayer();
00101 
00102     /* All the following non virtual methods must be called just after the constructor */
00103     /* and before any virtual method */
00104     void                SetSRS(OGRSpatialReference *poSRS);  /* duplicated by the method */
00105     void                SetFields(FieldUnionStrategy eFieldStrategy,
00106                                   int nFields,
00107                                   OGRFieldDefn** papoFields); /* duplicated by the method */
00108     void                SetGeometryType(GeometryTypeUnionStrategy eGeometryTypeStrategy,
00109                                         OGRwkbGeometryType eGeomType);
00110     void                SetSourceLayerFieldName(const char* pszSourceLayerFieldName);
00111     void                SetPreserveSrcFID(int bPreserveSrcFID);
00112     void                SetFeatureCount(int nFeatureCount);
00113     void                SetExtent(double dfXMin, double dfYMin, double dfXMax, double dfYMax);
00114 
00115     virtual const char  *GetName() { return osName.c_str(); }
00116     virtual OGRwkbGeometryType GetGeomType();
00117 
00118     virtual void        ResetReading();
00119     virtual OGRFeature *GetNextFeature();
00120 
00121     virtual OGRFeature *GetFeature( long nFeatureId );
00122 
00123     virtual OGRErr      CreateFeature( OGRFeature* poFeature );
00124 
00125     virtual OGRErr      SetFeature( OGRFeature* poFeature );
00126 
00127     virtual OGRFeatureDefn *GetLayerDefn();
00128 
00129     virtual OGRSpatialReference *GetSpatialRef();
00130 
00131     virtual int         GetFeatureCount( int );
00132 
00133     virtual OGRErr      SetAttributeFilter( const char * );
00134 
00135     virtual int         TestCapability( const char * );
00136 
00137     virtual OGRErr      GetExtent( OGREnvelope *psExtent, int bForce );
00138 
00139     virtual void        SetSpatialFilter( OGRGeometry * poGeomIn );
00140 
00141     virtual OGRErr      SetIgnoredFields( const char **papszFields );
00142 
00143     virtual OGRErr      SyncToDisk();
00144 };
00145 
00146 #endif // _OGRUNIONLAYER_H_INCLUDED

Generated for GDAL by doxygen 1.6.1.