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