LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/s57 - ogr_s57.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 12 14 85.7 %
Date: 2024-04-29 01:40:10 Functions: 6 7 85.7 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  * $Id$
       3             :  *
       4             :  * Project:  S-57 Translator
       5             :  * Purpose:  Declarations for classes binding S57 support onto OGRLayer,
       6             :  *           OGRDataSource and OGRDriver.  See also s57.h.
       7             :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       8             :  *
       9             :  ******************************************************************************
      10             :  * Copyright (c) 1999, Frank Warmerdam
      11             :  *
      12             :  * Permission is hereby granted, free of charge, to any person obtaining a
      13             :  * copy of this software and associated documentation files (the "Software"),
      14             :  * to deal in the Software without restriction, including without limitation
      15             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      16             :  * and/or sell copies of the Software, and to permit persons to whom the
      17             :  * Software is furnished to do so, subject to the following conditions:
      18             :  *
      19             :  * The above copyright notice and this permission notice shall be included
      20             :  * in all copies or substantial portions of the Software.
      21             :  *
      22             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      23             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      24             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      25             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      26             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      27             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      28             :  * DEALINGS IN THE SOFTWARE.
      29             :  ****************************************************************************/
      30             : 
      31             : #ifndef OGR_S57_H_INCLUDED
      32             : #define OGR_S57_H_INCLUDED
      33             : 
      34             : #include "ogrsf_frmts.h"
      35             : #include "s57.h"
      36             : 
      37             : class OGRS57DataSource;
      38             : 
      39             : /************************************************************************/
      40             : /*                             OGRS57Layer                              */
      41             : /*                                                                      */
      42             : /*      Represents all features of a particular S57 object class.       */
      43             : /************************************************************************/
      44             : 
      45             : class OGRS57Layer final : public OGRLayer
      46             : {
      47             :     OGRS57DataSource *poDS;
      48             : 
      49             :     OGRFeatureDefn *poFeatureDefn;
      50             : 
      51             :     int nCurrentModule;
      52             :     int nRCNM;
      53             :     int nOBJL;
      54             :     int nNextFEIndex;
      55             :     int nFeatureCount;
      56             : 
      57             :   public:
      58             :     OGRS57Layer(OGRS57DataSource *poDS, OGRFeatureDefn *,
      59             :                 int nFeatureCount = -1, int nOBJL = -1);
      60             :     virtual ~OGRS57Layer();
      61             : 
      62             :     void ResetReading() override;
      63             :     OGRFeature *GetNextFeature() override;
      64             :     OGRFeature *GetNextUnfilteredFeature();
      65             :     virtual OGRFeature *GetFeature(GIntBig nFeatureId) override;
      66             : 
      67             :     virtual GIntBig GetFeatureCount(int bForce = TRUE) override;
      68             :     virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce = TRUE) override;
      69             : 
      70          50 :     virtual OGRErr GetExtent(int iGeomField, OGREnvelope *psExtent,
      71             :                              int bForce) override
      72             :     {
      73          50 :         return OGRLayer::GetExtent(iGeomField, psExtent, bForce);
      74             :     }
      75             : 
      76       15678 :     OGRFeatureDefn *GetLayerDefn() override
      77             :     {
      78       15678 :         return poFeatureDefn;
      79             :     }
      80             : 
      81             :     virtual OGRErr ICreateFeature(OGRFeature *poFeature) override;
      82             :     int TestCapability(const char *) override;
      83             : };
      84             : 
      85             : /************************************************************************/
      86             : /*                          OGRS57DataSource                            */
      87             : /************************************************************************/
      88             : 
      89             : class OGRS57DataSource final : public OGRDataSource
      90             : {
      91             :     char *pszName;
      92             : 
      93             :     int nLayers;
      94             :     OGRS57Layer **papoLayers;
      95             : 
      96             :     OGRSpatialReference *poSpatialRef;
      97             : 
      98             :     char **papszOptions;
      99             : 
     100             :     int nModules;
     101             :     S57Reader **papoModules;
     102             : 
     103             :     S57Writer *poWriter;
     104             : 
     105             :     S57ClassContentExplorer *poClassContentExplorer;
     106             : 
     107             :     bool bExtentsSet;
     108             :     OGREnvelope oExtents;
     109             : 
     110             :     CPL_DISALLOW_COPY_ASSIGN(OGRS57DataSource)
     111             : 
     112             :   public:
     113             :     explicit OGRS57DataSource(char **papszOpenOptions = nullptr);
     114             :     ~OGRS57DataSource();
     115             : 
     116             :     void SetOptionList(char **);
     117             :     const char *GetOption(const char *);
     118             : 
     119             :     int Open(const char *pszName);
     120             :     int Create(const char *pszName, char **papszOptions);
     121             : 
     122           0 :     const char *GetName() override
     123             :     {
     124           0 :         return pszName;
     125             :     }
     126             : 
     127        3653 :     int GetLayerCount() override
     128             :     {
     129        3653 :         return nLayers;
     130             :     }
     131             : 
     132             :     OGRLayer *GetLayer(int) override;
     133             :     void AddLayer(OGRS57Layer *);
     134             :     int TestCapability(const char *) override;
     135             : 
     136        5221 :     OGRSpatialReference *DSGetSpatialRef()
     137             :     {
     138        5221 :         return poSpatialRef;
     139             :     }
     140             : 
     141        2010 :     int GetModuleCount()
     142             :     {
     143        2010 :         return nModules;
     144             :     }
     145             : 
     146             :     S57Reader *GetModule(int);
     147             : 
     148         118 :     S57Writer *GetWriter()
     149             :     {
     150         118 :         return poWriter;
     151             :     }
     152             : 
     153             :     OGRErr GetDSExtent(OGREnvelope *psExtent, int bForce = TRUE);
     154             : };
     155             : 
     156             : /************************************************************************/
     157             : /*                            OGRS57Driver                              */
     158             : /************************************************************************/
     159             : 
     160             : class OGRS57Driver final : public GDALDriver
     161             : {
     162             :     static S57ClassRegistrar *poRegistrar;
     163             : 
     164             :   public:
     165             :     OGRS57Driver();
     166             :     ~OGRS57Driver();
     167             : 
     168             :     static GDALDataset *Open(GDALOpenInfo *poOpenInfo);
     169             :     static GDALDataset *Create(const char *pszName, int nBands, int nXSize,
     170             :                                int nYSize, GDALDataType eDT,
     171             :                                char **papszOptions);
     172             : 
     173             :     static S57ClassRegistrar *GetS57Registrar();
     174             : };
     175             : 
     176             : #endif /* ndef OGR_S57_H_INCLUDED */

Generated by: LCOV version 1.14