File: ogrgrassdriver.cpp

package info (click to toggle)
gdal-grass 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,044 kB
  • sloc: python: 2,240; cpp: 1,954; makefile: 18
file content (64 lines) | stat: -rw-r--r-- 1,957 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/******************************************************************************
 *
 * Project:  OpenGIS Simple Features Reference Implementation
 * Purpose:  Implements OGRGRASSDriver class.
 * Author:   Radim Blazek, radim.blazek@gmail.com
 *
 ******************************************************************************
 * Copyright (c) 2005, Radim Blazek <radim.blazek@gmail.com>
 *
 * SPDX-License-Identifier: MIT
 *
 ****************************************************************************/

#include "ogrgrass.h"
#include "cpl_conv.h"
#include "cpl_string.h"

extern "C"
{
    void RegisterOGRGRASS();
}

/************************************************************************/
/*                                Open()                                */
/************************************************************************/
static auto GRASSDatasetOpen(GDALOpenInfo *poOpenInfo) -> GDALDataset *
{
    auto *poDS = new OGRGRASSDataSource();

    bool bUpdate = poOpenInfo->eAccess == GA_Update;

    if (!poDS->Open(poOpenInfo->pszFilename, bUpdate, true))
    {
        delete poDS;
        return nullptr;
    }
    else
    {
        return poDS;
    }
}

/************************************************************************/
/*                          RegisterOGRGRASS()                          */
/************************************************************************/
void RegisterOGRGRASS()
{
    if (!GDAL_CHECK_VERSION("OGR/GRASS driver"))
        return;

    if (GDALGetDriverByName("OGR_GRASS") != nullptr)
        return;

    auto *poDriver = new GDALDriver();

    poDriver->SetDescription("OGR_GRASS");
    poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES");
    poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "GRASS Vectors (5.7+)");
    poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/grass.html");

    poDriver->pfnOpen = GRASSDatasetOpen;

    GetGDALDriverManager()->RegisterDriver(poDriver);
}