LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/geojson - ogresrijsondriver.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 31 35 88.6 %
Date: 2024-05-03 15:49:35 Functions: 3 3 100.0 %

          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             :  * Permission is hereby granted, free of charge, to any person obtaining a
      11             :  * copy of this software and associated documentation files (the "Software"),
      12             :  * to deal in the Software without restriction, including without limitation
      13             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      14             :  * and/or sell copies of the Software, and to permit persons to whom the
      15             :  * Software is furnished to do so, subject to the following conditions:
      16             :  *
      17             :  * The above copyright notice and this permission notice shall be included
      18             :  * in all copies or substantial portions of the Software.
      19             :  *
      20             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      21             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      22             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      23             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      24             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      25             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      26             :  * DEALINGS IN THE SOFTWARE.
      27             :  ****************************************************************************/
      28             : 
      29             : #include "cpl_port.h"
      30             : #include "ogr_geojson.h"
      31             : 
      32             : #include <stdlib.h>
      33             : #include <string.h>
      34             : 
      35             : #include "cpl_conv.h"
      36             : #include "cpl_error.h"
      37             : #include "gdal.h"
      38             : #include "gdal_priv.h"
      39             : #include "ogrgeojsonutils.h"
      40             : #include "ogrsf_frmts.h"
      41             : 
      42             : /************************************************************************/
      43             : /*                       OGRESRIJSONDriverIdentify()                    */
      44             : /************************************************************************/
      45             : 
      46       44281 : static int OGRESRIJSONDriverIdentify(GDALOpenInfo *poOpenInfo)
      47             : {
      48       44281 :     GeoJSONSourceType nSrcType = ESRIJSONDriverGetSourceType(poOpenInfo);
      49       44281 :     if (nSrcType == eGeoJSONSourceUnknown)
      50       44264 :         return FALSE;
      51          17 :     if (nSrcType == eGeoJSONSourceService &&
      52           0 :         !STARTS_WITH_CI(poOpenInfo->pszFilename, "ESRIJSON:"))
      53             :     {
      54           0 :         return -1;
      55             :     }
      56          17 :     return TRUE;
      57             : }
      58             : 
      59             : /************************************************************************/
      60             : /*                           Open()                                     */
      61             : /************************************************************************/
      62             : 
      63          17 : static GDALDataset *OGRESRIJSONDriverOpen(GDALOpenInfo *poOpenInfo)
      64             : {
      65          17 :     GeoJSONSourceType nSrcType = ESRIJSONDriverGetSourceType(poOpenInfo);
      66          17 :     if (nSrcType == eGeoJSONSourceUnknown)
      67           0 :         return nullptr;
      68          17 :     return OGRGeoJSONDriverOpenInternal(poOpenInfo, nSrcType, "ESRIJSON");
      69             : }
      70             : 
      71             : /************************************************************************/
      72             : /*                          RegisterOGRESRIJSON()                       */
      73             : /************************************************************************/
      74             : 
      75        1511 : void RegisterOGRESRIJSON()
      76             : {
      77        1511 :     if (!GDAL_CHECK_VERSION("OGR/ESRIJSON driver"))
      78           0 :         return;
      79             : 
      80        1511 :     if (GDALGetDriverByName("ESRIJSON") != nullptr)
      81         295 :         return;
      82             : 
      83        1216 :     GDALDriver *poDriver = new GDALDriver();
      84             : 
      85        1216 :     poDriver->SetDescription("ESRIJSON");
      86        1216 :     poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES");
      87        1216 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "ESRIJSON");
      88        1216 :     poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "json");
      89        1216 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC,
      90        1216 :                               "drivers/vector/esrijson.html");
      91        1216 :     poDriver->SetMetadataItem(GDAL_DCAP_Z_GEOMETRIES, "YES");
      92             : 
      93        1216 :     poDriver->SetMetadataItem(
      94             :         GDAL_DMD_OPENOPTIONLIST,
      95             :         "<OpenOptionList>"
      96             :         "  <Option name='FEATURE_SERVER_PAGING' type='boolean' "
      97             :         "description='Whether to automatically scroll through results with a "
      98             :         "ArcGIS Feature Service endpoint'/>"
      99        1216 :         "</OpenOptionList>");
     100             : 
     101        1216 :     poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST,
     102        1216 :                               "<CreationOptionList/>");
     103             : 
     104        1216 :     poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES");
     105        1216 :     poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE");
     106             : 
     107        1216 :     poDriver->pfnOpen = OGRESRIJSONDriverOpen;
     108        1216 :     poDriver->pfnIdentify = OGRESRIJSONDriverIdentify;
     109             : 
     110        1216 :     GetGDALDriverManager()->RegisterDriver(poDriver);
     111             : }

Generated by: LCOV version 1.14