LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/mssqlspatial - ogrmssqlspatialdrivercore.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 40 40 100.0 %
Date: 2024-05-04 12:52:34 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  MSSQL Spatial driver
       4             :  * Purpose:  Definition of classes for OGR MSSQL Spatial driver.
       5             :  * Author:   Tamas Szekeres, szekerest at gmail.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2010, Tamas Szekeres
       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 "ogrsf_frmts.h"
      30             : #include "ogrmssqlspatialdrivercore.h"
      31             : 
      32             : /************************************************************************/
      33             : /*                   OGRMSSQLSPATIALDriverIdentify()                    */
      34             : /************************************************************************/
      35             : 
      36       43224 : int OGRMSSQLSPATIALDriverIdentify(GDALOpenInfo *poOpenInfo)
      37             : 
      38             : {
      39       43224 :     return STARTS_WITH_CI(poOpenInfo->pszFilename, "MSSQL:");
      40             : }
      41             : 
      42             : /************************************************************************/
      43             : /*                OGRMSSQLSPATIALDriverSetCommonMetadata()              */
      44             : /************************************************************************/
      45             : 
      46        1226 : void OGRMSSQLSPATIALDriverSetCommonMetadata(GDALDriver *poDriver)
      47             : {
      48        1226 :     poDriver->SetDescription(DRIVER_NAME);
      49             : 
      50        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES");
      51        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE_LAYER, "YES");
      52        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_DELETE_LAYER, "YES");
      53        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE_FIELD, "YES");
      54        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_CURVE_GEOMETRIES, "YES");
      55        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_MEASURED_GEOMETRIES, "YES");
      56        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_Z_GEOMETRIES, "YES");
      57        1226 :     poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS,
      58        1226 :                               "NATIVE OGRSQL SQLITE");
      59             : 
      60        1226 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME,
      61             :                               "Microsoft SQL Server Spatial Database"
      62             : #ifdef MSSQL_BCP_SUPPORTED
      63             :                               " (BCP)"
      64             : #endif
      65        1226 :     );
      66        1226 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC,
      67        1226 :                               "drivers/vector/mssqlspatial.html");
      68        1226 :     poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST,
      69        1226 :                               "<CreationOptionList/>");
      70             : 
      71        1226 :     poDriver->SetMetadataItem(
      72             :         GDAL_DS_LAYER_CREATIONOPTIONLIST,
      73             :         "<LayerCreationOptionList>"
      74             :         "  <Option name='GEOM_TYPE' type='string-select' description='Format "
      75             :         "of geometry columns' default='geometry'>"
      76             :         "    <Value>geometry</Value>"
      77             :         "    <Value>geography</Value>"
      78             :         "  </Option>"
      79             :         "  <Option name='OVERWRITE' type='boolean' description='Whether to "
      80             :         "overwrite an existing table with the layer name to be created' "
      81             :         "default='NO'/>"
      82             :         "  <Option name='LAUNDER' type='boolean' description='Whether layer "
      83             :         "and field names will be laundered' default='YES'/>"
      84             :         "  <Option name='PRECISION' type='boolean' description='Whether fields "
      85             :         "created should keep the width and precision' default='YES'/>"
      86             :         "  <Option name='DIM' type='integer' description='Set to 2 to force "
      87             :         "the geometries to be 2D, or 3 to be 2.5D'/>"
      88             :         "  <Option name='GEOMETRY_NAME' type='string' description='Name of "
      89             :         "geometry column.' default='ogr_geometry' "
      90             :         "deprecated_alias='GEOM_NAME'/>"
      91             :         "  <Option name='SCHEMA' type='string' description='Name of schema "
      92             :         "into which to create the new table' default='dbo'/>"
      93             :         "  <Option name='SRID' type='int' description='Forced SRID of the "
      94             :         "layer'/>"
      95             :         "  <Option name='SPATIAL_INDEX' type='boolean' description='Whether to "
      96             :         "create a spatial index' default='YES'/>"
      97             :         "  <Option name='UPLOAD_GEOM_FORMAT' type='string-select' "
      98             :         "description='Geometry format when creating or modifying features' "
      99             :         "default='wkb'>"
     100             :         "    <Value>wkb</Value>"
     101             :         "    <Value>wkt</Value>"
     102             :         "  </Option>"
     103             :         "  <Option name='FID' type='string' description='Name of the FID "
     104             :         "column to create' default='ogr_fid'/>"
     105             :         "  <Option name='FID64' type='boolean' description='Whether to create "
     106             :         "the FID column with bigint type to handle 64bit wide ids' "
     107             :         "default='NO'/>"
     108             :         "  <Option name='GEOMETRY_NULLABLE' type='boolean' "
     109             :         "description='Whether the values of the geometry column can be NULL' "
     110             :         "default='YES'/>"
     111             :         "  <Option name='EXTRACT_SCHEMA_FROM_LAYER_NAME' type='boolean' "
     112             :         "description='Whether a dot in a layer name should be considered as "
     113             :         "the separator for the schema and table name' default='YES'/>"
     114        1226 :         "</LayerCreationOptionList>");
     115             : 
     116        1226 :     poDriver->SetMetadataItem(GDAL_DMD_CONNECTION_PREFIX, "MSSQL:");
     117             : 
     118        1226 :     poDriver->SetMetadataItem(GDAL_DMD_CREATIONFIELDDATATYPES,
     119             :                               "Integer Integer64 Real String Date Time "
     120        1226 :                               "DateTime Binary");
     121        1226 :     poDriver->SetMetadataItem(GDAL_DMD_CREATION_FIELD_DEFN_FLAGS,
     122        1226 :                               "WidthPrecision Nullable Default");
     123             : 
     124        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_NOTNULL_FIELDS, "YES");
     125        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_DEFAULT_FIELDS, "YES");
     126        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_NOTNULL_GEOMFIELDS, "YES");
     127        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_MULTIPLE_VECTOR_LAYERS, "YES");
     128             : 
     129        1226 :     poDriver->pfnIdentify = OGRMSSQLSPATIALDriverIdentify;
     130        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES");
     131        1226 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE, "YES");
     132        1226 : }
     133             : 
     134             : /************************************************************************/
     135             : /*                 DeclareDeferredOGRMSSQLSpatialPlugin()               */
     136             : /************************************************************************/
     137             : 
     138             : #ifdef PLUGIN_FILENAME
     139        1520 : void DeclareDeferredOGRMSSQLSpatialPlugin()
     140             : {
     141        1520 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
     142             :     {
     143         301 :         return;
     144             :     }
     145        1219 :     auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME);
     146             : #ifdef PLUGIN_INSTALLATION_MESSAGE
     147             :     poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE,
     148             :                               PLUGIN_INSTALLATION_MESSAGE);
     149             : #endif
     150        1219 :     OGRMSSQLSPATIALDriverSetCommonMetadata(poDriver);
     151        1219 :     GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver);
     152             : }
     153             : #endif

Generated by: LCOV version 1.14