\param type Reqested type of the raster. \param driver Pointer to the GDAL driver being used to write the raster. \return Requested type, or if not supported, the preferred type to use for the raster. */
| 406 | for the raster. |
| 407 | */ |
| 408 | GDALError Raster::validateType(Dimension::Type& type, |
| 409 | GDALDriver *driver) |
| 410 | { |
| 411 | // Convert the string of supported GDAL types to a vector of PDAL types, |
| 412 | // ignoring types that aren't supported by PDAL (mostly complex values). |
| 413 | std::vector<Dimension::Type> types; |
| 414 | const char *itemp = driver->GetMetadataItem(GDAL_DMD_CREATIONDATATYPES); |
| 415 | if (itemp) |
| 416 | { |
| 417 | StringList items = Utils::split2(std::string(itemp), ' '); |
| 418 | for (auto& i : items) |
| 419 | { |
| 420 | Dimension::Type t = toPdalType(i); |
| 421 | if (t != Dimension::Type::None) |
| 422 | types.push_back(t); |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | // If requested type is not supported, return an error. |
| 427 | if (type != Dimension::Type::None && !Utils::contains(types, type)) |
| 428 | { |
| 429 | m_errorMsg = "Requested type '" + Dimension::interpretationName(type) + |
| 430 | "' not supported by GDAL driver '" + m_drivername + "'."; |
| 431 | return GDALError::InvalidType; |
| 432 | } |
| 433 | |
| 434 | // If no type is requested, take the "largest" one. |
| 435 | if (type == Dimension::Type::None) |
| 436 | { |
| 437 | std::sort(types.begin(), types.end()); |
| 438 | type = types.back(); |
| 439 | } |
| 440 | return GDALError::None; |
| 441 | } |
| 442 | |
| 443 | |
| 444 | /** |
nothing calls this directly
no test coverage detected