LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/cad - ogrcaddrivercore.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 34 34 100.0 %
Date: 2025-01-18 12:42:00 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /*******************************************************************************
       2             :  *  Project: OGR CAD Driver
       3             :  *  Purpose: Implements driver based on libopencad
       4             :  *  Author: Alexandr Borzykh, mush3d at gmail.com
       5             :  *  Author: Dmitry Baryshnikov, polimax@mail.ru
       6             :  *  Language: C++
       7             :  *******************************************************************************
       8             :  *  The MIT License (MIT)
       9             :  *
      10             :  *  Copyright (c) 2016 Alexandr Borzykh
      11             :  *  Copyright (c) 2016, NextGIS
      12             :  *
      13             :  * SPDX-License-Identifier: MIT
      14             :  *******************************************************************************/
      15             : 
      16             : #include "ogrsf_frmts.h"
      17             : 
      18             : #include "ogrcaddrivercore.h"
      19             : 
      20             : /************************************************************************/
      21             : /*                    OGRCADDriverIdentify()                            */
      22             : /************************************************************************/
      23             : 
      24       53030 : static int OGRCADDriverIdentify(GDALOpenInfo *poOpenInfo)
      25             : 
      26             : {
      27             : #if !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
      28       53030 :     if (!poOpenInfo->IsExtensionEqualToCI("DWG"))
      29       53037 :         return FALSE;
      30             : #endif
      31          18 :     return poOpenInfo->nHeaderBytes >= 6 && poOpenInfo->pabyHeader[0] == 'A' &&
      32          18 :            poOpenInfo->pabyHeader[1] == 'C';
      33             : }
      34             : 
      35             : /************************************************************************/
      36             : /*                  OGRCADDriverSetCommonMetadata()                  */
      37             : /************************************************************************/
      38             : 
      39        1389 : void OGRCADDriverSetCommonMetadata(GDALDriver *poDriver)
      40             : {
      41        1389 :     poDriver->SetDescription(DRIVER_NAME);
      42        1389 :     poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES");
      43        1389 :     poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES");
      44        1389 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE_LAYER, "YES");
      45        1389 :     poDriver->SetMetadataItem(GDAL_DCAP_DELETE_LAYER, "YES");
      46        1389 :     poDriver->SetMetadataItem(GDAL_DMD_SUBDATASETS, "YES");
      47        1389 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "AutoCAD Driver");
      48        1389 :     poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "dwg");
      49        1389 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/cad.html");
      50        1389 :     poDriver->SetMetadataItem(GDAL_DCAP_MULTIPLE_VECTOR_LAYERS, "YES");
      51        1389 :     poDriver->SetMetadataItem(GDAL_DCAP_CURVE_GEOMETRIES, "YES");
      52        1389 :     poDriver->SetMetadataItem(GDAL_DCAP_MEASURED_GEOMETRIES, "YES");
      53        1389 :     poDriver->SetMetadataItem(GDAL_DCAP_Z_GEOMETRIES, "YES");
      54        1389 :     poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE");
      55             : 
      56        1389 :     poDriver->SetMetadataItem(
      57             :         GDAL_DMD_OPENOPTIONLIST,
      58             :         "<OpenOptionList>"
      59             :         "  <Option name='MODE' type='string' description='Open mode. "
      60             :         "READ_ALL - read all data (slow), READ_FAST - read main data "
      61             :         "(fast), READ_FASTEST - read less data' default='READ_FAST'/>"
      62             :         "  <Option name='ADD_UNSUPPORTED_GEOMETRIES_DATA' type='string' "
      63             :         "description='Add unsupported geometries data (color, attributes) "
      64             :         "to the layer (YES/NO). They will have no geometrical "
      65             :         "representation.' default='NO'/>"
      66        1389 :         "</OpenOptionList>");
      67             : 
      68        1389 :     poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES");
      69        1389 :     poDriver->SetMetadataItem(GDAL_DCAP_FEATURE_STYLES, "YES");
      70        1389 :     poDriver->SetMetadataItem(GDAL_DCAP_FEATURE_STYLES_READ, "YES");
      71             : 
      72        1389 :     poDriver->pfnIdentify = OGRCADDriverIdentify;
      73        1389 :     poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES");
      74        1389 : }
      75             : 
      76             : /************************************************************************/
      77             : /*                   DeclareDeferredOGRCADPlugin()                      */
      78             : /************************************************************************/
      79             : 
      80             : #ifdef PLUGIN_FILENAME
      81        1682 : void DeclareDeferredOGRCADPlugin()
      82             : {
      83        1682 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
      84             :     {
      85         301 :         return;
      86             :     }
      87        1381 :     auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME);
      88             : #ifdef PLUGIN_INSTALLATION_MESSAGE
      89             :     poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE,
      90             :                               PLUGIN_INSTALLATION_MESSAGE);
      91             : #endif
      92        1381 :     OGRCADDriverSetCommonMetadata(poDriver);
      93        1381 :     GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver);
      94             : }
      95             : #endif

Generated by: LCOV version 1.14