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
1 change: 1 addition & 0 deletions src/MapWinGIS.Core/MapWinGIS.Core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<ClInclude Include="include\mapwingis\gdal\GdalEnvironment.h" />
<ClInclude Include="include\mapwingis\gdal\GdalRuntime.h" />
<ClInclude Include="include\mapwingis\gdal\GdalAlgorithmRunner.h" />
<ClInclude Include="include\mapwingis\gdal\GdalTypedOptions.h" />
<ClInclude Include="include\mapwingis\vector\FieldInfo.h" />
<ClInclude Include="include\mapwingis\vector\VectorDataset.h" />
<ClInclude Include="src\internal\Utf8.h" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,15 @@ namespace mwg
[[nodiscard]] bool SetArgument(std::string_view name, double value);
/// Sets a list of real-valued algorithm argument values.
[[nodiscard]] bool SetArgument(std::string_view name, const std::vector<double>& value);
/// Sets a list of integer-valued algorithm argument values.
[[nodiscard]] bool SetArgument(std::string_view name, const std::vector<int>& value);
/// Sets a list of string-valued algorithm argument values.
[[nodiscard]] bool SetArgument(std::string_view name, const std::vector<std::string>& value);

/// Validates configured values using the instantiated GDAL algorithm's
/// argument metadata and constraints.
[[nodiscard]] bool ValidateArguments();

/// Parses GDAL-style command-line flags for this algorithm.
[[nodiscard]] bool ParseCommandLineArgs(const std::vector<std::string>& args);

Expand Down
375 changes: 375 additions & 0 deletions src/MapWinGIS.Core/include/mapwingis/gdal/GdalTypedOptions.h

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions src/MwGdalCore/GdalAlgorithmRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ namespace mwg
_impl->configurationValid, name, value);
}

bool GdalAlgorithmRunner::SetArgument(const std::string_view name, const std::vector<int>& value)
{
if (!CanConfigure(name))
return false;
return SetArgumentValue(_impl->algorithm.get(), _impl->errors,
_impl->configurationValid, name, value);
}

bool GdalAlgorithmRunner::SetArgument(const std::string_view name,
const std::vector<std::string>& value)
{
Expand Down Expand Up @@ -261,6 +269,30 @@ namespace mwg
return succeeded;
}

bool GdalAlgorithmRunner::ValidateArguments()
{
if (_impl->runAttempted)
{
AddError(_impl->errors, "GDAL algorithm arguments cannot be validated after Run().");
return false;
}
if (_impl->algorithm == nullptr || !_impl->configurationValid)
return false;

GdalErrorScope scope;
const std::size_t previousCount = _impl->errors.size();
const bool succeeded = _impl->algorithm->ValidateArguments();
AppendErrors(_impl->errors, scope);
scope.RethrowCaptureException();
if (!succeeded)
{
AddFailureIfNoDiagnostic(_impl->errors, previousCount,
"GDAL algorithm argument validation failed.");
_impl->configurationValid = false;
}
return succeeded;
}

bool GdalAlgorithmRunner::Run(GdalProgressAdapter::Callback progress,
const GdalCancellationToken* cancellationToken)
{
Expand Down
Loading
Loading