-
Notifications
You must be signed in to change notification settings - Fork 6
feat: batch task to reduce geojson maps precision and remove ids #1353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e700d77
Add geojson task and unit tests
davidgamez 7b02c25
Fix get sql timestamp
davidgamez 0981bb7
Fix blob call
davidgamez c181316
Add return to main function and db_session commit
davidgamez 851c019
Add missing id in the path
davidgamez 2cc9fb1
make file public
davidgamez 800a462
fix api failing tests and update documentation
davidgamez 3b6d4b2
implement gbfs geolocation adjustment
davidgamez 9a65a7b
Merge branch 'main' into feat/update_geolocation_precision_batch
davidgamez a7ec320
remove commented line
davidgamez 2cf0450
Merge branch 'main' into feat/update_geolocation_precision_batch
davidgamez f7bc1bd
fix documentation
davidgamez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ pluggy~=1.3.0 | |
| certifi~=2025.8.3 | ||
| fastapi | ||
| uvicorn[standard] | ||
| psutil | ||
|
|
||
|
|
||
| # SQL Alchemy and Geo Alchemy | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
functions-python/tasks_executor/src/tasks/geojson/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| # Update GeoJSON files | ||
|
|
||
| This task adjust the GeoJSON files removing the map IDs and reducing the precision of the coordinates to 5 decimal places. ALso updates the geolocation_file_created_date and geolocation_file_dataset_id fields in the Feed table. | ||
|
|
||
| --- | ||
|
|
||
| ## Task ID | ||
|
|
||
| Use task ID: `update_geojson_files_precision` | ||
|
|
||
| --- | ||
|
|
||
| ## Usage | ||
|
|
||
| The function accepts the following payload: | ||
|
|
||
| ```json | ||
| { | ||
| "dry_run": true, // [optional] If true, do not upload or modify the database (default: true) | ||
| "precision": 5, // [optional] Number of decimal places to keep in coordinates (default: 5) | ||
| "limit": 10, // [optional] Limit the number of feeds to process (default: no limit) | ||
| "data_type": "gtfs" // [optional] Type of data to process, either "gtfs" or "gbfs" (default: "gtfs") | ||
| } | ||
| ``` | ||
|
|
||
| ### Example: | ||
|
|
||
| ```json | ||
| { | ||
| "dry_run": true, | ||
| "data_type": "gtfs", | ||
| "limit": 10 | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## What It Does | ||
|
|
||
| List all feeds with GeoJSON files, download each file, remove map IDs, reduce coordinate precision to the specified number of decimal places, and re-upload the modified file. | ||
| Also updates the `geolocation_file_created_date` and `geolocation_file_dataset_id` fields in the `Feed` table. | ||
|
|
||
| ## GCP Environment Variables | ||
|
|
||
| The function requires the following environment variables: | ||
|
|
||
| | Variable | Description | | ||
| |--------------------------------|-------------------------------------------------------------------------| | ||
| | `DATASETS_BUCKET_NAME` | The name of the GCS bucket used to store extracted GTFS files | | ||
| | `GBFS_SNAPSHOTS_BUCKET_NAME` | The name of the GCS bucket used to store extracted GBFS snapshots files | | ||
|
|
||
| --- | ||
|
|
||
| ## Additional Notes | ||
|
|
||
| * Commits to the database occur in batches of 100 feeds to improve performance and avoid large transaction blocks. | ||
| * If `dry_run` is enabled, files are uploads or DB modifications are performed. Only the number of affected feeds is logged. | ||
| * The function is safe to rerun. It will only affect feeds with missing geolocation_file_dataset_id. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.