Coverage Report

Created: 2026-08-14 09:29

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