Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: OpenGIS Simple Features Reference Implementation 4 : * Purpose: ESRIJSON driver 5 : * Author: Even Rouault, <even.rouault at spatialys.com> 6 : * 7 : ****************************************************************************** 8 : * Copyright (c) 2017, Even Rouault, <even.rouault at spatialys.com> 9 : * 10 : * SPDX-License-Identifier: MIT 11 : ****************************************************************************/ 12 : 13 : #include "cpl_port.h" 14 : #include "ogr_geojson.h" 15 : 16 : #include <stdlib.h> 17 : #include <string.h> 18 : 19 : #include "cpl_conv.h" 20 : #include "cpl_error.h" 21 : #include "gdal.h" 22 : #include "gdal_priv.h" 23 : #include "ogrgeojsonutils.h" 24 : #include "ogrsf_frmts.h" 25 : 26 : /************************************************************************/ 27 : /* OGRESRIJSONDriverIdentify() */ 28 : /************************************************************************/ 29 : 30 57999 : static int OGRESRIJSONDriverIdentify(GDALOpenInfo *poOpenInfo) 31 : { 32 57999 : GeoJSONSourceType nSrcType = ESRIJSONDriverGetSourceType(poOpenInfo); 33 57999 : if (nSrcType == eGeoJSONSourceUnknown) 34 57978 : return FALSE; 35 21 : if (nSrcType == eGeoJSONSourceService) 36 : { 37 2 : if (poOpenInfo->IsSingleAllowedDriver("ESRIJSON")) 38 1 : return TRUE; 39 1 : if (!STARTS_WITH_CI(poOpenInfo->pszFilename, "ESRIJSON:")) 40 : { 41 0 : return -1; 42 : } 43 : } 44 20 : return TRUE; 45 : } 46 : 47 : /************************************************************************/ 48 : /* Open() */ 49 : /************************************************************************/ 50 : 51 20 : static GDALDataset *OGRESRIJSONDriverOpen(GDALOpenInfo *poOpenInfo) 52 : { 53 20 : GeoJSONSourceType nSrcType = ESRIJSONDriverGetSourceType(poOpenInfo); 54 20 : if (nSrcType == eGeoJSONSourceUnknown) 55 0 : return nullptr; 56 20 : return OGRGeoJSONDriverOpenInternal(poOpenInfo, nSrcType, "ESRIJSON"); 57 : } 58 : 59 : /************************************************************************/ 60 : /* RegisterOGRESRIJSON() */ 61 : /************************************************************************/ 62 : 63 2055 : void RegisterOGRESRIJSON() 64 : { 65 2055 : if (!GDAL_CHECK_VERSION("OGR/ESRIJSON driver")) 66 0 : return; 67 : 68 2055 : if (GDALGetDriverByName("ESRIJSON") != nullptr) 69 263 : return; 70 : 71 1792 : GDALDriver *poDriver = new GDALDriver(); 72 : 73 1792 : poDriver->SetDescription("ESRIJSON"); 74 1792 : poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); 75 1792 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "ESRIJSON"); 76 1792 : poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "json"); 77 1792 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, 78 1792 : "drivers/vector/esrijson.html"); 79 1792 : poDriver->SetMetadataItem(GDAL_DCAP_Z_GEOMETRIES, "YES"); 80 1792 : poDriver->SetMetadataItem(GDAL_DCAP_MEASURED_GEOMETRIES, "YES"); 81 : 82 1792 : poDriver->SetMetadataItem( 83 : GDAL_DMD_OPENOPTIONLIST, 84 : "<OpenOptionList>" 85 : " <Option name='FEATURE_SERVER_PAGING' type='boolean' " 86 : "description='Whether to automatically scroll through results with a " 87 : "ArcGIS Feature Service endpoint'/>" 88 : " <Option name='HTTP_METHOD' type='string-select' default='AUTO' " 89 : "description='Which HTTP request method to use to send requests to " 90 : "the server'>" 91 : " <Value>AUTO</Value>" 92 : " <Value>GET</Value>" 93 : " <Value>POST</Value>" 94 : " </Option>" 95 1792 : "</OpenOptionList>"); 96 : 97 1792 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST, 98 1792 : "<CreationOptionList/>"); 99 : 100 1792 : poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES"); 101 1792 : poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE"); 102 : 103 1792 : poDriver->pfnOpen = OGRESRIJSONDriverOpen; 104 1792 : poDriver->pfnIdentify = OGRESRIJSONDriverIdentify; 105 : 106 1792 : GetGDALDriverManager()->RegisterDriver(poDriver); 107 : }