Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions apps/gdalalg_raster_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,41 @@ void GDALRasterIndexAlgorithm::AddCommonOptions()

AddArg("skip-errors", 0, _("Skip errors related to input datasets"),
&m_skipErrors);
AddArg("profile", 0, _("Profile of output dataset"), &m_profile)
.SetDefault(m_profile)
.SetChoices(PROFILE_NONE, PROFILE_STAC_GEOPARQUET);
AddArg("base-url", 0, _("Base URL for STAC-GeoParquet href"), &m_baseUrl);
AddArg("id-method", 0, _("How to derive STAC-GeoParquet 'id'"), &m_idMethod)
.SetDefault(m_idMethod)
.SetChoices(ID_METHOD_FILENAME, ID_METHOD_MD5, ID_METHOD_METADATA_ITEM);
AddArg("id-metadata-item", 0,
_("Name of metadata item used to set STAC-GeoParquet 'id'"),
&m_idMetadataItem)
.SetDefault(m_idMetadataItem)
.AddValidationAction(
[this]()
{
m_idMethod = ID_METHOD_METADATA_ITEM;
return true;
});

AddValidationAction(
[this]()
{
if (m_profile == PROFILE_STAC_GEOPARQUET)
{
if (!m_outputFormat.empty() &&
!EQUAL(m_outputFormat.c_str(), "Parquet"))
{
ReportError(CE_Failure, CPLE_NotSupported,
"STAC-GeoParquet profile is only compatible "
"with Parquet output format");
return false;
}
m_outputFormat = "Parquet";
}
return true;
});
}

/************************************************************************/
Expand Down Expand Up @@ -140,6 +175,24 @@ bool GDALRasterIndexAlgorithm::RunImpl(GDALProgressFunc pfnProgress,
CPLStringList aosOptions;
aosOptions.push_back("--invoked-from-gdal-raster-index");

if (m_profile != PROFILE_NONE)
{
aosOptions.push_back("-profile");
aosOptions.push_back(m_profile);

if (!m_baseUrl.empty())
{
aosOptions.push_back("--base-url");
aosOptions.push_back(m_baseUrl);
}

aosOptions.push_back("--id-metadata-item");
aosOptions.push_back(m_idMetadataItem);

aosOptions.push_back("--id-method");
aosOptions.push_back(m_idMethod);
}

if (m_skipErrors)
{
aosOptions.push_back("-skip_errors");
Expand Down
10 changes: 10 additions & 0 deletions apps/gdalalg_raster_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ class CPL_DLL GDALRasterIndexAlgorithm /* non final */
std::string m_sourceCrsFormat = "auto";
std::vector<std::string> m_metadata{};
bool m_skipErrors = false;

static constexpr const char *PROFILE_NONE = "none";
static constexpr const char *PROFILE_STAC_GEOPARQUET = "STAC-GeoParquet";
std::string m_profile{PROFILE_NONE};
std::string m_baseUrl{};
static constexpr const char *ID_METHOD_FILENAME = "filename";
static constexpr const char *ID_METHOD_MD5 = "md5";
static constexpr const char *ID_METHOD_METADATA_ITEM = "metadata-item";
std::string m_idMethod{ID_METHOD_FILENAME};
std::string m_idMetadataItem{"id"};
};

//! @endcond
Expand Down
Loading
Loading