OGR
ogrunionlayer.h
1 /******************************************************************************
2  * $Id: ogrunionlayer.h 27044 2014-03-16 23:41:27Z 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-2014, Even Rouault <even dot rouault at mines-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 /* OGRUnionLayerGeomFieldDefn */
37 /************************************************************************/
38 
40 {
41  public:
42 
43  int bGeomTypeSet;
44  int bSRSSet;
45  OGREnvelope sStaticEnvelope;
46 
47  OGRUnionLayerGeomFieldDefn(const char* pszName, OGRwkbGeometryType eType);
51 };
52 
53 /************************************************************************/
54 /* OGRUnionLayer */
55 /************************************************************************/
56 
57 typedef enum
58 {
59  FIELD_FROM_FIRST_LAYER,
60  FIELD_UNION_ALL_LAYERS,
61  FIELD_INTERSECTION_ALL_LAYERS,
62  FIELD_SPECIFIED,
63 } FieldUnionStrategy;
64 
65 class OGRUnionLayer : public OGRLayer
66 {
67  protected:
68  CPLString osName;
69  int nSrcLayers;
70  OGRLayer **papoSrcLayers;
71  int bHasLayerOwnership;
72 
73  OGRFeatureDefn *poFeatureDefn;
74  int nFields;
75  OGRFieldDefn **papoFields;
76  int nGeomFields;
77  OGRUnionLayerGeomFieldDefn **papoGeomFields;
78  FieldUnionStrategy eFieldStrategy;
79  CPLString osSourceLayerFieldName;
80 
81  int bPreserveSrcFID;
82 
83  int nFeatureCount;
84 
85  int iCurLayer;
86  char *pszAttributeFilter;
87  int nNextFID;
88  int *panMap;
89  char **papszIgnoredFields;
90  int bAttrFilterPassThroughValue;
91  int *pabModifiedLayers;
92  int *pabCheckIfAutoWrap;
93  OGRSpatialReference *poGlobalSRS;
94 
95  void AutoWarpLayerIfNecessary(int iSubLayer);
96  OGRFeature *TranslateFromSrcLayer(OGRFeature* poSrcFeature);
97  void ApplyAttributeFilterToSrcLayer(int iSubLayer);
98  int GetAttrFilterPassThroughValue();
99  void ConfigureActiveLayer();
100  void SetSpatialFilterToSourceLayer(OGRLayer* poSrcLayer);
101 
102  public:
103  OGRUnionLayer( const char* pszName,
104  int nSrcLayers, /* must be >= 1 */
105  OGRLayer** papoSrcLayers, /* array itself ownership always transferred, layer ownership depending on bTakeLayerOwnership */
106  int bTakeLayerOwnership);
107 
108  virtual ~OGRUnionLayer();
109 
110  /* All the following non virtual methods must be called just after the constructor */
111  /* and before any virtual method */
112  void SetFields(FieldUnionStrategy eFieldStrategy,
113  int nFields,
114  OGRFieldDefn** papoFields, /* duplicated by the method */
115  int nGeomFields, /* maybe -1 to explicitely disable geometry fields */
116  OGRUnionLayerGeomFieldDefn** papoGeomFields /* duplicated by the method */);
117  void SetSourceLayerFieldName(const char* pszSourceLayerFieldName);
118  void SetPreserveSrcFID(int bPreserveSrcFID);
119  void SetFeatureCount(int nFeatureCount);
120  virtual const char *GetName() { return osName.c_str(); }
121  virtual OGRwkbGeometryType GetGeomType();
122 
123  virtual void ResetReading();
124  virtual OGRFeature *GetNextFeature();
125 
126  virtual OGRFeature *GetFeature( long nFeatureId );
127 
128  virtual OGRErr CreateFeature( OGRFeature* poFeature );
129 
130  virtual OGRErr SetFeature( OGRFeature* poFeature );
131 
132  virtual OGRFeatureDefn *GetLayerDefn();
133 
135 
136  virtual int GetFeatureCount( int );
137 
138  virtual OGRErr SetAttributeFilter( const char * );
139 
140  virtual int TestCapability( const char * );
141 
142  virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce = TRUE);
143  virtual OGRErr GetExtent( OGREnvelope *psExtent, int bForce );
144 
145  virtual void SetSpatialFilter( OGRGeometry * poGeomIn );
146  virtual void SetSpatialFilter( int iGeomField, OGRGeometry * );
147 
148  virtual OGRErr SetIgnoredFields( const char **papszFields );
149 
150  virtual OGRErr SyncToDisk();
151 };
152 
153 #endif // _OGRUNIONLAYER_H_INCLUDED
Definition: ogrunionlayer.h:65
Definition: ogr_feature.h:112
virtual OGRSpatialReference * GetSpatialRef()
Fetch spatial reference system of this field.
Definition: ogrgeomfielddefn.cpp:395
Convenient string class based on std::string.
Definition: cpl_string.h:226
virtual const char * GetName()
Return the layer name.
Definition: ogrunionlayer.h:120
Definition: ogr_feature.h:167
Definition: ogr_feature.h:52
OGRwkbGeometryType
Definition: ogr_core.h:308
Definition: ogr_geometry.h:79
Definition: ogr_spatialref.h:129
Definition: ogr_core.h:48
Definition: ogrsf_frmts.h:59
Definition: ogr_feature.h:232
Definition: ogrunionlayer.h:39

Generated for GDAL by doxygen 1.8.11.