Loading
feat: #3614000: Add overpass_api_preset submodule: Provide a Config Entity to save, reuse, and export Overpass queries
Closes #3614000
Ported by hand from tbcs's MR !9 (merged) (tag previous/3618910-expose-surface-for/2026-10-12, commits 0e01cd65, 7c353360, and the preset parts of 2ed31651 and ac122b20) onto current 1.0.x, in an optional submodule as agreed on the issue.
Changes
Query builder in the main module
- New
Drupal\overpass_api\QueryBuilder(serviceoverpass_api.query_builder): pure Overpass QL generation, no geocoder or map dependency.overpass_api_ui'sQueryBuilderdelegates to it and keeps its public methods and the geocoding. {{bbox}}in a raw query expands to the baresouth,west,north,east, as in Overpass Turbo. 1.0.x wrapped it in parentheses, so the usualnode[...]({{bbox}});became((s,w,n,e)).
The overpass_api_preset submodule
- Config entity
overpass_preset, config namesoverpass_api_preset.preset.*. It stores the parts of a query (mode, element types, tag filters, location, timeout), never the generated QL, and the resolved area id or coordinates, so running a preset never calls a geocoder. - Admin UI at
/admin/structure/overpass-presetwith Edit, Duplicate, Delete and Export, permissionadminister overpass presets(restrict access). PresetExecutorInterface(overpass_api_preset.executor):execute()andcount(). The form's Test button counts without count;and makes one attempt.- Two disabled example presets: pharmacies and bus stops, in a small bounding box.
Query builder
- "Load preset" and "Save as preset" appear only when
overpass_api_presetis enabled and the user has the permission.overpass_api_uigets no new dependency. - The ported "Load preset" did not fill the form on current core: the form builder ignores user input without
form_idandform_token. Fixed.
Notes
- The entity type uses an annotation, not the PHP attribute, because the attribute needs Drupal 11.1 and the module supports ^10.3. Drupal 11.4 reports a deprecation for it.
- Not in this MR: the Feeds shortcut (#3614002), polygon areas (#3630444).
- Differences from MR !9 (merged) that a consumer building on it will notice: config prefix
overpass_api_preset.preset.*, namespaceDrupal\overpass_api_preset, executor serviceoverpass_api_preset.executor,count()takes an options argument, preset timeout default 60.
Commits
d738f4dMove the Overpass QL generation to the main module56ca9c5Add the overpass_api_preset submodule with the overpass_preset config entity951e187Add Load preset and Save as preset to the query builder2279f3bDocument presets and the {{bbox}} shortcut3a72d0fFix the cspell findings
Testing
- Unit: main module 78 (22 new for the builder),
overpass_api_ui22 unchanged,overpass_api_preset20. - Kernel (strict schema): 10. Default presets install disabled and valid, CRUD, every query mode accepted, an unknown mode is a violation, uninstall removes presets.
- Functional: preset admin UI 4, query builder with and without the submodule 2, settings form 1. No request reaches an Overpass endpoint.
- Locally (DDEV, Drupal 11.4.11, PostgreSQL 18, PHPUnit 11.5): all pass; phpcs (Drupal, DrupalPractice) and phpstan report nothing. cspell (CI word list) is clean on the changed files.