list.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <stdio.h>
  2. #include <grass/gis.h>
  3. #include <grass/glocale.h>
  4. #include <grass/gis.h>
  5. #include <grass/glocale.h>
  6. #include <gdal.h>
  7. #include "proto.h"
  8. void list_formats(void)
  9. {
  10. /* -------------------------------------------------------------------- */
  11. /* List supported formats and exit. */
  12. /* code from GDAL 1.2.5 gcore/gdal_misc.cpp */
  13. /* Copyright (c) 1999, Frank Warmerdam */
  14. /* -------------------------------------------------------------------- */
  15. int iDr;
  16. G_message(_("Supported formats:"));
  17. for (iDr = 0; iDr < GDALGetDriverCount(); iDr++) {
  18. GDALDriverH hDriver = GDALGetDriver(iDr);
  19. const char *pszRWFlag;
  20. #ifdef GDAL_DCAP_RASTER
  21. /* Starting with GDAL 2.0, vector drivers can also be returned */
  22. /* Only keep raster drivers */
  23. if (!GDALGetMetadataItem(hDriver, GDAL_DCAP_RASTER, NULL))
  24. continue;
  25. #endif
  26. if (GDALGetMetadataItem(hDriver, GDAL_DCAP_CREATE, NULL))
  27. pszRWFlag = "rw+";
  28. else if (GDALGetMetadataItem(hDriver, GDAL_DCAP_CREATECOPY, NULL))
  29. pszRWFlag = "rw";
  30. else
  31. pszRWFlag = "ro";
  32. fprintf(stdout, " %s (%s): %s\n",
  33. GDALGetDriverShortName(hDriver),
  34. pszRWFlag, GDALGetDriverLongName(hDriver));
  35. }
  36. }