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/gdal_priv.h"
- #include "gdal/ogrsf_frmts.h"
- int main(int argc, char *argv[]) {
- GDALAllRegister();
- GDALDataset *poDS = static_cast<GDALDataset *>(GDALOpenEx(
- argv[1],
- GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR,
- NULL,
- NULL,
- NULL));
- if (poDS == NULL) {
- printf("Open failed: %s\n", CPLGetLastErrorMsg());
- 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("\tFeature Count: %lld\n", Layer->GetFeatureCount());
- for (const auto &Feature : Layer) {
- OGRGeometry *Geometry = Feature->GetGeometryRef();
- if (Geometry == nullptr) { continue; }
- OGRwkbGeometryType gt = Geometry->getGeometryType();
- switch (gt) {
- case wkbPoint: printf("w\tkbPoint\n"); break;
- case wkbPoint25D: printf("\twkbPoint25D\n"); break;
- case wkbLineString: printf("\twkbLineString\n"); break;
- case wkbPolygon: printf("\twkbPolygon\n"); break;
- default: printf("\tDefault\n"); break;
- }
- }
- }
- GDALClose(poDS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement