OGR
ogrunionlayer.h
1 /******************************************************************************
2  * $Id: ogrunionlayer.h 24640 2012-07-01 19:37:38Z rouault $
3  *
4  * Project: OpenGIS Simple Features Reference Implementation
5  * Purpose: Defines OGRUnionLayer class
6  * Author: Even Rouault, even dot rouault at mines dash paris dot org
7  *
8  ******************************************************************************
9  * Copyright (c) 2012, Even Rouault <even dot rouault at mines dash paris dot org>
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 #ifndef _OGRUNIONLAYER_H_INCLUDED
31 #define _OGRUNIONLAYER_H_INCLUDED
32 
33 #include "ogrsf_frmts.h"
34 
35 /************************************************************************/
36 /* OGRUnionLayer */
37 /************************************************************************/
38 
39 typedef enum
40 {
41  FIELD_FROM_FIRST_LAYER,
42  FIELD_UNION_ALL_LAYERS,
43  FIELD_INTERSECTION_ALL_LAYERS,
44  FIELD_SPECIFIED,
45 } FieldUnionStrategy;
46 
47 typedef enum
48 {
49  GEOMTYPE_FROM_FIRST_LAYER,
50  GEOMTYPE_UNION_ALL_LAYERS,
51  GEOMTYPE_SPECIFIED,
52 } GeometryTypeUnionStrategy;
53 
54 class OGRUnionLayer : public OGRLayer
55 {
56  protected:
57  CPLString osName;
58  int nSrcLayers;
59  OGRLayer **papoSrcLayers;
60  int bHasLayerOwnership;
61 
62  OGRFeatureDefn *poFeatureDefn;
63  int nFields;
64  OGRFieldDefn **papoFields;
65  FieldUnionStrategy eFieldStrategy;
66  CPLString osSourceLayerFieldName;
67 
68  OGRwkbGeometryType eGeomType;
69  GeometryTypeUnionStrategy eGeometryTypeStrategy;
70 
71  int bPreserveSrcFID;
72 
73  OGRSpatialReference *poSRS;
74  int bSRSSet;
75 
76  int nFeatureCount;
77  OGREnvelope sStaticEnvelope;
78 
79  int iCurLayer;
80  char *pszAttributeFilter;
81  int nNextFID;
82  int *panMap;
83  char **papszIgnoredFields;
84  int bAttrFilterPassThroughValue;
85  int *pabModifiedLayers;
86  int *pabCheckIfAutoWrap;
87 
88  void AutoWarpLayerIfNecessary(int iSubLayer);
89  OGRFeature *TranslateFromSrcLayer(OGRFeature* poSrcFeature);
90  void ApplyAttributeFilterToSrcLayer(int iSubLayer);
91  int GetAttrFilterPassThroughValue();
92  void ConfigureActiveLayer();
93 
94  public:
95  OGRUnionLayer( const char* pszName,
96  int nSrcLayers, /* must be >= 1 */
97  OGRLayer** papoSrcLayers, /* array itself ownership always transferred, layer ownership depending on bTakeLayerOwnership */
98  int bTakeLayerOwnership);
99 
100  virtual ~OGRUnionLayer();
101 
102  /* All the following non virtual methods must be called just after the constructor */
103  /* and before any virtual method */
104  void SetSRS(OGRSpatialReference *poSRS); /* duplicated by the method */
105  void SetFields(FieldUnionStrategy eFieldStrategy,
106  int nFields,
107  OGRFieldDefn** papoFields); /* duplicated by the method */
108  void SetGeometryType(GeometryTypeUnionStrategy eGeometryTypeStrategy,
109  OGRwkbGeometryType eGeomType);
110  void SetSourceLayerFieldName(const char* pszSourceLayerFieldName);
111  void SetPreserveSrcFID(int bPreserveSrcFID);
112  void SetFeatureCount(int nFeatureCount);
113  void SetExtent(double dfXMin, double dfYMin, double dfXMax, double dfYMax);
114 
115  virtual const char *GetName() { return osName.c_str(); }
117 
118  virtual void ResetReading();
119  virtual OGRFeature *GetNextFeature();
120 
121  virtual OGRFeature *GetFeature( long nFeatureId );
122 
123  virtual OGRErr CreateFeature( OGRFeature* poFeature );
124 
125  virtual OGRErr SetFeature( OGRFeature* poFeature );
126 
127  virtual OGRFeatureDefn *GetLayerDefn();
128 
130 
131  virtual int GetFeatureCount( int );
132 
133  virtual OGRErr SetAttributeFilter( const char * );
134 
135  virtual int TestCapability( const char * );
136 
137  virtual OGRErr GetExtent( OGREnvelope *psExtent, int bForce );
138 
139  virtual void SetSpatialFilter( OGRGeometry * poGeomIn );
140 
141  virtual OGRErr SetIgnoredFields( const char **papszFields );
142 
143  virtual OGRErr SyncToDisk();
144 };
145 
146 #endif // _OGRUNIONLAYER_H_INCLUDED

Generated for GDAL by doxygen 1.8.1.2.