GDAL
|
00001 /****************************************************************************** 00002 * $Id: ogrunionlayer.h 29330 2015-06-14 12:11:11Z 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 #include "ogrsf_frmts.h" 00034 00035 /************************************************************************/ 00036 /* OGRUnionLayerGeomFieldDefn */ 00037 /************************************************************************/ 00038 00039 class OGRUnionLayerGeomFieldDefn: public OGRGeomFieldDefn 00040 { 00041 public: 00042 00043 int bGeomTypeSet; 00044 int bSRSSet; 00045 OGREnvelope sStaticEnvelope; 00046 00047 OGRUnionLayerGeomFieldDefn(const char* pszName, OGRwkbGeometryType eType); 00048 OGRUnionLayerGeomFieldDefn(OGRGeomFieldDefn* poSrc); 00049 OGRUnionLayerGeomFieldDefn(OGRUnionLayerGeomFieldDefn* poSrc); 00050 ~OGRUnionLayerGeomFieldDefn(); 00051 }; 00052 00053 /************************************************************************/ 00054 /* OGRUnionLayer */ 00055 /************************************************************************/ 00056 00057 typedef enum 00058 { 00059 FIELD_FROM_FIRST_LAYER, 00060 FIELD_UNION_ALL_LAYERS, 00061 FIELD_INTERSECTION_ALL_LAYERS, 00062 FIELD_SPECIFIED, 00063 } FieldUnionStrategy; 00064 00065 class OGRUnionLayer : public OGRLayer 00066 { 00067 protected: 00068 CPLString osName; 00069 int nSrcLayers; 00070 OGRLayer **papoSrcLayers; 00071 int bHasLayerOwnership; 00072 00073 OGRFeatureDefn *poFeatureDefn; 00074 int nFields; 00075 OGRFieldDefn **papoFields; 00076 int nGeomFields; 00077 OGRUnionLayerGeomFieldDefn **papoGeomFields; 00078 FieldUnionStrategy eFieldStrategy; 00079 CPLString osSourceLayerFieldName; 00080 00081 int bPreserveSrcFID; 00082 00083 GIntBig nFeatureCount; 00084 00085 int iCurLayer; 00086 char *pszAttributeFilter; 00087 int nNextFID; 00088 int *panMap; 00089 char **papszIgnoredFields; 00090 int bAttrFilterPassThroughValue; 00091 int *pabModifiedLayers; 00092 int *pabCheckIfAutoWrap; 00093 OGRSpatialReference *poGlobalSRS; 00094 00095 void AutoWarpLayerIfNecessary(int iSubLayer); 00096 OGRFeature *TranslateFromSrcLayer(OGRFeature* poSrcFeature); 00097 void ApplyAttributeFilterToSrcLayer(int iSubLayer); 00098 int GetAttrFilterPassThroughValue(); 00099 void ConfigureActiveLayer(); 00100 void SetSpatialFilterToSourceLayer(OGRLayer* poSrcLayer); 00101 00102 public: 00103 OGRUnionLayer( const char* pszName, 00104 int nSrcLayers, /* must be >= 1 */ 00105 OGRLayer** papoSrcLayers, /* array itself ownership always transferred, layer ownership depending on bTakeLayerOwnership */ 00106 int bTakeLayerOwnership); 00107 00108 virtual ~OGRUnionLayer(); 00109 00110 /* All the following non virtual methods must be called just after the constructor */ 00111 /* and before any virtual method */ 00112 void SetFields(FieldUnionStrategy eFieldStrategy, 00113 int nFields, 00114 OGRFieldDefn** papoFields, /* duplicated by the method */ 00115 int nGeomFields, /* maybe -1 to explicitly disable geometry fields */ 00116 OGRUnionLayerGeomFieldDefn** papoGeomFields /* duplicated by the method */); 00117 void SetSourceLayerFieldName(const char* pszSourceLayerFieldName); 00118 void SetPreserveSrcFID(int bPreserveSrcFID); 00119 void SetFeatureCount(int nFeatureCount); 00120 virtual const char *GetName() { return osName.c_str(); } 00121 virtual OGRwkbGeometryType GetGeomType(); 00122 00123 virtual void ResetReading(); 00124 virtual OGRFeature *GetNextFeature(); 00125 00126 virtual OGRFeature *GetFeature( GIntBig nFeatureId ); 00127 00128 virtual OGRErr ICreateFeature( OGRFeature* poFeature ); 00129 00130 virtual OGRErr ISetFeature( OGRFeature* poFeature ); 00131 00132 virtual OGRFeatureDefn *GetLayerDefn(); 00133 00134 virtual OGRSpatialReference *GetSpatialRef(); 00135 00136 virtual GIntBig GetFeatureCount( int ); 00137 00138 virtual OGRErr SetAttributeFilter( const char * ); 00139 00140 virtual int TestCapability( const char * ); 00141 00142 virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent, int bForce = TRUE); 00143 virtual OGRErr GetExtent( OGREnvelope *psExtent, int bForce ); 00144 00145 virtual void SetSpatialFilter( OGRGeometry * poGeomIn ); 00146 virtual void SetSpatialFilter( int iGeomField, OGRGeometry * ); 00147 00148 virtual OGRErr SetIgnoredFields( const char **papszFields ); 00149 00150 virtual OGRErr SyncToDisk(); 00151 }; 00152 00153 #endif // _OGRUNIONLAYER_H_INCLUDED