LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/ili - ogrili1driver.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 42 42 100.0 %
Date: 2024-04-29 17:29:47 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  Interlis 1 Translator
       4             :  * Purpose:  Implements OGRILI1Layer class.
       5             :  * Author:   Pirmin Kalberer, Sourcepole AG
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2004, Pirmin Kalberer, Sourcepole AG
       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 "cpl_conv.h"
      30             : #include "ogr_ili1.h"
      31             : #include "ogrsf_frmts.h"
      32             : 
      33             : /************************************************************************/
      34             : /*                                Open()                                */
      35             : /************************************************************************/
      36             : 
      37       24595 : static GDALDataset *OGRILI1DriverOpen(GDALOpenInfo *poOpenInfo)
      38             : 
      39             : {
      40       24595 :     if (poOpenInfo->eAccess == GA_Update ||
      41       23857 :         (!poOpenInfo->bStatOK &&
      42       20352 :          strchr(poOpenInfo->pszFilename, ',') == nullptr))
      43       21017 :         return nullptr;
      44             : 
      45        3578 :     if (poOpenInfo->pabyHeader != nullptr)
      46             :     {
      47        3049 :         if (strstr((const char *)poOpenInfo->pabyHeader, "SCNT") == nullptr)
      48             :         {
      49        3017 :             return nullptr;
      50             :         }
      51             :     }
      52         529 :     else if (poOpenInfo->bIsDirectory)
      53         453 :         return nullptr;
      54             : 
      55         108 :     OGRILI1DataSource *poDS = new OGRILI1DataSource();
      56             : 
      57         108 :     if (!poDS->Open(poOpenInfo->pszFilename, poOpenInfo->papszOpenOptions,
      58         156 :                     TRUE) ||
      59          48 :         poDS->GetLayerCount() == 0)
      60             :     {
      61          60 :         delete poDS;
      62          60 :         return nullptr;
      63             :     }
      64             : 
      65          48 :     return poDS;
      66             : }
      67             : 
      68             : /************************************************************************/
      69             : /*                               Create()                               */
      70             : /************************************************************************/
      71             : 
      72          22 : static GDALDataset *OGRILI1DriverCreate(const char *pszName, int /* nBands */,
      73             :                                         int /* nXSize */, int /* nYSize */,
      74             :                                         GDALDataType /* eDT */,
      75             :                                         char **papszOptions)
      76             : {
      77          22 :     OGRILI1DataSource *poDS = new OGRILI1DataSource();
      78             : 
      79          22 :     if (!poDS->Create(pszName, papszOptions))
      80             :     {
      81           1 :         delete poDS;
      82           1 :         return nullptr;
      83             :     }
      84             : 
      85          21 :     return poDS;
      86             : }
      87             : 
      88             : /************************************************************************/
      89             : /*                           RegisterOGRILI1()                           */
      90             : /************************************************************************/
      91             : 
      92        1512 : void RegisterOGRILI1()
      93             : {
      94        1512 :     if (GDALGetDriverByName("Interlis 1") != nullptr)
      95         295 :         return;
      96             : 
      97        1217 :     GDALDriver *poDriver = new GDALDriver();
      98             : 
      99        1217 :     poDriver->SetDescription("Interlis 1");
     100        1217 :     poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES");
     101        1217 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE_FIELD, "YES");
     102        1217 :     poDriver->SetMetadataItem(GDAL_DCAP_CURVE_GEOMETRIES, "YES");
     103        1217 :     poDriver->SetMetadataItem(GDAL_DCAP_Z_GEOMETRIES, "YES");
     104        1217 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "Interlis 1");
     105        1217 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/ili.html");
     106        1217 :     poDriver->SetMetadataItem(GDAL_DMD_EXTENSIONS, "itf ili");
     107        1217 :     poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE");
     108        1217 :     poDriver->SetMetadataItem(
     109             :         GDAL_DMD_OPENOPTIONLIST,
     110             :         "<OpenOptionList>"
     111             :         "  <Option name='MODEL' type='string' description='Filename of the "
     112             :         "model in IlisMeta format (.imd)'/>"
     113        1217 :         "</OpenOptionList>");
     114        1217 :     poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES");
     115             : 
     116        1217 :     poDriver->pfnOpen = OGRILI1DriverOpen;
     117        1217 :     poDriver->pfnCreate = OGRILI1DriverCreate;
     118             : 
     119        1217 :     GetGDALDriverManager()->RegisterDriver(poDriver);
     120             : }

Generated by: LCOV version 1.14