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