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

Generated by: LCOV version 1.14