LCOV - code coverage report
Current view: top level - frmts/sdts - sdtsxref.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 20 23 87.0 %
Date: 2024-11-21 22:18:42 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  SDTS Translator
       4             :  * Purpose:  Implementation of SDTS_XREF class for reading XREF module.
       5             :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 1999, Frank Warmerdam
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "sdts_al.h"
      14             : 
      15             : /************************************************************************/
      16             : /*                             SDTS_XREF()                              */
      17             : /************************************************************************/
      18             : 
      19          52 : SDTS_XREF::SDTS_XREF()
      20          52 :     : pszSystemName(CPLStrdup("")), pszDatum(CPLStrdup("")), nZone(0)
      21             : {
      22          52 : }
      23             : 
      24             : /************************************************************************/
      25             : /*                             ~SDTS_XREF()                             */
      26             : /************************************************************************/
      27             : 
      28         104 : SDTS_XREF::~SDTS_XREF()
      29             : {
      30          52 :     CPLFree(pszSystemName);
      31          52 :     CPLFree(pszDatum);
      32          52 : }
      33             : 
      34             : /************************************************************************/
      35             : /*                                Read()                                */
      36             : /*                                                                      */
      37             : /*      Read the named file to initialize this structure.               */
      38             : /************************************************************************/
      39             : 
      40           3 : int SDTS_XREF::Read(const char *pszFilename)
      41             : 
      42             : {
      43             :     /* -------------------------------------------------------------------- */
      44             :     /*      Open the file, and read the header.                             */
      45             :     /* -------------------------------------------------------------------- */
      46           6 :     DDFModule oXREFFile;
      47           3 :     if (!oXREFFile.Open(pszFilename))
      48           0 :         return FALSE;
      49             : 
      50             :     /* -------------------------------------------------------------------- */
      51             :     /*      Read the first record, and verify that this is an XREF record.  */
      52             :     /* -------------------------------------------------------------------- */
      53           3 :     DDFRecord *poRecord = oXREFFile.ReadRecord();
      54           3 :     if (poRecord == nullptr)
      55           0 :         return FALSE;
      56             : 
      57           3 :     if (poRecord->GetStringSubfield("XREF", 0, "MODN", 0) == nullptr)
      58           0 :         return FALSE;
      59             : 
      60             :     /* -------------------------------------------------------------------- */
      61             :     /*      Read fields of interest.                                        */
      62             :     /* -------------------------------------------------------------------- */
      63             : 
      64           3 :     CPLFree(pszSystemName);
      65           3 :     pszSystemName =
      66           3 :         CPLStrdup(poRecord->GetStringSubfield("XREF", 0, "RSNM", 0));
      67             : 
      68           3 :     CPLFree(pszDatum);
      69           3 :     pszDatum = CPLStrdup(poRecord->GetStringSubfield("XREF", 0, "HDAT", 0));
      70             : 
      71           3 :     nZone = poRecord->GetIntSubfield("XREF", 0, "ZONE", 0);
      72             : 
      73           3 :     return TRUE;
      74             : }

Generated by: LCOV version 1.14