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 : * 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 : 31 : #include "ogrcartodrivercore.h" 32 : 33 : /************************************************************************/ 34 : /* OGRCartoDriverIdentify() */ 35 : /************************************************************************/ 36 : 37 42089 : int OGRCartoDriverIdentify(GDALOpenInfo *poOpenInfo) 38 : 39 : { 40 84108 : return STARTS_WITH_CI(poOpenInfo->pszFilename, "CARTO:") || 41 84108 : STARTS_WITH_CI(poOpenInfo->pszFilename, "CARTODB:"); 42 : } 43 : 44 : /************************************************************************/ 45 : /* OGRCartoDriverSetCommonMetadata() */ 46 : /************************************************************************/ 47 : 48 1216 : void OGRCartoDriverSetCommonMetadata(GDALDriver *poDriver) 49 : { 50 1216 : poDriver->SetDescription(DRIVER_NAME); 51 1216 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "Carto"); 52 1216 : poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); 53 1216 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE_LAYER, "YES"); 54 1216 : poDriver->SetMetadataItem(GDAL_DCAP_DELETE_LAYER, "YES"); 55 1216 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE_FIELD, "YES"); 56 1216 : poDriver->SetMetadataItem(GDAL_DCAP_DELETE_FIELD, "YES"); 57 1216 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/carto.html"); 58 1216 : poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, 59 1216 : "NATIVE OGRSQL SQLITE"); 60 : 61 1216 : poDriver->SetMetadataItem(GDAL_DMD_CONNECTION_PREFIX, "CARTO:"); 62 : 63 1216 : poDriver->SetMetadataItem( 64 : GDAL_DMD_OPENOPTIONLIST, 65 : "<OpenOptionList>" 66 : " <Option name='API_KEY' type='string' description='Account API key'/>" 67 : " <Option name='ACCOUNT' type='string' description='Account name' " 68 : "required='true'/>" 69 : " <Option name='BATCH_INSERT' type='boolean' description='Whether to " 70 : "group features to be inserted in a batch' default='YES'/>" 71 : " <Option name='COPY_MODE' type='boolean' description='Whether to use " 72 : "the COPY API for faster uploads' default='YES'/>" 73 1216 : "</OpenOptionList>"); 74 : 75 1216 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST, 76 1216 : "<CreationOptionList/>"); 77 : 78 1216 : poDriver->SetMetadataItem( 79 : GDAL_DS_LAYER_CREATIONOPTIONLIST, 80 : "<LayerCreationOptionList>" 81 : " <Option name='OVERWRITE' type='boolean' description='Whether to " 82 : "overwrite an existing table with the layer name to be created' " 83 : "default='NO'/>" 84 : " <Option name='LAUNDER' type='boolean' description='Whether layer " 85 : "and field names will be laundered' default='YES'/>" 86 : " <Option name='GEOMETRY_NULLABLE' type='boolean' " 87 : "description='Whether the values of the geometry column can be NULL' " 88 : "default='YES'/>" 89 : " <Option name='CARTODBFY' alias='CARTODBIFY' type='boolean' " 90 : "description='Whether the created layer should be " 91 : "\"Cartodbifi'ed\" (i.e. registered in dashboard)' default='YES'/>" 92 1216 : "</LayerCreationOptionList>"); 93 : 94 1216 : poDriver->SetMetadataItem( 95 : GDAL_DMD_CREATIONFIELDDATATYPES, 96 1216 : "Integer Integer64 Real String Date DateTime Time"); 97 1216 : poDriver->SetMetadataItem(GDAL_DCAP_NOTNULL_FIELDS, "YES"); 98 1216 : poDriver->SetMetadataItem(GDAL_DCAP_DEFAULT_FIELDS, "YES"); 99 1216 : poDriver->SetMetadataItem(GDAL_DCAP_NOTNULL_GEOMFIELDS, "YES"); 100 : 101 1216 : poDriver->pfnIdentify = OGRCartoDriverIdentify; 102 1216 : poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES"); 103 1216 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE, "YES"); 104 1216 : } 105 : 106 : /************************************************************************/ 107 : /* DeclareDeferredOGRCartoPlugin() */ 108 : /************************************************************************/ 109 : 110 : #ifdef PLUGIN_FILENAME 111 : void DeclareDeferredOGRCartoPlugin() 112 : { 113 : if (GDALGetDriverByName(DRIVER_NAME) != nullptr) 114 : { 115 : return; 116 : } 117 : auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME); 118 : #ifdef PLUGIN_INSTALLATION_MESSAGE 119 : poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE, 120 : PLUGIN_INSTALLATION_MESSAGE); 121 : #endif 122 : OGRCartoDriverSetCommonMetadata(poDriver); 123 : GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver); 124 : } 125 : #endif