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
|
#include <string.h>
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/glocale.h>
#ifdef HAVE_OGR
#include "ogr_api.h"
#endif
int is_ogr(const char *format)
{
int use_ogr = TRUE;
if (strcmp(format, "PostgreSQL") == 0) {
#if defined HAVE_OGR && defined HAVE_POSTGRES
if (!getenv("GRASS_VECTOR_OGR"))
use_ogr = FALSE;
#else
#ifdef HAVE_POSTGRES
if (getenv("GRASS_VECTOR_OGR"))
G_warning(_("Environment variable GRASS_VECTOR_OGR defined, "
"but GRASS is compiled with OGR support. "
"Using GRASS-PostGIS data driver instead."));
use_ogr = FALSE;
#else /* -> force using OGR */
G_warning(_("GRASS is not compiled with PostgreSQL support. "
"Using OGR-PostgreSQL driver instead of native "
"GRASS-PostGIS data driver."));
#endif /* HAVE_POSTRES */
#endif /* HAVE_OGR && HAVE_POSTGRES */
}
return use_ogr;
}
void check_format(char *format)
{
if (!is_ogr(format))
return;
#ifdef HAVE_OGR
OGRSFDriverH driver;
G_strchg(format, '_', ' ');
driver = OGRGetDriverByName(format);
if (!driver)
G_fatal_error(_("Format <%s> not supported"), format);
if (!OGR_Dr_TestCapability(driver, ODrCCreateDataSource))
G_fatal_error(_("Format <%s> does not support writing"), format);
#endif
}
|