LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/pds - ogr_pds.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 5 7 71.4 %
Date: 2024-04-29 12:21:24 Functions: 3 4 75.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  * $Id$
       3             :  *
       4             :  * Project:  PDS Translator
       5             :  * Purpose:  Definition of classes for OGR .pdstable driver.
       6             :  * Author:   Even Rouault, even dot rouault at spatialys.com
       7             :  *
       8             :  ******************************************************************************
       9             :  * Copyright (c) 2010, Even Rouault <even dot rouault at spatialys.com>
      10             :  *
      11             :  * Permission is hereby granted, free of charge, to any person obtaining a
      12             :  * copy of this software and associated documentation files (the "Software"),
      13             :  * to deal in the Software without restriction, including without limitation
      14             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15             :  * and/or sell copies of the Software, and to permit persons to whom the
      16             :  * Software is furnished to do so, subject to the following conditions:
      17             :  *
      18             :  * The above copyright notice and this permission notice shall be included
      19             :  * in all copies or substantial portions of the Software.
      20             :  *
      21             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27             :  * DEALINGS IN THE SOFTWARE.
      28             :  ****************************************************************************/
      29             : 
      30             : #ifndef OGR_PDS_H_INCLUDED
      31             : #define OGR_PDS_H_INCLUDED
      32             : 
      33             : #include "ogrsf_frmts.h"
      34             : #include "nasakeywordhandler.h"
      35             : 
      36             : namespace OGRPDS
      37             : {
      38             : 
      39             : /************************************************************************/
      40             : /*                              OGRPDSLayer                             */
      41             : /************************************************************************/
      42             : 
      43             : typedef enum
      44             : {
      45             :     ASCII_REAL,
      46             :     ASCII_INTEGER,
      47             :     CHARACTER,
      48             :     MSB_INTEGER,
      49             :     MSB_UNSIGNED_INTEGER,
      50             :     IEEE_REAL,
      51             : } FieldFormat;
      52             : 
      53             : typedef struct
      54             : {
      55             :     int nStartByte;
      56             :     int nByteCount;
      57             :     FieldFormat eFormat;
      58             :     int nItemBytes;
      59             :     int nItems;
      60             : } FieldDesc;
      61             : 
      62             : class OGRPDSLayer final : public OGRLayer,
      63             :                           public OGRGetNextFeatureThroughRaw<OGRPDSLayer>
      64             : {
      65             :     OGRFeatureDefn *poFeatureDefn;
      66             : 
      67             :     std::string osTableID;
      68             :     VSILFILE *fpPDS;
      69             :     int nRecords;
      70             :     int nStartBytes;
      71             :     int nRecordSize;
      72             :     GByte *pabyRecord;
      73             :     int nNextFID;
      74             :     int nLongitudeIndex;
      75             :     int nLatitudeIndex;
      76             : 
      77             :     FieldDesc *pasFieldDesc;
      78             : 
      79             :     void ReadStructure(const std::string &osStructureFilename);
      80             :     OGRFeature *GetNextRawFeature();
      81             : 
      82             :     CPL_DISALLOW_COPY_ASSIGN(OGRPDSLayer)
      83             : 
      84             :   public:
      85             :     OGRPDSLayer(const std::string &osTableID, const char *pszLayerName,
      86             :                 VSILFILE *fp, const std::string &osLabelFilename,
      87             :                 const std::string &osStructureFilename, int nRecords,
      88             :                 int nStartBytes, int nRecordSize, GByte *pabyRecord,
      89             :                 bool bIsASCII);
      90             :     virtual ~OGRPDSLayer();
      91             : 
      92             :     virtual void ResetReading() override;
      93           2 :     DEFINE_GET_NEXT_FEATURE_THROUGH_RAW(OGRPDSLayer)
      94             : 
      95           1 :     virtual OGRFeatureDefn *GetLayerDefn() override
      96             :     {
      97           1 :         return poFeatureDefn;
      98             :     }
      99             : 
     100             :     virtual int TestCapability(const char *) override;
     101             : 
     102             :     virtual GIntBig GetFeatureCount(int bForce = TRUE) override;
     103             : 
     104             :     virtual OGRFeature *GetFeature(GIntBig nFID) override;
     105             : 
     106             :     virtual OGRErr SetNextByIndex(GIntBig nIndex) override;
     107             : };
     108             : 
     109             : }  // namespace OGRPDS
     110             : 
     111             : /************************************************************************/
     112             : /*                           OGRPDSDataSource                           */
     113             : /************************************************************************/
     114             : 
     115             : class OGRPDSDataSource final : public OGRDataSource
     116             : {
     117             :     char *pszName;
     118             : 
     119             :     OGRLayer **papoLayers;
     120             :     int nLayers;
     121             : 
     122             :     NASAKeywordHandler oKeywords;
     123             : 
     124             :     CPLString osTempResult;
     125             :     const char *GetKeywordSub(const char *pszPath, int iSubscript,
     126             :                               const char *pszDefault);
     127             : 
     128             :     bool LoadTable(const char *pszFilename, int nRecordSize,
     129             :                    CPLString osTableID);
     130             : 
     131             :   public:
     132             :     OGRPDSDataSource();
     133             :     virtual ~OGRPDSDataSource();
     134             : 
     135             :     int Open(const char *pszFilename);
     136             : 
     137           0 :     virtual const char *GetName() override
     138             :     {
     139           0 :         return pszName;
     140             :     }
     141             : 
     142           3 :     virtual int GetLayerCount() override
     143             :     {
     144           3 :         return nLayers;
     145             :     }
     146             : 
     147             :     virtual OGRLayer *GetLayer(int) override;
     148             : 
     149             :     virtual int TestCapability(const char *) override;
     150             : 
     151             :     static void CleanString(CPLString &osInput);
     152             : };
     153             : 
     154             : #endif /* ndef OGR_PDS_H_INCLUDED */

Generated by: LCOV version 1.14