LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/tiger - tigerpoint.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 0 26 0.0 %
Date: 2026-03-26 23:25:44 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  TIGER/Line Translator
       4             :  * Purpose:  Implements TigerPoint class.
       5             :  * Author:   Mark Phillips, mbp@geomtech.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2002, Mark Phillips
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "ogr_tiger.h"
      14             : #include "cpl_conv.h"
      15             : 
      16             : #include <cinttypes>
      17             : 
      18             : /************************************************************************/
      19             : /*                             TigerPoint()                             */
      20             : /************************************************************************/
      21           0 : TigerPoint::TigerPoint(const TigerRecordInfo *psRTInfoIn,
      22           0 :                        const char *m_pszFileCodeIn)
      23           0 :     : TigerFileBase(psRTInfoIn, m_pszFileCodeIn)
      24             : {
      25           0 : }
      26             : 
      27             : /************************************************************************/
      28             : /*                             GetFeature()                             */
      29             : /************************************************************************/
      30             : 
      31           0 : OGRFeature *TigerPoint::GetFeature(int nFID)
      32             : {
      33           0 :     return TigerFileBase::GetFeature(nFID);
      34             : } /* to avoid -Woverloaded-virtual warnings */
      35             : 
      36             : /************************************************************************/
      37             : /*                             GetFeature()                             */
      38             : /************************************************************************/
      39           0 : OGRFeature *TigerPoint::GetFeature(int nRecordId, int nX0, int nX1, int nY0,
      40             :                                    int nY1)
      41             : {
      42             :     char achRecord[OGR_TIGER_RECBUF_LEN];
      43             : 
      44           0 :     if (nRecordId < 0 || nRecordId >= nFeatures)
      45             :     {
      46           0 :         CPLError(CE_Failure, CPLE_FileIO,
      47             :                  "Request for out-of-range feature %d of %sP", nRecordId,
      48             :                  pszModule);
      49           0 :         return nullptr;
      50             :     }
      51             : 
      52             :     /* -------------------------------------------------------------------- */
      53             :     /*      Read the raw record data from the file.                         */
      54             :     /* -------------------------------------------------------------------- */
      55             : 
      56           0 :     if (fpPrimary == nullptr)
      57           0 :         return nullptr;
      58             : 
      59             :     {
      60           0 :         const auto nOffset = static_cast<uint64_t>(nRecordId) * nRecordLength;
      61           0 :         if (VSIFSeekL(fpPrimary, nOffset, SEEK_SET) != 0)
      62             :         {
      63           0 :             CPLError(CE_Failure, CPLE_FileIO,
      64             :                      "Failed to seek to %" PRIu64 " of %sP", nOffset,
      65             :                      pszModule);
      66           0 :             return nullptr;
      67             :         }
      68             :     }
      69             : 
      70             :     // Overflow cannot happen since psRTInfo->nRecordLength is unsigned
      71             :     // char and sizeof(achRecord) == OGR_TIGER_RECBUF_LEN > 255
      72           0 :     if (VSIFReadL(achRecord, psRTInfo->nRecordLength, 1, fpPrimary) != 1)
      73             :     {
      74           0 :         CPLError(CE_Failure, CPLE_FileIO, "Failed to read record %d of %sP",
      75             :                  nRecordId, pszModule);
      76           0 :         return nullptr;
      77             :     }
      78             : 
      79             :     /* -------------------------------------------------------------------- */
      80             :     /*      Set fields.                                                     */
      81             :     /* -------------------------------------------------------------------- */
      82             : 
      83           0 :     OGRFeature *poFeature = new OGRFeature(poFeatureDefn);
      84             : 
      85           0 :     SetFields(psRTInfo, poFeature, achRecord);
      86             : 
      87             :     /* -------------------------------------------------------------------- */
      88             :     /*      Set geometry                                                    */
      89             :     /* -------------------------------------------------------------------- */
      90             : 
      91           0 :     const double dfX = atoi(GetField(achRecord, nX0, nX1)) / 1000000.0;
      92           0 :     const double dfY = atoi(GetField(achRecord, nY0, nY1)) / 1000000.0;
      93             : 
      94           0 :     if (dfX != 0.0 || dfY != 0.0)
      95             :     {
      96           0 :         poFeature->SetGeometryDirectly(new OGRPoint(dfX, dfY));
      97             :     }
      98             : 
      99           0 :     return poFeature;
     100             : }

Generated by: LCOV version 1.14