/src/gdal/ogr/ogrsf_frmts/vfk/ogrvfkdriver.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: OpenGIS Simple Features Reference Implementation |
4 | | * Purpose: Implements OGRVFKDriver class. |
5 | | * Author: Martin Landa, landa.martin gmail.com |
6 | | * |
7 | | ****************************************************************************** |
8 | | * Copyright (c) 2009-2018, Martin Landa <landa.martin gmail.com> |
9 | | * |
10 | | * SPDX-License-Identifier: MIT |
11 | | ****************************************************************************/ |
12 | | |
13 | | #include "ogr_vfk.h" |
14 | | #include "cpl_conv.h" |
15 | | #include "cpl_string.h" |
16 | | #include "ogrvfkdrivercore.h" |
17 | | |
18 | | /* |
19 | | \brief Open existing data source |
20 | | \return NULL on failure |
21 | | */ |
22 | | static GDALDataset *OGRVFKDriverOpen(GDALOpenInfo *poOpenInfo) |
23 | 3.93k | { |
24 | 3.93k | if (poOpenInfo->eAccess == GA_Update || !OGRVFKDriverIdentify(poOpenInfo)) |
25 | 0 | return nullptr; |
26 | | |
27 | 3.93k | OGRVFKDataSource *poDS = new OGRVFKDataSource(); |
28 | | |
29 | 3.93k | if (!poDS->Open(poOpenInfo) || poDS->GetLayerCount() == 0) |
30 | 1.41k | { |
31 | 1.41k | delete poDS; |
32 | 1.41k | return nullptr; |
33 | 1.41k | } |
34 | 2.51k | else |
35 | 2.51k | return poDS; |
36 | 3.93k | } |
37 | | |
38 | | /*! |
39 | | \brief Register VFK driver |
40 | | */ |
41 | | void RegisterOGRVFK() |
42 | 24 | { |
43 | 24 | if (!GDAL_CHECK_VERSION("OGR/VFK driver")) |
44 | 0 | return; |
45 | | |
46 | 24 | if (GDALGetDriverByName(DRIVER_NAME) != nullptr) |
47 | 0 | return; |
48 | | |
49 | 24 | GDALDriver *poDriver = new GDALDriver(); |
50 | 24 | OGRVFKDriverSetCommonMetadata(poDriver); |
51 | 24 | poDriver->pfnOpen = OGRVFKDriverOpen; |
52 | | |
53 | 24 | GetGDALDriverManager()->RegisterDriver(poDriver); |
54 | 24 | } |