LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/ogdi - ogrogdi.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 20 22 90.9 %
Date: 2024-04-29 17:29:47 Functions: 9 10 90.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  * $Id$
       3             :  *
       4             :  * Project:  OGDI Bridge
       5             :  * Purpose:  Private definitions within the OGDI driver to implement
       6             :  *           integration with OGR.
       7             :  * Author:   Daniel Morissette, danmo@videotron.ca
       8             :  *           (Based on some code contributed by Frank Warmerdam :)
       9             :  *
      10             :  ******************************************************************************
      11             :  * Copyright (c) 2000,  Daniel Morissette
      12             :  *
      13             :  * Permission is hereby granted, free of charge, to any person obtaining a
      14             :  * copy of this software and associated documentation files (the "Software"),
      15             :  * to deal in the Software without restriction, including without limitation
      16             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      17             :  * and/or sell copies of the Software, and to permit persons to whom the
      18             :  * Software is furnished to do so, subject to the following conditions:
      19             :  *
      20             :  * The above copyright notice and this permission notice shall be included
      21             :  * in all copies or substantial portions of the Software.
      22             :  *
      23             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      24             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      25             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      26             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      27             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      28             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      29             :  * DEALINGS IN THE SOFTWARE.
      30             :  ****************************************************************************/
      31             : 
      32             : #ifndef OGDOGDI_H_INCLUDED
      33             : #define OGDOGDI_H_INCLUDED
      34             : 
      35             : #include <math.h>
      36             : extern "C"
      37             : {
      38             : /* Older versions of OGDI have register keywords as qualifier for arguments
      39             :  * of functions, which is illegal in C++17 */
      40             : #define register
      41             : #include "ecs.h"
      42             : #undef register
      43             : }
      44             : #include "ogrsf_frmts.h"
      45             : 
      46             : /************************************************************************/
      47             : /*                             OGROGDILayer                             */
      48             : /************************************************************************/
      49             : class OGROGDIDataSource;
      50             : 
      51             : class OGROGDILayer final : public OGRLayer
      52             : {
      53             :     OGROGDIDataSource *m_poODS;
      54             :     int m_nClientID;
      55             :     char *m_pszOGDILayerName;
      56             :     ecs_Family m_eFamily;
      57             : 
      58             :     OGRFeatureDefn *m_poFeatureDefn;
      59             :     OGRSpatialReference *m_poSpatialRef;
      60             :     ecs_Region m_sFilterBounds;
      61             : 
      62             :     int m_iNextShapeId;
      63             :     int m_nTotalShapeCount;
      64             :     int m_nFilteredOutShapes;
      65             : 
      66             :     OGRFeature *GetNextRawFeature();
      67             : 
      68             :   public:
      69             :     OGROGDILayer(OGROGDIDataSource *, const char *, ecs_Family);
      70             :     virtual ~OGROGDILayer();
      71             : 
      72             :     virtual void SetSpatialFilter(OGRGeometry *) override;
      73             : 
      74          78 :     virtual void SetSpatialFilter(int iGeomField, OGRGeometry *poGeom) override
      75             :     {
      76          78 :         OGRLayer::SetSpatialFilter(iGeomField, poGeom);
      77          78 :     }
      78             : 
      79             :     virtual OGRErr SetAttributeFilter(const char *pszQuery) override;
      80             : 
      81             :     void ResetReading() override;
      82             :     OGRFeature *GetNextFeature() override;
      83             : 
      84             :     OGRFeature *GetFeature(GIntBig nFeatureId) override;
      85             : 
      86        2041 :     OGRFeatureDefn *GetLayerDefn() override
      87             :     {
      88        2041 :         return m_poFeatureDefn;
      89             :     }
      90             : 
      91             :     GIntBig GetFeatureCount(int) override;
      92             : 
      93             :     int TestCapability(const char *) override;
      94             : 
      95             :   private:
      96             :     void BuildFeatureDefn();
      97             : };
      98             : 
      99             : /************************************************************************/
     100             : /*                          OGROGDIDataSource                           */
     101             : /************************************************************************/
     102             : 
     103             : class OGROGDIDataSource final : public OGRDataSource
     104             : {
     105             :     OGROGDILayer **m_papoLayers;
     106             :     int m_nLayers;
     107             : 
     108             :     int m_nClientID;
     109             : 
     110             :     ecs_Region m_sGlobalBounds;
     111             :     OGRSpatialReference *m_poSpatialRef;
     112             : 
     113             :     OGROGDILayer *m_poCurrentLayer;
     114             : 
     115             :     char *m_pszFullName;
     116             : 
     117             :     int m_bLaunderLayerNames;
     118             : 
     119             :     void IAddLayer(const char *pszLayerName, ecs_Family eFamily);
     120             : 
     121             :   public:
     122             :     OGROGDIDataSource();
     123             :     ~OGROGDIDataSource();
     124             : 
     125             :     int Open(const char *);
     126             : 
     127           0 :     const char *GetName() override
     128             :     {
     129           0 :         return m_pszFullName;
     130             :     }
     131             : 
     132         455 :     int GetLayerCount() override
     133             :     {
     134         455 :         return m_nLayers;
     135             :     }
     136             : 
     137             :     OGRLayer *GetLayer(int) override;
     138             : 
     139             :     int TestCapability(const char *) override;
     140             : 
     141         608 :     ecs_Region *GetGlobalBounds()
     142             :     {
     143         608 :         return &m_sGlobalBounds;
     144             :     }
     145             : 
     146          19 :     OGRSpatialReference *DSGetSpatialRef()
     147             :     {
     148          19 :         return m_poSpatialRef;
     149             :     }
     150             : 
     151          19 :     int GetClientID()
     152             :     {
     153          19 :         return m_nClientID;
     154             :     }
     155             : 
     156        1378 :     OGROGDILayer *GetCurrentLayer()
     157             :     {
     158        1378 :         return m_poCurrentLayer;
     159             :     }
     160             : 
     161           8 :     void SetCurrentLayer(OGROGDILayer *poLayer)
     162             :     {
     163           8 :         m_poCurrentLayer = poLayer;
     164           8 :     }
     165             : 
     166          19 :     int LaunderLayerNames()
     167             :     {
     168          19 :         return m_bLaunderLayerNames;
     169             :     }
     170             : };
     171             : 
     172             : #endif /* OGDOGDI_H_INCLUDED */

Generated by: LCOV version 1.14