Skip to content

Conversation

@cka-y
Copy link
Contributor

@cka-y cka-y commented Jun 16, 2025

Summary
Closes #1221.

Details

Previously, the query used to filter feeds by bounding box did not properly join GtfsDataset and GtfsFeed, resulting in a cartesian product. This caused the ST_Covers(...) spatial filter to be applied incorrectly or not at all.

The query has been updated to explicitly join GtfsDataset on feed_id when applying bounding box filters, preventing duplicate table references and ensuring the spatial filtering works as intended.

Validation

The following request now returns the correct GTFS feed for the Lisbon area (as expected):

GET /v1/gtfs_feeds?limit=10&offset=0&bounding_filter_method=completely_enclosed&is_official=true&dataset_latitudes=38.4,39.0&dataset_longitudes=-8.8,-9.5

Example response from dev:

Sample output
[
  {
    "id": "mdb-1272",
    "data_type": "gtfs",
    ...
    "provider": "Cascais Próxima, E.M., S.A.",
    ...
    "locations": [
      { "country_code": "PT", "municipality": "Cascais e Estoril", ... },
      ...
    ],
    "latest_dataset": {
      "id": "mdb-1272-202502251645",
      "bounding_box": {
        "minimum_latitude": 38.679561,
        "maximum_latitude": 38.763594,
        "minimum_longitude": -9.484887,
        "maximum_longitude": -9.313059
      },
      ...
    }
  }
]

✅ Verified locally pointing to dev.

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with ./scripts/api-tests.sh to make sure you didn't break anything
  • Add or update any needed documentation to the repo
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s)

Copy link
Member

@davidgamez davidgamez left a comment

Choose a reason for hiding this comment

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

LGTM!

@cka-y cka-y merged commit ee644de into main Jun 16, 2025
2 of 3 checks passed
@cka-y cka-y deleted the feat/1221 branch June 16, 2025 20:26
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.

/gtfs_feeds filter by coodinates not working

3 participants