LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/plscenes - ogrplscenesdriver.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 17 22 77.3 %
Date: 2024-11-21 22:18:42 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  PlanetLabs scene driver
       4             :  * Purpose:  PlanetLabs scene driver
       5             :  * Author:   Even Rouault, even dot rouault at spatialys.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2015-2016, Planet Labs
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "ogr_plscenes.h"
      14             : #include "ogrplscenesdrivercore.h"
      15             : 
      16             : /************************************************************************/
      17             : /*                            OGRPLScenesOpen()                         */
      18             : /************************************************************************/
      19             : 
      20          28 : static GDALDataset *OGRPLScenesOpen(GDALOpenInfo *poOpenInfo)
      21             : {
      22          56 :     if (!OGRPLSCENESDriverIdentify(poOpenInfo) ||
      23          28 :         poOpenInfo->eAccess == GA_Update)
      24           0 :         return nullptr;
      25             : 
      26          56 :     char **papszOptions = CSLTokenizeStringComplex(
      27          28 :         poOpenInfo->pszFilename + strlen("PLScenes:"), ",", TRUE, FALSE);
      28             :     CPLString osVersion = CSLFetchNameValueDef(
      29             :         papszOptions, "version",
      30          56 :         CSLFetchNameValueDef(poOpenInfo->papszOpenOptions, "VERSION", ""));
      31          28 :     CSLDestroy(papszOptions);
      32             : 
      33          28 :     if (EQUAL(osVersion, "v0") || EQUAL(osVersion, "v1"))
      34             :     {
      35           0 :         CPLError(CE_Failure, CPLE_AppDefined,
      36             :                  "This API version has been removed or deprecated. "
      37             :                  "Please use DATA_V1 API instead");
      38           0 :         return nullptr;
      39             :     }
      40          28 :     else if (EQUAL(osVersion, "data_v1") || EQUAL(osVersion, ""))
      41             :     {
      42          28 :         return OGRPLScenesDataV1Dataset::Open(poOpenInfo);
      43             :     }
      44             :     else
      45             :     {
      46           0 :         CPLError(CE_Failure, CPLE_AppDefined, "Unhandled API version: %s",
      47             :                  osVersion.c_str());
      48           0 :         return nullptr;
      49             :     }
      50             : }
      51             : 
      52             : /************************************************************************/
      53             : /*                        RegisterOGRPLSCENES()                         */
      54             : /************************************************************************/
      55             : 
      56        1595 : void RegisterOGRPLSCENES()
      57             : 
      58             : {
      59        1595 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
      60         302 :         return;
      61             : 
      62        1293 :     GDALDriver *poDriver = new GDALDriver();
      63        1293 :     OGRPLSCENESDriverSetCommonMetadata(poDriver);
      64             : 
      65        1293 :     poDriver->pfnOpen = OGRPLScenesOpen;
      66             : 
      67        1293 :     GetGDALDriverManager()->RegisterDriver(poDriver);
      68             : }

Generated by: LCOV version 1.14