Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // GDAL_Test.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include <iostream>
- //#include "gdal.h"
- #include "ogrsf_frmts/ogrsf_frmts.h"
- int main()
- {
- system("echo GDAL_DATA variable: %GDAL_DATA%");
- GDALAllRegister();
- GDALDataset* poDS = static_cast<GDALDataset*>(
- GDALOpenEx("C:\\GDAL\\S57Data\\1B5X02NE.000", GDAL_OF_VECTOR, NULL, NULL, NULL));
- if (poDS == NULL)
- {
- printf("Open failed.\n");
- exit(1);
- }
- printf("FileList\n");
- char** FileList = poDS->GetFileList();
- char* File = FileList[0];
- int i = 0;
- while (File != nullptr)
- {
- printf("File %d: %s\n",++i,File);
- File = FileList[i];
- }
- printf("Driver Name: %s\n", poDS->GetDriverName());
- printf("Layer Count: %d\n", poDS->GetLayerCount());
- for (OGRLayer* Layer : poDS->GetLayers())
- {
- Layer->ResetReading();
- printf("Layer Name: %s\n", Layer->GetName());
- //printf("Feature Count: %d\n", Layer->GetFeatureCount());
- continue;
- for (const auto& Feature : Layer)
- {
- OGRGeometry* Geometry = Feature->GetGeometryRef();
- if (Geometry == nullptr)
- {
- continue;
- }
- OGRwkbGeometryType gt = Geometry->getGeometryType();
- switch (gt)
- {
- case wkbPoint:
- printf("wkbPoint\n");
- break;
- case wkbPoint25D:
- printf("wkbPoint25D\n");
- break;
- case wkbLineString:
- printf("wkbLineString\n");
- break;
- case wkbPolygon:
- printf("wkbPolygon\n");
- break;
- default:
- printf("Default\n");
- break;
- }
- }
- }
- GDALClose(poDS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement