Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: AmigoCloud Translator 4 : * Purpose: Implements OGRAMIGOCLOUDDriver. 5 : * Author: Victor Chernetsky, <victor at amigocloud dot com> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2015, Victor Chernetsky, <victor at amigocloud dot com> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #include "ogr_amigocloud.h" 14 : 15 : extern "C" void RegisterOGRAmigoCloud(); 16 : 17 : /************************************************************************/ 18 : /* OGRAmigoCloudDriverIdentify() */ 19 : /************************************************************************/ 20 : 21 45060 : static int OGRAmigoCloudDriverIdentify(GDALOpenInfo *poOpenInfo) 22 : { 23 45060 : return EQUALN(poOpenInfo->pszFilename, 24 : "AMIGOCLOUD:", strlen("AMIGOCLOUD:")); 25 : } 26 : 27 : /************************************************************************/ 28 : /* OGRAmigoCloudDriverOpen() */ 29 : /************************************************************************/ 30 : 31 0 : static GDALDataset *OGRAmigoCloudDriverOpen(GDALOpenInfo *poOpenInfo) 32 : 33 : { 34 0 : if (!OGRAmigoCloudDriverIdentify(poOpenInfo)) 35 0 : return nullptr; 36 : 37 0 : OGRAmigoCloudDataSource *poDS = new OGRAmigoCloudDataSource(); 38 : 39 0 : if (!poDS->Open(poOpenInfo->pszFilename, poOpenInfo->papszOpenOptions, 40 0 : poOpenInfo->eAccess == GA_Update)) 41 : { 42 0 : delete poDS; 43 0 : poDS = nullptr; 44 : } 45 : 46 0 : return poDS; 47 : } 48 : 49 : /************************************************************************/ 50 : /* OGRAmigoCloudDriverCreate() */ 51 : /************************************************************************/ 52 : 53 0 : static GDALDataset *OGRAmigoCloudDriverCreate(const char *pszName, 54 : CPL_UNUSED int nBands, 55 : CPL_UNUSED int nXSize, 56 : CPL_UNUSED int nYSize, 57 : CPL_UNUSED GDALDataType eDT, 58 : CPL_UNUSED char **papszOptions) 59 : 60 : { 61 0 : OGRAmigoCloudDataSource *poDS = new OGRAmigoCloudDataSource(); 62 : 63 0 : if (!poDS->Open(pszName, nullptr, TRUE)) 64 : { 65 0 : delete poDS; 66 0 : return nullptr; 67 : } 68 : 69 0 : return poDS; 70 : } 71 : 72 : /************************************************************************/ 73 : /* RegisterOGRAMIGOCLOUD() */ 74 : /************************************************************************/ 75 : 76 1595 : void RegisterOGRAmigoCloud() 77 : { 78 1595 : if (GDALGetDriverByName("AmigoCloud") != nullptr) 79 302 : return; 80 : 81 1293 : GDALDriver *poDriver = new GDALDriver(); 82 : 83 1293 : poDriver->SetDescription("AmigoCloud"); 84 1293 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "AmigoCloud"); 85 1293 : poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); 86 1293 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE_LAYER, "YES"); 87 1293 : poDriver->SetMetadataItem(GDAL_DCAP_DELETE_LAYER, "YES"); 88 1293 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, 89 1293 : "drivers/vector/amigocloud.html"); 90 1293 : poDriver->SetMetadataItem(GDAL_DMD_CONNECTION_PREFIX, "AMIGOCLOUD:"); 91 : 92 1293 : poDriver->SetMetadataItem( 93 : GDAL_DMD_OPENOPTIONLIST, 94 : "<OpenOptionList>" 95 : " <Option name='AMIGOCLOUD_API_KEY' type='string' " 96 : "description='AmigoCLoud API token'/>" 97 : " <Option name='OVERWRITE' type='boolean' description='Whether to " 98 : "overwrite an existing table without deleting it' default='NO'/>" 99 1293 : "</OpenOptionList>"); 100 : 101 1293 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST, 102 1293 : "<CreationOptionList/>"); 103 : 104 1293 : poDriver->SetMetadataItem( 105 : GDAL_DS_LAYER_CREATIONOPTIONLIST, 106 : "<LayerCreationOptionList>" 107 : " <Option name='GEOMETRY_NULLABLE' type='boolean' " 108 : "description='Whether the values of the geometry column can be NULL' " 109 : "default='YES'/>" 110 1293 : "</LayerCreationOptionList>"); 111 : 112 1293 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONFIELDDATATYPES, 113 1293 : "String Integer Integer64 Real"); 114 1293 : poDriver->SetMetadataItem(GDAL_DCAP_NOTNULL_FIELDS, "YES"); 115 1293 : poDriver->SetMetadataItem(GDAL_DCAP_DEFAULT_FIELDS, "YES"); 116 1293 : poDriver->SetMetadataItem(GDAL_DCAP_NOTNULL_GEOMFIELDS, "YES"); 117 1293 : poDriver->SetMetadataItem(GDAL_DCAP_Z_GEOMETRIES, "YES"); 118 1293 : poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, 119 1293 : "NATIVE OGRSQL SQLITE"); 120 : 121 1293 : poDriver->pfnOpen = OGRAmigoCloudDriverOpen; 122 1293 : poDriver->pfnIdentify = OGRAmigoCloudDriverIdentify; 123 1293 : poDriver->pfnCreate = OGRAmigoCloudDriverCreate; 124 : 125 1293 : GetGDALDriverManager()->RegisterDriver(poDriver); 126 : }