如何在 C++ 中使用 gdal 打开 postGIS table?
How do I open postGIS table with gdal in C++?
我对使用 C++ 的 gdal 完全陌生,想用 gdal API 打开 postgreSQL table(几何)。我在 gdal.org 的教程中找不到如何做到这一点。以下是我现在正在尝试的。如何使用 GDALOpenEx for postgreSQL 打开 table?
GDALAllRegister();
GDALDataset* poDS;
std::string source = "PG:host=111.111.111.111 port=5432 dbname=db user=user password=password";
poDS = (GDALDataset*) GDALOpenEx(source.c_str(), GDAL_OF_VERBOSE_ERROR | GDAL_OF_VECTOR, NULL, NULL, NULL);
ERROR 4: PG:host=host port=5432 dbname=db user=user password=XXXX No such file or directory
这个问题我也疑惑了好几个小时。
我使用了相同类型的连接字符串。
这足以连接 postgresql.If 这没有用,请检查其他内容。
编译 gdal 时启用 postgresql(在 nmake.opt 文件中打开 PostGIS Libraries 列,设置 libpq.lib 文件和包含目录)。
代码:
GDALAllRegister();
const char* path ="PG:dbname=db host=localhost port=5432 user=postgres
password=password";
GDALDataset *pDos =nullptr;
pDos = (GDALDataset *)GDALOpenEx(path,GDAL_OF_VECTOR,nullptr,nullptr,nullptr);
我对使用 C++ 的 gdal 完全陌生,想用 gdal API 打开 postgreSQL table(几何)。我在 gdal.org 的教程中找不到如何做到这一点。以下是我现在正在尝试的。如何使用 GDALOpenEx for postgreSQL 打开 table?
GDALAllRegister();
GDALDataset* poDS;
std::string source = "PG:host=111.111.111.111 port=5432 dbname=db user=user password=password";
poDS = (GDALDataset*) GDALOpenEx(source.c_str(), GDAL_OF_VERBOSE_ERROR | GDAL_OF_VECTOR, NULL, NULL, NULL);
ERROR 4: PG:host=host port=5432 dbname=db user=user password=XXXX No such file or directory
这个问题我也疑惑了好几个小时。 我使用了相同类型的连接字符串。 这足以连接 postgresql.If 这没有用,请检查其他内容。 编译 gdal 时启用 postgresql(在 nmake.opt 文件中打开 PostGIS Libraries 列,设置 libpq.lib 文件和包含目录)。 代码:
GDALAllRegister();
const char* path ="PG:dbname=db host=localhost port=5432 user=postgres
password=password";
GDALDataset *pDos =nullptr;
pDos = (GDALDataset *)GDALOpenEx(path,GDAL_OF_VECTOR,nullptr,nullptr,nullptr);