/src/gdal/ogr/ogrsf_frmts/geojson/ogresrijsondriver.cpp
Line  | Count  | Source (jump to first uncovered line)  | 
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  |  | static int OGRESRIJSONDriverIdentify(GDALOpenInfo *poOpenInfo)  | 
31  | 0  | { | 
32  | 0  |     GeoJSONSourceType nSrcType = ESRIJSONDriverGetSourceType(poOpenInfo);  | 
33  | 0  |     if (nSrcType == eGeoJSONSourceUnknown)  | 
34  | 0  |         return FALSE;  | 
35  | 0  |     if (nSrcType == eGeoJSONSourceService)  | 
36  | 0  |     { | 
37  | 0  |         if (poOpenInfo->IsSingleAllowedDriver("ESRIJSON")) | 
38  | 0  |             return TRUE;  | 
39  | 0  |         if (!STARTS_WITH_CI(poOpenInfo->pszFilename, "ESRIJSON:"))  | 
40  | 0  |         { | 
41  | 0  |             return -1;  | 
42  | 0  |         }  | 
43  | 0  |     }  | 
44  | 0  |     return TRUE;  | 
45  | 0  | }  | 
46  |  |  | 
47  |  | /************************************************************************/  | 
48  |  | /*                           Open()                                     */  | 
49  |  | /************************************************************************/  | 
50  |  |  | 
51  |  | static GDALDataset *OGRESRIJSONDriverOpen(GDALOpenInfo *poOpenInfo)  | 
52  | 0  | { | 
53  | 0  |     GeoJSONSourceType nSrcType = ESRIJSONDriverGetSourceType(poOpenInfo);  | 
54  | 0  |     if (nSrcType == eGeoJSONSourceUnknown)  | 
55  | 0  |         return nullptr;  | 
56  | 0  |     return OGRGeoJSONDriverOpenInternal(poOpenInfo, nSrcType, "ESRIJSON");  | 
57  | 0  | }  | 
58  |  |  | 
59  |  | /************************************************************************/  | 
60  |  | /*                          RegisterOGRESRIJSON()                       */  | 
61  |  | /************************************************************************/  | 
62  |  |  | 
63  |  | void RegisterOGRESRIJSON()  | 
64  | 0  | { | 
65  | 0  |     if (!GDAL_CHECK_VERSION("OGR/ESRIJSON driver")) | 
66  | 0  |         return;  | 
67  |  |  | 
68  | 0  |     if (GDALGetDriverByName("ESRIJSON") != nullptr) | 
69  | 0  |         return;  | 
70  |  |  | 
71  | 0  |     GDALDriver *poDriver = new GDALDriver();  | 
72  |  | 
  | 
73  | 0  |     poDriver->SetDescription("ESRIJSON"); | 
74  | 0  |     poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES");  | 
75  | 0  |     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "ESRIJSON");  | 
76  | 0  |     poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "json");  | 
77  | 0  |     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC,  | 
78  | 0  |                               "drivers/vector/esrijson.html");  | 
79  | 0  |     poDriver->SetMetadataItem(GDAL_DCAP_Z_GEOMETRIES, "YES");  | 
80  | 0  |     poDriver->SetMetadataItem(GDAL_DCAP_MEASURED_GEOMETRIES, "YES");  | 
81  |  | 
  | 
82  | 0  |     poDriver->SetMetadataItem(  | 
83  | 0  |         GDAL_DMD_OPENOPTIONLIST,  | 
84  | 0  |         "<OpenOptionList>"  | 
85  | 0  |         "  <Option name='FEATURE_SERVER_PAGING' type='boolean' "  | 
86  | 0  |         "description='Whether to automatically scroll through results with a "  | 
87  | 0  |         "ArcGIS Feature Service endpoint'/>"  | 
88  | 0  |         "</OpenOptionList>");  | 
89  |  | 
  | 
90  | 0  |     poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST,  | 
91  | 0  |                               "<CreationOptionList/>");  | 
92  |  | 
  | 
93  | 0  |     poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES");  | 
94  | 0  |     poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE");  | 
95  |  | 
  | 
96  | 0  |     poDriver->pfnOpen = OGRESRIJSONDriverOpen;  | 
97  | 0  |     poDriver->pfnIdentify = OGRESRIJSONDriverIdentify;  | 
98  |  | 
  | 
99  | 0  |     GetGDALDriverManager()->RegisterDriver(poDriver);  | 
100  | 0  | }  |