Advertisement
Guest User

Untitled

a guest
Aug 18th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <ogrsf_frmts.h>
  2. bool read_data_from_postgis()
  3. {
  4. using std::string;
  5. GDALAllRegister();
  6. GDALDataset* poDS;
  7. string source = "PG:host=192.168.1.11 port=5432 user=postgres password=abcd dbname=postgres";
  8.  
  9. poDS = (GDALDataset*)GDALOpenEx(source.c_str(), NULL, NULL, NULL, NULL);
  10. if (poDS == nullptr)
  11. {
  12. std::cerr << "connection FAILED.n";
  13. return false;
  14. }
  15. std::cout << "Connected to Postgres.n";
  16. std::cout << poDS->GetLayerCount() << std::endl; // return 0!!
  17.  
  18. return true;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement