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 24 0.0 %
Date: 2024-11-21 22:18:42 Functions: 0 2 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           0 : OGRFeature *TigerPoint::GetFeature(int nRecordId, int nX0, int nX1, int nY0,
      31             :                                    int nY1)
      32             : {
      33             :     char achRecord[OGR_TIGER_RECBUF_LEN];
      34             : 
      35           0 :     if (nRecordId < 0 || nRecordId >= nFeatures)
      36             :     {
      37           0 :         CPLError(CE_Failure, CPLE_FileIO,
      38             :                  "Request for out-of-range feature %d of %sP", nRecordId,
      39             :                  pszModule);
      40           0 :         return nullptr;
      41             :     }
      42             : 
      43             :     /* -------------------------------------------------------------------- */
      44             :     /*      Read the raw record data from the file.                         */
      45             :     /* -------------------------------------------------------------------- */
      46             : 
      47           0 :     if (fpPrimary == nullptr)
      48           0 :         return nullptr;
      49             : 
      50             :     {
      51           0 :         const auto nOffset = static_cast<uint64_t>(nRecordId) * nRecordLength;
      52           0 :         if (VSIFSeekL(fpPrimary, nOffset, SEEK_SET) != 0)
      53             :         {
      54           0 :             CPLError(CE_Failure, CPLE_FileIO,
      55             :                      "Failed to seek to %" PRIu64 " of %sP", nOffset,
      56             :                      pszModule);
      57           0 :             return nullptr;
      58             :         }
      59             :     }
      60             : 
      61             :     // Overflow cannot happen since psRTInfo->nRecordLength is unsigned
      62             :     // char and sizeof(achRecord) == OGR_TIGER_RECBUF_LEN > 255
      63           0 :     if (VSIFReadL(achRecord, psRTInfo->nRecordLength, 1, fpPrimary) != 1)
      64             :     {
      65           0 :         CPLError(CE_Failure, CPLE_FileIO, "Failed to read record %d of %sP",
      66             :                  nRecordId, pszModule);
      67           0 :         return nullptr;
      68             :     }
      69             : 
      70             :     /* -------------------------------------------------------------------- */
      71             :     /*      Set fields.                                                     */
      72             :     /* -------------------------------------------------------------------- */
      73             : 
      74           0 :     OGRFeature *poFeature = new OGRFeature(poFeatureDefn);
      75             : 
      76           0 :     SetFields(psRTInfo, poFeature, achRecord);
      77             : 
      78             :     /* -------------------------------------------------------------------- */
      79             :     /*      Set geometry                                                    */
      80             :     /* -------------------------------------------------------------------- */
      81             : 
      82           0 :     const double dfX = atoi(GetField(achRecord, nX0, nX1)) / 1000000.0;
      83           0 :     const double dfY = atoi(GetField(achRecord, nY0, nY1)) / 1000000.0;
      84             : 
      85           0 :     if (dfX != 0.0 || dfY != 0.0)
      86             :     {
      87           0 :         poFeature->SetGeometryDirectly(new OGRPoint(dfX, dfY));
      88             :     }
      89             : 
      90           0 :     return poFeature;
      91             : }

Generated by: LCOV version 1.14