11inline dataset_ptr
open(
char const* file,
bool update =
false)
14 char const* opts[] = {
"MSSQLSPATIAL_USE_BCP=NO",
nullptr};
15 auto flags = update ? GDAL_OF_UPDATE : GDAL_OF_READONLY;
16 auto ret = dataset_ptr{GDALOpenEx(file, flags, 0, opts, 0)};
17 boat::check(!!ret, error_or(concat(
"GDALOpenEx ", file)));
24 char const* opts[] = {
"SPATIALITE=YES",
nullptr};
25 auto drv = GDALGetDriverByName(
driver);
26 boat::check(!!drv, error_or(concat(
"GDALGetDriverByName ",
driver)));
27 auto ret = dataset_ptr{GDALCreate(drv, file, 0, 0, 0, GDT_Unknown, opts)};
28 boat::check(!!ret, error_or(concat(
"GDALCreate ", file)));
37 auto drv = GDALGetDriverByName(
driver);
38 boat::check(!!drv, error_or(concat(
"GDALGetDriverByName ",
driver)));
39 auto ret = dataset_ptr{GDALCreate(
44 static_cast<int>(rast.
bands.size()),
45 GDALGetDataTypeByName(rast.
bands.at(0).type_name.data()),
47 boat::check(!!ret, error_or(concat(
"GDALCreate ", file)));
55 check(GDALSetGeoTransform(ret.get(), a.data()));
57 check(GDALSetSpatialRef(ret.get(), crs.get()));
58 for (
auto [i, band] : std::views::enumerate(rast.
bands)) {
59 auto b = GDALGetRasterBand(ret.get(),
int(i + 1));
60 auto ci = GDALGetColorInterpretationByName(band.color_name.data());
61 boat::check(ci != GCI_Undefined, band.color_name);
62 check(GDALSetRasterColorInterpretation(b, ci));