Skip to content

feat: add PostPass query builder module to osm2pgsql-query-builder - #305

Open
KenKambi wants to merge 1 commit into
hotosm:feat/separate-sql-query-builderfrom
KenKambi:pr-304
Open

feat: add PostPass query builder module to osm2pgsql-query-builder#305
KenKambi wants to merge 1 commit into
hotosm:feat/separate-sql-query-builderfrom
KenKambi:pr-304

Conversation

@KenKambi

@KenKambi KenKambi commented May 5, 2026

Copy link
Copy Markdown

What type of PR is this?

Check all applicable

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation
  • 🧑‍💻 Refactor
  • ✅ Test
  • 🤖 Build or CI
  • ❓ Other (please specify)

Related Issue :

What does this PR do ?

  • Adds PostPass support to the osm2pgsql-query-builder package.
  • PostPass (https://postpass.geofabrik.de/) uses the same tags ->> 'key'
    column format as osm2pgsql, so all existing filter helpers are reused from
    builder.py — no duplication.
  • New: osm2pgsql_query_builder/postpass_module.py
  • Updated: __init__.py
  • New: tests/test_postpass.py.

A brief description of how this solves the issue.

  • This PR implements the postpass_module within the new osm2pgsql-query-builder structure. It introduces specialized SQL generation logic for PostPass backends, including:
    -PostPassQueryParams & BboxFilter: Pydantic models for strict input validation.
    -build_postpass_query: Generates optimized SQL using the && (bounding box) operator for faster spatial index scans.
    -wrap_postpass_geojson: Wraps query results into a valid GeoJSON FeatureCollection directly via PostgreSQL's json_build_object

Consideration :

  • A separate postpass_module.py was chosen because the PostPass backend has a meaningfully different execution model (HTTP POST vs. direct DB connection) and different table names. Keeping it isolated makes both easier to maintain and understand independently.

How to test ?

To test these changes locally, install the package in editable mode and run the suite:

# Install the package in editable mode
pip install -e osm2pgsql-query-builder

# Run the full test suite (disabling pytest_qgis if necessary)
python -m pytest osm2pgsql-query-builder/tests/ -v -p no:pytest_qgis

@KenKambi

KenKambi commented May 5, 2026

Copy link
Copy Markdown
Author

Hey @spwoodcock ! PR is up — 42/42 tests passing. Let me know if you'd like any changes before merging. 🙌

@spwoodcock

Copy link
Copy Markdown
Member

Awesome, thanks Ken!

Love the tests too 🙌

I think we should merge, then I will probably rename the package - I thought I would separate everything into small packages, but that is hassle - perhaps all of this can live together in raw-data-api-py, renamed to osm-data-client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants