00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _OGRUNIONLAYER_H_INCLUDED
00031 #define _OGRUNIONLAYER_H_INCLUDED
00032
00033 #include "ogrsf_frmts.h"
00034
00035
00036
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
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 int 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,
00105 OGRLayer** papoSrcLayers,
00106 int bTakeLayerOwnership);
00107
00108 virtual ~OGRUnionLayer();
00109
00110
00111
00112 void SetFields(FieldUnionStrategy eFieldStrategy,
00113 int nFields,
00114 OGRFieldDefn** papoFields,
00115 int nGeomFields,
00116 OGRUnionLayerGeomFieldDefn** papoGeomFields );
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( long nFeatureId );
00127
00128 virtual OGRErr CreateFeature( OGRFeature* poFeature );
00129
00130 virtual OGRErr SetFeature( OGRFeature* poFeature );
00131
00132 virtual OGRFeatureDefn *GetLayerDefn();
00133
00134 virtual OGRSpatialReference *GetSpatialRef();
00135
00136 virtual int 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