LCOV - code coverage report
Current view: top level - gnm - gnmnetwork.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 21 31 67.7 %
Date: 2024-05-03 15:49:35 Functions: 9 13 69.2 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL/OGR Geography Network support (Geographic Network Model)
       4             :  * Purpose:  GNM network class.
       5             :  * Authors:  Mikhail Gusev (gusevmihs at gmail dot com)
       6             :  *           Dmitry Baryshnikov, polimax@mail.ru
       7             :  *
       8             :  ******************************************************************************
       9             :  * Copyright (c) 2014, Mikhail Gusev
      10             :  * Copyright (c) 2014-2015, NextGIS <info@nextgis.com>
      11             :  *
      12             :  * Permission is hereby granted, free of charge, to any person obtaining a
      13             :  * copy of this software and associated documentation files (the "Software"),
      14             :  * to deal in the Software without restriction, including without limitation
      15             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      16             :  * and/or sell copies of the Software, and to permit persons to whom the
      17             :  * Software is furnished to do so, subject to the following conditions:
      18             :  *
      19             :  * The above copyright notice and this permission notice shall be included
      20             :  * in all copies or substantial portions of the Software.
      21             :  *
      22             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      23             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      24             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      25             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      26             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      27             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      28             :  * DEALINGS IN THE SOFTWARE.
      29             :  ****************************************************************************/
      30             : 
      31             : #include "gnm_api.h"
      32             : #include "ogrsf_frmts.h"
      33             : 
      34          16 : GNMNetwork::GNMNetwork() : GDALDataset()
      35             : {
      36          16 : }
      37             : 
      38          16 : GNMNetwork::~GNMNetwork()
      39             : {
      40          16 : }
      41             : 
      42           3 : const char *GNMNetwork::GetName() const
      43             : {
      44           3 :     return m_soName;
      45             : }
      46             : 
      47          10 : const OGRSpatialReference *GNMNetwork::GetSpatialRef() const
      48             : {
      49          10 :     return m_oSRS.IsEmpty() ? nullptr : &m_oSRS;
      50             : }
      51             : 
      52           0 : char **GNMNetwork::GetFileList()
      53             : {
      54           0 :     return nullptr;
      55             : }
      56             : 
      57             : //--- C API --------------------------------------------------------------------
      58             : 
      59           2 : const char *CPL_STDCALL GNMGetName(GNMNetworkH hNet)
      60             : {
      61           2 :     VALIDATE_POINTER1(hNet, "GNMGetVersion", nullptr);
      62             : 
      63           2 :     return ((GNMNetwork *)hNet)->GetName();
      64             : }
      65             : 
      66           2 : int CPL_STDCALL GNMGetVersion(GNMNetworkH hNet)
      67             : {
      68           2 :     VALIDATE_POINTER1(hNet, "GNMGetVersion", 0);
      69             : 
      70           2 :     return ((GNMNetwork *)hNet)->GetVersion();
      71             : }
      72             : 
      73           0 : CPLErr CPL_STDCALL GNMDisconnectAll(GNMNetworkH hNet)
      74             : {
      75           0 :     VALIDATE_POINTER1(hNet, "GNMDisconnectAll", CE_Failure);
      76             : 
      77           0 :     return ((GNMNetwork *)hNet)->DisconnectAll();
      78             : }
      79             : 
      80           0 : OGRFeatureH CPL_STDCALL GNMGetFeatureByGlobalFID(GNMNetworkH hNet,
      81             :                                                  GNMGFID nGFID)
      82             : {
      83           0 :     VALIDATE_POINTER1(hNet, "GNMGetFeatureByGlobalFID", nullptr);
      84             : 
      85           0 :     return (OGRFeatureH)((GNMNetwork *)hNet)->GetFeatureByGlobalFID(nGFID);
      86             : }
      87             : 
      88           3 : OGRLayerH CPL_STDCALL GNMGetPath(GNMNetworkH hNet, GNMGFID nStartFID,
      89             :                                  GNMGFID nEndFID,
      90             :                                  GNMGraphAlgorithmType eAlgorithm,
      91             :                                  char **papszOptions)
      92             : {
      93           3 :     VALIDATE_POINTER1(hNet, "GNMGetPath", nullptr);
      94             : 
      95             :     return (OGRLayerH)((GNMNetwork *)hNet)
      96           3 :         ->GetPath(nStartFID, nEndFID, eAlgorithm, papszOptions);
      97             : }
      98             : 
      99           5 : GNMNetworkH CPL_STDCALL GNMCastToNetwork(GDALMajorObjectH hBase)
     100             : {
     101           0 :     return reinterpret_cast<GNMNetworkH>(
     102           5 :         dynamic_cast<GNMNetwork *>(reinterpret_cast<GDALMajorObject *>(hBase)));
     103             : }
     104             : 
     105           1 : GNMGenericNetworkH CPL_STDCALL GNMCastToGenericNetwork(GDALMajorObjectH hBase)
     106             : {
     107           0 :     return reinterpret_cast<GNMGenericNetworkH>(
     108           1 :         dynamic_cast<GNMNetwork *>(reinterpret_cast<GDALMajorObject *>(hBase)));
     109             : }

Generated by: LCOV version 1.14