00001 /****************************************************************************** 00002 * $Id: ogr_gensql.h,v 1.6 2003/03/20 19:13:21 warmerda Exp $ 00003 * 00004 * Project: OpenGIS Simple Features Reference Implementation 00005 * Purpose: Classes related to generic implementation of ExecuteSQL(). 00006 * Author: Frank Warmerdam, warmerdam@pobox.com 00007 * 00008 ****************************************************************************** 00009 * Copyright (c) 2002, Frank Warmerdam 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 * $Log: ogr_gensql.h,v $ 00031 * Revision 1.6 2003/03/20 19:13:21 warmerda 00032 * Added ClearFilters() method to cleanup spatial or attribute filters on the 00033 * target layer, and any joined layers. Used in destructor and after all 00034 * features have been read from source layer. 00035 * 00036 * Revision 1.5 2003/03/19 20:34:23 warmerda 00037 * add support for tables from external datasources 00038 * 00039 * Revision 1.4 2003/03/05 05:10:17 warmerda 00040 * implement join support 00041 * 00042 * Revision 1.3 2002/04/29 19:35:50 warmerda 00043 * fixes for selecting FID 00044 * 00045 * Revision 1.2 2002/04/25 16:07:55 warmerda 00046 * fleshed out DISTINCT support 00047 * 00048 * Revision 1.1 2002/04/25 02:24:37 warmerda 00049 * New 00050 * 00051 */ 00052 00053 #ifndef _OGR_GENSQL_H_INCLUDED 00054 #define _OGR_GENSQL_H_INCLUDED 00055 00056 #include "ogrsf_frmts.h" 00057 00058 /************************************************************************/ 00059 /* OGRGenSQLResultsLayer */ 00060 /************************************************************************/ 00061 00062 class CPL_DLL OGRGenSQLResultsLayer : public OGRLayer 00063 { 00064 private: 00065 OGRDataSource *poSrcDS; 00066 OGRLayer *poSrcLayer; 00067 void *pSelectInfo; 00068 00069 OGRLayer **papoTableLayers; 00070 00071 OGRGeometry *poSpatialFilter; 00072 00073 OGRFeatureDefn *poDefn; 00074 00075 int PrepareSummary(); 00076 00077 int nIndexSize; 00078 long *panFIDIndex; 00079 00080 int nNextIndexFID; 00081 OGRFeature *poSummaryFeature; 00082 00083 int iFIDFieldIndex; 00084 00085 OGRField *pasOrderByIndex; 00086 00087 int nExtraDSCount; 00088 OGRDataSource **papoExtraDS; 00089 00090 OGRFeature *TranslateFeature( OGRFeature * ); 00091 void CreateOrderByIndex(); 00092 void SortIndexSection( OGRField *pasIndexFields, 00093 int nStart, int nEntries ); 00094 int Compare( OGRField *pasFirst, OGRField *pasSecond ); 00095 00096 void ClearFilters(); 00097 00098 public: 00099 OGRGenSQLResultsLayer( OGRDataSource *poSrcDS, 00100 void *pSelectInfo, 00101 OGRGeometry *poSpatFilter ); 00102 virtual ~OGRGenSQLResultsLayer(); 00103 00104 virtual OGRGeometry *GetSpatialFilter(); 00105 virtual void SetSpatialFilter( OGRGeometry * ); 00106 00107 #ifdef notdef 00108 virtual OGRErr SetAttributeFilter( const char * ); 00109 #endif 00110 00111 virtual void ResetReading(); 00112 virtual OGRFeature *GetNextFeature(); 00113 virtual OGRFeature *GetFeature( long nFID ); 00114 00115 virtual OGRFeatureDefn *GetLayerDefn(); 00116 00117 virtual OGRSpatialReference *GetSpatialRef(); 00118 00119 virtual int GetFeatureCount( int bForce = TRUE ); 00120 virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE); 00121 00122 virtual int TestCapability( const char * ); 00123 }; 00124 00125 #endif /* ndef _OGR_GENSQL_H_INCLUDED */ 00126