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

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  Carto Translator
       4             :  * Purpose:  Implements OGRCARTODriver.
       5             :  * Author:   Even Rouault, even dot rouault at spatialys.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2013, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "ogrsf_frmts.h"
      14             : 
      15             : #include "ogrcartodrivercore.h"
      16             : 
      17             : /************************************************************************/
      18             : /*                    OGRCartoDriverIdentify()                            */
      19             : /************************************************************************/
      20             : 
      21       45118 : int OGRCartoDriverIdentify(GDALOpenInfo *poOpenInfo)
      22             : 
      23             : {
      24       90166 :     return STARTS_WITH_CI(poOpenInfo->pszFilename, "CARTO:") ||
      25       90166 :            STARTS_WITH_CI(poOpenInfo->pszFilename, "CARTODB:");
      26             : }
      27             : 
      28             : /************************************************************************/
      29             : /*                  OGRCartoDriverSetCommonMetadata()                  */
      30             : /************************************************************************/
      31             : 
      32        1293 : void OGRCartoDriverSetCommonMetadata(GDALDriver *poDriver)
      33             : {
      34        1293 :     poDriver->SetDescription(DRIVER_NAME);
      35        1293 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "Carto");
      36        1293 :     poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES");
      37        1293 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE_LAYER, "YES");
      38        1293 :     poDriver->SetMetadataItem(GDAL_DCAP_DELETE_LAYER, "YES");
      39        1293 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE_FIELD, "YES");
      40        1293 :     poDriver->SetMetadataItem(GDAL_DCAP_DELETE_FIELD, "YES");
      41        1293 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/carto.html");
      42        1293 :     poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS,
      43        1293 :                               "NATIVE OGRSQL SQLITE");
      44             : 
      45        1293 :     poDriver->SetMetadataItem(GDAL_DMD_CONNECTION_PREFIX, "CARTO:");
      46             : 
      47        1293 :     poDriver->SetMetadataItem(
      48             :         GDAL_DMD_OPENOPTIONLIST,
      49             :         "<OpenOptionList>"
      50             :         "  <Option name='API_KEY' type='string' description='Account API key'/>"
      51             :         "  <Option name='ACCOUNT' type='string' description='Account name' "
      52             :         "required='true'/>"
      53             :         "  <Option name='BATCH_INSERT' type='boolean' description='Whether to "
      54             :         "group features to be inserted in a batch' default='YES'/>"
      55             :         "  <Option name='COPY_MODE' type='boolean' description='Whether to use "
      56             :         "the COPY API for faster uploads' default='YES'/>"
      57        1293 :         "</OpenOptionList>");
      58             : 
      59        1293 :     poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST,
      60        1293 :                               "<CreationOptionList/>");
      61             : 
      62        1293 :     poDriver->SetMetadataItem(
      63             :         GDAL_DS_LAYER_CREATIONOPTIONLIST,
      64             :         "<LayerCreationOptionList>"
      65             :         "  <Option name='OVERWRITE' type='boolean' description='Whether to "
      66             :         "overwrite an existing table with the layer name to be created' "
      67             :         "default='NO'/>"
      68             :         "  <Option name='LAUNDER' type='boolean' description='Whether layer "
      69             :         "and field names will be laundered' default='YES'/>"
      70             :         "  <Option name='GEOMETRY_NULLABLE' type='boolean' "
      71             :         "description='Whether the values of the geometry column can be NULL' "
      72             :         "default='YES'/>"
      73             :         "  <Option name='CARTODBFY' alias='CARTODBIFY' type='boolean' "
      74             :         "description='Whether the created layer should be "
      75             :         "\"Cartodbifi&apos;ed\" (i.e. registered in dashboard)' default='YES'/>"
      76        1293 :         "</LayerCreationOptionList>");
      77             : 
      78        1293 :     poDriver->SetMetadataItem(
      79             :         GDAL_DMD_CREATIONFIELDDATATYPES,
      80        1293 :         "Integer Integer64 Real String Date DateTime Time");
      81        1293 :     poDriver->SetMetadataItem(GDAL_DCAP_NOTNULL_FIELDS, "YES");
      82        1293 :     poDriver->SetMetadataItem(GDAL_DCAP_DEFAULT_FIELDS, "YES");
      83        1293 :     poDriver->SetMetadataItem(GDAL_DCAP_NOTNULL_GEOMFIELDS, "YES");
      84             : 
      85        1293 :     poDriver->pfnIdentify = OGRCartoDriverIdentify;
      86        1293 :     poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES");
      87        1293 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE, "YES");
      88        1293 : }
      89             : 
      90             : /************************************************************************/
      91             : /*                   DeclareDeferredOGRCartoPlugin()                      */
      92             : /************************************************************************/
      93             : 
      94             : #ifdef PLUGIN_FILENAME
      95             : void DeclareDeferredOGRCartoPlugin()
      96             : {
      97             :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
      98             :     {
      99             :         return;
     100             :     }
     101             :     auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME);
     102             : #ifdef PLUGIN_INSTALLATION_MESSAGE
     103             :     poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE,
     104             :                               PLUGIN_INSTALLATION_MESSAGE);
     105             : #endif
     106             :     OGRCartoDriverSetCommonMetadata(poDriver);
     107             :     GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver);
     108             : }
     109             : #endif

Generated by: LCOV version 1.14