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-05-04 12:52:34 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             :  * Permission is hereby granted, free of charge, to any person obtaining a
      11             :  * copy of this software and associated documentation files (the "Software"),
      12             :  * to deal in the Software without restriction, including without limitation
      13             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      14             :  * and/or sell copies of the Software, and to permit persons to whom the
      15             :  * Software is furnished to do so, subject to the following conditions:
      16             :  *
      17             :  * The above copyright notice and this permission notice shall be included
      18             :  * in all copies or substantial portions of the Software.
      19             :  *
      20             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      21             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      22             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      23             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      24             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      25             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      26             :  * DEALINGS IN THE SOFTWARE.
      27             :  ****************************************************************************/
      28             : 
      29             : #include "sdts_al.h"
      30             : 
      31             : /************************************************************************/
      32             : /*                             SDTS_XREF()                              */
      33             : /************************************************************************/
      34             : 
      35          52 : SDTS_XREF::SDTS_XREF()
      36          52 :     : pszSystemName(CPLStrdup("")), pszDatum(CPLStrdup("")), nZone(0)
      37             : {
      38          52 : }
      39             : 
      40             : /************************************************************************/
      41             : /*                             ~SDTS_XREF()                             */
      42             : /************************************************************************/
      43             : 
      44         104 : SDTS_XREF::~SDTS_XREF()
      45             : {
      46          52 :     CPLFree(pszSystemName);
      47          52 :     CPLFree(pszDatum);
      48          52 : }
      49             : 
      50             : /************************************************************************/
      51             : /*                                Read()                                */
      52             : /*                                                                      */
      53             : /*      Read the named file to initialize this structure.               */
      54             : /************************************************************************/
      55             : 
      56           3 : int SDTS_XREF::Read(const char *pszFilename)
      57             : 
      58             : {
      59             :     /* -------------------------------------------------------------------- */
      60             :     /*      Open the file, and read the header.                             */
      61             :     /* -------------------------------------------------------------------- */
      62           6 :     DDFModule oXREFFile;
      63           3 :     if (!oXREFFile.Open(pszFilename))
      64           0 :         return FALSE;
      65             : 
      66             :     /* -------------------------------------------------------------------- */
      67             :     /*      Read the first record, and verify that this is an XREF record.  */
      68             :     /* -------------------------------------------------------------------- */
      69           3 :     DDFRecord *poRecord = oXREFFile.ReadRecord();
      70           3 :     if (poRecord == nullptr)
      71           0 :         return FALSE;
      72             : 
      73           3 :     if (poRecord->GetStringSubfield("XREF", 0, "MODN", 0) == nullptr)
      74           0 :         return FALSE;
      75             : 
      76             :     /* -------------------------------------------------------------------- */
      77             :     /*      Read fields of interest.                                        */
      78             :     /* -------------------------------------------------------------------- */
      79             : 
      80           3 :     CPLFree(pszSystemName);
      81           3 :     pszSystemName =
      82           3 :         CPLStrdup(poRecord->GetStringSubfield("XREF", 0, "RSNM", 0));
      83             : 
      84           3 :     CPLFree(pszDatum);
      85           3 :     pszDatum = CPLStrdup(poRecord->GetStringSubfield("XREF", 0, "HDAT", 0));
      86             : 
      87           3 :     nZone = poRecord->GetIntSubfield("XREF", 0, "ZONE", 0);
      88             : 
      89           3 :     return TRUE;
      90             : }

Generated by: LCOV version 1.14