• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OSGeo / gdal / 14797820179

02 May 2025 03:04PM UTC coverage: 70.761% (-0.02%) from 70.776%
14797820179

Pull #12250

github

web-flow
Merge 64f84b285 into 7790d0b3c
Pull Request #12250: Rename gdal raster astype to gdal raster set-type

6 of 6 new or added lines in 4 files covered. (100.0%)

166 existing lines in 31 files now uncovered.

562913 of 795512 relevant lines covered (70.76%)

222329.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

43.75
/gnm/gnm_frmts/db/gnmdbdriver.cpp
1
/******************************************************************************
2
 *
3
 * Project:  GDAL/OGR Geography Network support (Geographic Network Model)
4
 * Purpose:  GNM generic driver.
5
 * Authors:  Mikhail Gusev (gusevmihs at gmail dot com)
6
 *           Dmitry Baryshnikov, polimax@mail.ru
7
 *
8
 ******************************************************************************
9
 * Copyright (c) 2014, Mikhail Gusev
10
 * Copyright (c) 2014-2015, NextGIS <info@nextgis.com>
11
 *
12
 * Permission is hereby granted, free of charge, to any person obtaining a
13
 * copy of this software and associated documentation files (the "Software"),
14
 * to deal in the Software without restriction, including without limitation
15
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16
 * and/or sell copies of the Software, and to permit persons to whom the
17
 * Software is furnished to do so, subject to the following conditions:
18
 *
19
 * The above copyright notice and this permission notice shall be included
20
 * in all copies or substantial portions of the Software.
21
 *
22
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28
 * DEALINGS IN THE SOFTWARE.
29
 ****************************************************************************/
30

31
#include "gnm_frmts.h"
32
#include "gnm_priv.h"
33
#include "gnmdb.h"
34

35
static int GNMDBDriverIdentify(GDALOpenInfo *poOpenInfo)
42,546✔
36

37
{
38
    if (!STARTS_WITH_CI(poOpenInfo->pszFilename, "PGB:") &&
42,546✔
39
        !STARTS_WITH_CI(poOpenInfo->pszFilename, "PG:"))
42,546✔
40
        return FALSE;
42,546✔
UNCOV
41
    if ((poOpenInfo->nOpenFlags & GDAL_OF_GNM) == 0)
×
42
        return FALSE;
×
43

44
    // TODO: do we need to open datasource end check tables/layer exist?
45

UNCOV
46
    return TRUE;
×
47
}
48

49
static GDALDataset *GNMDBDriverOpen(GDALOpenInfo *poOpenInfo)
×
50

51
{
52
    if (!GNMDBDriverIdentify(poOpenInfo))
×
53
        return nullptr;
×
54

55
    GNMDatabaseNetwork *poFN = new GNMDatabaseNetwork();
×
56

57
    if (poFN->Open(poOpenInfo) != CE_None)
×
58
    {
59
        delete poFN;
×
60
        poFN = nullptr;
×
61
    }
62

63
    return poFN;
×
64
}
65

66
static GDALDataset *
67
GNMDBDriverCreate(const char *pszName, CPL_UNUSED int nBands,
×
68
                  CPL_UNUSED int nXSize, CPL_UNUSED int nYSize,
69
                  CPL_UNUSED GDALDataType eDT, char **papszOptions)
70
{
71
    CPLAssert(nullptr != pszName);
×
72
    CPLDebug("GNM", "Attempt to create network at: %s", pszName);
×
73

74
    GNMDatabaseNetwork *poFN = new GNMDatabaseNetwork();
×
75

76
    if (poFN->Create(pszName, papszOptions) != CE_None)
×
77
    {
78
        delete poFN;
×
79
        poFN = nullptr;
×
80
    }
81

82
    return poFN;
×
83
}
84

85
static CPLErr GNMDBDriverDelete(const char *pszDataSource)
×
86

87
{
88
    GDALOpenInfo oOpenInfo(pszDataSource, GA_Update);
×
89
    GNMDatabaseNetwork *poFN = new GNMDatabaseNetwork();
×
90

91
    if (poFN->Open(&oOpenInfo) != CE_None)
×
92
    {
93
        delete poFN;
×
94
        poFN = nullptr;
×
95

96
        return CE_Failure;
×
97
    }
98

99
    return poFN->Delete();
×
100
}
101

102
void RegisterGNMDatabase()
1,672✔
103
{
104
    if (GDALGetDriverByName("GNMDatabase") == nullptr)
1,672✔
105
    {
106
        GDALDriver *poDriver = new GDALDriver();
1,390✔
107

108
        poDriver->SetDescription("GNMDatabase");
1,390✔
109
        poDriver->SetMetadataItem(GDAL_DCAP_GNM, "YES");
1,390✔
110
        poDriver->SetMetadataItem(GDAL_DMD_LONGNAME,
1,390✔
111
                                  "Geographic Network generic DB based "
112
                                  "model");
1,390✔
113

114
        poDriver->SetMetadataItem(
1,390✔
115
            GDAL_DMD_CREATIONOPTIONLIST,
116
            CPLSPrintf(
117
                "<CreationOptionList>"
118
                "  <Option name='%s' type='string' description='The network "
119
                "name. Also it will be a folder name, so the limits for folder "
120
                "name distribute on network name'/>"
121
                "  <Option name='%s' type='string' description='The network "
122
                "description. Any text describes the network'/>"
123
                "  <Option name='%s' type='string' description='The network "
124
                "Spatial reference. All network features will reproject to "
125
                "this spatial reference. May be a WKT text or EPSG code'/>"
126
                "  <Option name='FORMAT' type='string' description='The OGR "
127
                "format to store network data.'/>"
128
                "  <Option name='OVERWRITE' type='boolean' "
129
                "description='Overwrite exist network or not' default='NO'/>"
130
                "</CreationOptionList>",
131
                GNM_MD_NAME, GNM_MD_DESCR, GNM_MD_SRS));
1,390✔
132

133
        poDriver->SetMetadataItem(GDAL_DS_LAYER_CREATIONOPTIONLIST,
1,390✔
134
                                  "<LayerCreationOptionList/>");
1,390✔
135
        poDriver->pfnOpen = GNMDBDriverOpen;
1,390✔
136
        poDriver->pfnIdentify = GNMDBDriverIdentify;
1,390✔
137
        poDriver->pfnCreate = GNMDBDriverCreate;
1,390✔
138
        poDriver->pfnDelete = GNMDBDriverDelete;
1,390✔
139

140
        GetGDALDriverManager()->RegisterDriver(poDriver);
1,390✔
141
    }
142
}
1,672✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc