Problem/Motivation
The overpass_api module currently exposes Overpass API access purely as a service (OverpassApi::query() / rawQuery()). There is no interactive UI for building an Overpass QL query: any site builder who wants to fetch OSM data has to hand-write Overpass QL and call the service from custom code.
The QGIS QuickOSM plugin solves exactly this problem for QGIS users with a query-builder GUI (query type selector, key/value filters, bounding box / named-area / around-area spatial modes, raw query editor). This issue proposes a Drupal-native equivalent as a new submodule, so Drupal site builders get the same experience without leaving the browser.
Proposed resolution
Add a new submodule, overpass_api_ui, depending on overpass_api, drupal/geocoder (+ geocoder-php/nominatim-provider), and drupal/leaflet:
- A
QueryBuilderFormwith 5 query-type modes: NotSpatial (attribute-only), BBox, InArea, AroundArea, and a raw query editor for hand-written OQL/XML. - Shared controls across the spatial modes: OSM type checkboxes (node/way/relation), a dynamic (AJAX add/remove) key/value filter table with AND/OR between rows.
- InArea/AroundArea resolve a free-text place name to an OSM ID / lat-lon via the
geocoderservice (Nominatim provider), Overpass's own{{geocodeArea:name}}/{{geocodeCoords:name}}tokens are client-side template syntax from overpass-turbo/QuickOSM, not real Overpass QL, so this resolution has to happen before the query is sent. - BBox mode gets an interactive Leaflet map (via the Geoman drawing controls bundled with
drupal/leaflet) to draw a rectangle, two-way synced with the 4 numeric lat/lon fields. - A live, read-only "generated query" preview pane shows the actual OQL that will be submitted, post geocoder-resolution.
- Running the query calls the existing
OverpassApi::rawQuery()and renders: an elements table (osm_id, osm_type, flattened tags), a raw-JSON toggle, a Leaflet map rendering the result set as a GeoJSON overlay, and a "download as .json" button.
Remaining tasks
- Scaffold
overpass_api_ui.info.yml/.routing.yml/.permissions.yml/.services.yml/.libraries.yml. - Implement the
overpass_api_ui.query_builderservice (form values → OQL fragment string), unit-tested independently of HTTP. - Implement
QueryBuilderFormwith the 5 query-type modes and shared key/value filter table (#ajax+#states). - Wire up
geocoder/Nominatim resolution for InArea/AroundArea, including the OSM-ID → Overpass area-ID math. - Wire up the Leaflet map: bbox rectangle drawing (BBox mode), radius-circle preview (AroundArea), GeoJSON result overlay.
- Implement results rendering: elements table, raw-JSON toggle, JSON download.
- Unit tests for the query-builder service; extend existing PHPUnit/PHPCS suites.
- User documentation for the new form.
User interface changes
New admin/user-facing route and form (e.g. /admin/config/system/overpass-api/query-builder), gated by a new permission (e.g. use overpass api ui). No changes to the existing overpass_api settings form.
The form uses a single "Query type" radios field (NotSpatial / BBox / InArea / AroundArea / Raw query) with mode-specific fieldsets shown or hidden via Drupal's #states API, rather than separate tabs per mode. Shared controls (OSM type checkboxes, key/value filter table) stay outside the conditional area so there is one AJAX-managed instance instead of duplicating it per mode.
API changes
New service: overpass_api_ui.query_builder. No changes to the existing overpass_api API surface (OverpassApi, OverpassQueryOptions). This submodule consumes them as-is.
Data model changes
None. No new entities, config schema, or database tables. Query building and result display are transient/in-request only.
Issue fork overpass_api-3610872
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
orkutmuratyilmazComment #4
orkutmuratyilmazComment #5
nitinkumar_7 commentedTested the MR locally installed the submodule with its geocoder/leaflet deps, ran through all 5 query modes NotSpatial, BBox......
Bbox drawing on the Leaflet map syncs correctly with the lat/lon fields, place-name resolution for InArea/AroundArea works via Nominatim, and results render fine as table + map + JSON download. Unit tests for the query-builder logic all pass locally.
Comment #6
nitinkumar_7 commentedone things worth addressing : no rate-limiting/flood control on "Run query" (it hits the public overpass endpoint directly), and the shipped Nominatim config still has a placeholder user-agent that needs replacing before production use.
Comment #7
orkutmuratyilmaz@nitinkumar_7, thanks for your comments, I'm working on your concerns now.
Comment #8
orkutmuratyilmaz@nitinkumar_7, I've just pushed 2 new commits.