Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: Elasticsearch Translator 4 : * Purpose: 5 : * Author: 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2011, Adam Estrada 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #include "ogr_elastic.h" 14 : #include "cpl_conv.h" 15 : #include "ogrelasticdrivercore.h" 16 : 17 : /************************************************************************/ 18 : /* OGRElasticsearchDriverOpen() */ 19 : /************************************************************************/ 20 : 21 30 : static GDALDataset *OGRElasticsearchDriverOpen(GDALOpenInfo *poOpenInfo) 22 : 23 : { 24 30 : if (!OGRElasticsearchDriverIdentify(poOpenInfo)) 25 0 : return nullptr; 26 : 27 30 : OGRElasticDataSource *poDS = new OGRElasticDataSource(); 28 30 : if (!poDS->Open(poOpenInfo)) 29 : { 30 6 : delete poDS; 31 6 : poDS = nullptr; 32 : } 33 : 34 30 : return poDS; 35 : } 36 : 37 : /************************************************************************/ 38 : /* OGRElasticsearchDriverCreate() */ 39 : /************************************************************************/ 40 10 : static GDALDataset *OGRElasticsearchDriverCreate(const char *pszName, 41 : CPL_UNUSED int nXSize, 42 : CPL_UNUSED int nYSize, 43 : CPL_UNUSED int nBands, 44 : CPL_UNUSED GDALDataType eDT, 45 : CSLConstList papszOptions) 46 : { 47 10 : OGRElasticDataSource *poDS = new OGRElasticDataSource(); 48 : 49 10 : if (!poDS->Create(pszName, papszOptions)) 50 : { 51 2 : delete poDS; 52 2 : poDS = nullptr; 53 : } 54 : 55 10 : return poDS; 56 : } 57 : 58 : /************************************************************************/ 59 : /* RegisterOGRElastic() */ 60 : /************************************************************************/ 61 : 62 2063 : void RegisterOGRElastic() 63 : { 64 2063 : if (!GDAL_CHECK_VERSION("OGR/Elastic Search driver")) 65 0 : return; 66 : 67 2063 : if (GDALGetDriverByName(DRIVER_NAME) != nullptr) 68 283 : return; 69 : 70 1780 : GDALDriver *poDriver = new GDALDriver(); 71 1780 : OGRElasticsearchDriverSetCommonMetadata(poDriver); 72 1780 : poDriver->pfnOpen = OGRElasticsearchDriverOpen; 73 1780 : poDriver->pfnCreate = OGRElasticsearchDriverCreate; 74 : 75 1780 : GetGDALDriverManager()->RegisterDriver(poDriver); 76 : }