Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

ogr_gensql.h

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

Generated for GDAL by doxygen 1.4.4.