Skip to content

Add a mechanism to register external algorithm, in particular for drivers #12126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 14, 2025

Conversation

rouault
Copy link
Member

@rouault rouault commented Apr 10, 2025

Fixes #12101

  • GDALAlgorithm: add mechanism to register 'external' algorithms
  • GDALDriver: add methods to register algorithms, including deferred loaded drivers. The declaration of the algorithm (just its path) is done in the code integrated in libgdal, but the plugin DLL is loaded only if the algorithm is instantiated
  • PDF driver: add 'gdal driver pdf list-layers'
  • OpenFileGDB: add 'gdal driver openfilegdb repack'
$ gdal
ERROR 1: gdal: Missing command name.
Usage: gdal <COMMAND> [OPTIONS]
where <COMMAND> is one of:
[...]
  - driver:   Command for driver specific operations.
[...]

$ gdal driver
ERROR 1: driver: Missing subcommand name.
Usage: gdal driver <SUBCOMMAND> [OPTIONS]
where <SUBCOMMAND> is one of:
  - pdf: Command for PDF driver specific operations.
[...]

$ gdal driver pdf list-layers autotest/gdrivers/data/pdf/adobe_style_geospatial.pdf
[
  "New_Data_Frame",
  "New_Data_Frame.Graticule",
  "Layers",
  "Layers.Measured_Grid",
  "Layers.Graticule"
]

$ gdal driver openfilegdb repack poly.gdb && echo yes
yes

$ gdal driver openfilegdb repack poly.gdb --progress
0...10...20...30...40...50...60...70...80...90...100 - done.

@rouault rouault added enhancement funded through GSP Work funded through the GDAL Sponsorship Program gdal_cli Anything related to the new 3.11 "gdal" CLI frontend labels Apr 10, 2025
@rouault rouault added this to the 3.11.0 milestone Apr 10, 2025
@rouault rouault force-pushed the plugin_algorithm branch 10 times, most recently from 7a49c59 to c4d80c0 Compare April 10, 2025 21:38
@rouault rouault closed this Apr 10, 2025
@rouault rouault reopened this Apr 10, 2025
@rouault rouault force-pushed the plugin_algorithm branch 10 times, most recently from 114588f to d837304 Compare April 11, 2025 17:35
@coveralls
Copy link
Collaborator

Coverage Status

coverage: 70.582% (-0.01%) from 70.593%
when pulling 6f8935c on rouault:plugin_algorithm
into c19543d on OSGeo:master.

Copy link
Collaborator

@elpaso elpaso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!
This paves the road to useful driver-specific sub commands.

std::vector<std::string> ret = m_subAlgRegistry.GetNames();
const auto other = GDALGlobalAlgorithmRegistry::GetSingleton()
.GetDeclaredSubAlgorithmNames(m_callPath);
ret.insert(ret.end(), other.begin(), other.end());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we skip this insert call if other.empty() ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we skip this insert call if other.empty() ?

we could, but this adds extra code, for little advantage. This isn't a specially performance critical code path, and the overhead of inserting nothing should be un-noticeable

@rouault rouault merged commit 0b0d699 into OSGeo:master Apr 14, 2025
57 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement funded through GSP Work funded through the GDAL Sponsorship Program gdal_cli Anything related to the new 3.11 "gdal" CLI frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Idea: per-driver algorithms
3 participants