ogr_gensql.h

00001 /******************************************************************************
00002  * $Id: ogr_gensql.h 23531 2011-12-11 19:11:56Z rouault $
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 #ifndef _OGR_GENSQL_H_INCLUDED
00031 #define _OGR_GENSQL_H_INCLUDED
00032 
00033 #include "ogrsf_frmts.h"
00034 #include "swq.h"
00035 #include "cpl_hash_set.h"
00036 
00037 /************************************************************************/
00038 /*                        OGRGenSQLResultsLayer                         */
00039 /************************************************************************/
00040 
00041 class CPL_DLL OGRGenSQLResultsLayer : public OGRLayer
00042 {
00043   private:
00044     OGRDataSource *poSrcDS;
00045     OGRLayer    *poSrcLayer;
00046     void        *pSelectInfo;
00047 
00048     char        *pszWHERE;
00049 
00050     OGRLayer   **papoTableLayers;
00051 
00052     OGRFeatureDefn *poDefn;
00053 
00054     int         PrepareSummary();
00055 
00056     int         nIndexSize;
00057     long       *panFIDIndex;
00058 
00059     int         nNextIndexFID;
00060     OGRFeature  *poSummaryFeature;
00061 
00062     int         iFIDFieldIndex;
00063 
00064     OGRField    *pasOrderByIndex;
00065 
00066     int         nExtraDSCount;
00067     OGRDataSource **papoExtraDS;
00068 
00069     OGRFeature *TranslateFeature( OGRFeature * );
00070     void        CreateOrderByIndex();
00071     void        SortIndexSection( OGRField *pasIndexFields, 
00072                                   int nStart, int nEntries );
00073     int         Compare( OGRField *pasFirst, OGRField *pasSecond );
00074 
00075     void        ClearFilters();
00076 
00077     void        FindAndSetIgnoredFields();
00078     void        ExploreExprForIgnoredFields(swq_expr_node* expr, CPLHashSet* hSet);
00079     void        AddFieldDefnToSet(int iTable, int iColumn, CPLHashSet* hSet);
00080 
00081     int         ContainGeomSpecialField(swq_expr_node* expr);
00082   public:
00083                 OGRGenSQLResultsLayer( OGRDataSource *poSrcDS, 
00084                                        void *pSelectInfo, 
00085                                        OGRGeometry *poSpatFilter,
00086                                        const char *pszWHERE,
00087                                        const char *pszDialect );
00088     virtual     ~OGRGenSQLResultsLayer();
00089 
00090     virtual OGRGeometry *GetSpatialFilter();
00091 
00092     virtual void        ResetReading();
00093     virtual OGRFeature *GetNextFeature();
00094     virtual OGRErr      SetNextByIndex( long nIndex );
00095     virtual OGRFeature *GetFeature( long nFID );
00096 
00097     virtual OGRFeatureDefn *GetLayerDefn();
00098 
00099     virtual OGRSpatialReference *GetSpatialRef();
00100 
00101     virtual int         GetFeatureCount( int bForce = TRUE );
00102     virtual OGRErr      GetExtent(OGREnvelope *psExtent, int bForce = TRUE);
00103 
00104     virtual int         TestCapability( const char * );
00105 };
00106 
00107 #endif /* ndef _OGR_GENSQL_H_INCLUDED */
00108 

Generated for GDAL by doxygen 1.6.1.