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 (service overpass_api.query_builder): pure Overpass QL generation, no geocoder or map dependency. overpass_api_ui's QueryBuilder delegates to it and keeps its public methods and the geocoding.
  • {{bbox}} in a raw query expands to the bare south,west,north,east, as in Overpass Turbo. 1.0.x wrapped it in parentheses, so the usual node[...]({{bbox}}); became ((s,w,n,e)).

The overpass_api_preset submodule

  • Config entity overpass_preset, config names overpass_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-preset with Edit, Duplicate, Delete and Export, permission administer overpass presets (restrict access).
  • PresetExecutorInterface (overpass_api_preset.executor): execute() and count(). The form's Test button counts with out 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_preset is enabled and the user has the permission. overpass_api_ui gets no new dependency.
  • The ported "Load preset" did not fill the form on current core: the form builder ignores user input without form_id and form_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.*, namespace Drupal\overpass_api_preset, executor service overpass_api_preset.executor, count() takes an options argument, preset timeout default 60.

Commits

  • d738f4d Move the Overpass QL generation to the main module
  • 56ca9c5 Add the overpass_api_preset submodule with the overpass_preset config entity
  • 951e187 Add Load preset and Save as preset to the query builder
  • 2279f3b Document presets and the {{bbox}} shortcut
  • 3a72d0f Fix the cspell findings

Testing

  • Unit: main module 78 (22 new for the builder), overpass_api_ui 22 unchanged, overpass_api_preset 20.
  • 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.

Merge request reports

Loading
Loading