-
-
Notifications
You must be signed in to change notification settings - Fork 33
Vehicle chapter rewrite #258
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
Vehicle chapter rewrite #258
Conversation
WalkthroughCMake image handling was standardized to use configure_file(... COPYONLY) and arrow-style debug messages; add_subdirectory ordering adjusted. The vehicle chapter was refactored: image names and SQL views renamed/added, routing moved to vehicle_net/taxi_net, penalties added, and build BYPRODUCTS/DEPENDS updated. Locale POT/PO updated. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer
participant CMake as CMake (top)
participant Sub as Subdir CMake
participant FS as Filesystem
Dev->>CMake: cmake configure
loop each images dir
CMake-->>CMake: message("-> ${CMAKE_CURRENT_SOURCE_DIR}/${dir}")
CMake->>Sub: add_subdirectory("${dir}")
CMake-->>CMake: message("<- ${CMAKE_CURRENT_SOURCE_DIR}/${dir}")
loop each file f
Sub-->>Sub: message(" -> ${f}") (verbose)
Sub->>FS: configure_file(${f} ${f} COPYONLY)
end
end
sequenceDiagram
autonumber
participant Build as Build System
participant CMakev as CMake (vehicles)
participant SQL as DB (psql)
participant Out as BYPRODUCTS
Build->>CMakev: invoke add_custom_command (vehicles)
CMakev-->>CMakev: set BYPRODUCTS := route_*, oneway_*, time_*, *_penalty*, *_view*
CMakev->>SQL: execute vehicles.sql (penalty, penalized views)
CMakev->>SQL: execute images.sql (vehicle_* image views)
SQL-->>Out: emit route_*.txt and other byproducts
CMakev-->>Build: byproducts available for subsequent steps
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2025-10-06T17:41:16.475Z
Applied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
🧹 Nitpick comments (3)
locale/en/LC_MESSAGES/basic/vehicle.po (1)
399-401
: Simplify redundant phrasing.The text "by joining the
vehicle_net
joined with theconfiguration
table" contains redundant phrasing with "by joining...joined". Consider simplifying to improve readability.Apply this diff to simplify:
msgid "" -"Create a penalized view by joining the ``vehicle_net`` joined with the " +"Create a penalized view by joining ``vehicle_net`` with the " "``configuration`` table"docs/un_sdg/images/sdg3/CMakeLists.txt (1)
18-21
: Use explicit destination and quoting in configure_file for clarity.Safer and more explicit:
- Quote paths.
- Write to CMAKE_CURRENT_BINARY_DIR to avoid ambiguity.
- message(STATUS " -> ${f}") - endif() - configure_file(${f} ${f} COPYONLY) + message(STATUS " -> ${f}") + endif() + configure_file("${f}" "${CMAKE_CURRENT_BINARY_DIR}/${f}" COPYONLY)docs/un_sdg/images/introduction/CMakeLists.txt (1)
12-15
: Prefer explicit binary destination and quoting.Prevents surprises if source/build dirs overlap or filenames have spaces.
- message(STATUS " -> ${f}") - endif() - configure_file(${f} ${f} COPYONLY) + message(STATUS " -> ${f}") + endif() + configure_file("${f}" "${CMAKE_CURRENT_BINARY_DIR}/${f}" COPYONLY)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (9)
docs/basic/images/vehicle/ad11.png
is excluded by!**/*.png
docs/basic/images/vehicle/ad7.png
is excluded by!**/*.png
docs/basic/images/vehicle/ad8.png
is excluded by!**/*.png
docs/basic/images/vehicle/pedestrian_only_roads.png
is excluded by!**/*.png
docs/basic/images/vehicle/route_using_pedestrian.png
is excluded by!**/*.png
docs/basic/images/vehicle/vehicle_route_coming.png
is excluded by!**/*.png
docs/basic/images/vehicle/vehicle_route_going.png
is excluded by!**/*.png
docs/basic/images/vehicle/vehicle_time_is_money.png
is excluded by!**/*.png
docs/basic/images/vehicle/vehicle_use_penalty.png
is excluded by!**/*.png
📒 Files selected for processing (23)
docs/basic/images/CMakeLists.txt
(1 hunks)docs/basic/images/data/CMakeLists.txt
(1 hunks)docs/basic/images/pedestrian/CMakeLists.txt
(1 hunks)docs/basic/images/plpgsql_function/CMakeLists.txt
(1 hunks)docs/basic/images/sql_function/CMakeLists.txt
(1 hunks)docs/basic/images/vehicle/CMakeLists.txt
(1 hunks)docs/basic/vehicle.rst
(9 hunks)docs/images/CMakeLists.txt
(2 hunks)docs/images/introduction/CMakeLists.txt
(1 hunks)docs/images/logos/CMakeLists.txt
(1 hunks)docs/images/osgeolive/CMakeLists.txt
(1 hunks)docs/interactions/images/CMakeLists.txt
(1 hunks)docs/interactions/images/chap_QGIS/CMakeLists.txt
(1 hunks)docs/scripts/basic/vehicles/CMakeLists.txt
(1 hunks)docs/scripts/basic/vehicles/images.sql
(2 hunks)docs/scripts/basic/vehicles/vehicles.sql
(2 hunks)docs/un_sdg/images/CMakeLists.txt
(1 hunks)docs/un_sdg/images/introduction/CMakeLists.txt
(1 hunks)docs/un_sdg/images/sdg11/CMakeLists.txt
(1 hunks)docs/un_sdg/images/sdg3/CMakeLists.txt
(1 hunks)docs/un_sdg/images/sdg7/CMakeLists.txt
(1 hunks)locale/en/LC_MESSAGES/basic/vehicle.po
(5 hunks)locale/pot/basic/vehicle.pot
(2 hunks)
🔇 Additional comments (2)
docs/interactions/images/CMakeLists.txt (1)
15-19
: LGTM: clearer add_subdirectory flow with pre/post debug.The change is straightforward and consistent with the new pattern.
docs/scripts/basic/vehicles/CMakeLists.txt (1)
13-35
: Make SQL runs fail-fast and deterministic.
- Ensure psql stops on errors.
- Set working directory so \o BYPRODUCTS land where CMake expects.
- Minor: add VERBATIM for safe argument handling.
add_custom_command( TARGET basic_vehicles_scripts PRE_BUILD BYPRODUCTS @@ - COMMAND psql -d city_routing -f vehicles.sql - COMMAND psql -d city_routing -f images.sql + COMMAND psql -v ON_ERROR_STOP=1 -d city_routing -f vehicles.sql + COMMAND psql -v ON_ERROR_STOP=1 -d city_routing -f images.sql COMMENT "running vehicles scripts" - DEPENDS vehicles.sql images.sql) + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + VERBATIM + DEPENDS vehicles.sql images.sql)If the SQL files rely on @PLACE_@ / @ID_@ substitutions, confirm these CMake variables are defined before configure_file runs. To check:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
docs/scripts/basic/vehicles/vehicles.sql (1)
40-41
: Make the penalty column addition idempotent.Re-running the workshop now fails at Line 40 because
ALTER TABLE … ADD COLUMN
raises an error when the column already exists. Please addIF NOT EXISTS
(and keepdouble precision
for clarity) so the script remains rerunnable.Apply this diff:
-ALTER TABLE configuration ADD COLUMN penalty FLOAT DEFAULT 1.0; +ALTER TABLE configuration + ADD COLUMN IF NOT EXISTS penalty double precision DEFAULT 1.0;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
docs/basic/vehicle.rst
(9 hunks)docs/scripts/basic/graphs/graphs.sql
(2 hunks)docs/scripts/basic/pedestrian/images.sql
(7 hunks)docs/scripts/basic/plpgsql_function/plpgsql_function.sql
(1 hunks)docs/scripts/basic/sql_function/images.sql
(1 hunks)docs/scripts/basic/vehicles/images.sql
(3 hunks)docs/scripts/basic/vehicles/vehicles.sql
(2 hunks)locale/en/LC_MESSAGES/basic/vehicle.po
(5 hunks)locale/pot/basic/vehicle.pot
(2 hunks)
✅ Files skipped from review due to trivial changes (1)
- locale/en/LC_MESSAGES/basic/vehicle.po
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/basic/vehicle.rst
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-06T17:41:16.475Z
Learnt from: cvvergara
PR: pgRouting/workshop#258
File: docs/scripts/basic/vehicles/images.sql:49-51
Timestamp: 2025-10-06T17:41:16.475Z
Learning: In OpenStreetMap data structures for pgRouting workshop examples, when filtering the configuration table:
- Use `tag_key` to match any tag with that key (e.g., `tag_key IN ('cycleway')` excludes all roads with any cycleway key regardless of value)
- Use `tag_value` to match specific values of tags (e.g., `tag_value IN ('primary', 'secondary')` matches roads classified as primary or secondary)
- Some terms like 'cycleway' appear both as tag keys (cycleway=lane, cycleway=track) and as tag values (highway=cycleway), requiring filtering on both: `WHERE tag_key IN ('cycleway') OR tag_value IN ('cycleway')`
Applied to files:
docs/scripts/basic/vehicles/vehicles.sql
docs/scripts/basic/vehicles/images.sql
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
docs/scripts/basic/vehicles/vehicles.sql (1)
40-41
: Use an explicit double precision type.Previous feedback still applies:
FLOAT
is ambiguous in PostgreSQL. Please switch todouble precision
(or a numeric precision) while keepingIF NOT EXISTS
so re-running stays idempotent.ALTER TABLE configuration - ADD COLUMN IF NOT EXISTS penalty FLOAT DEFAULT 1.0; + ADD COLUMN IF NOT EXISTS penalty double precision DEFAULT 1.0;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/scripts/basic/vehicles/vehicles.sql
(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-06T17:41:16.475Z
Learnt from: cvvergara
PR: pgRouting/workshop#258
File: docs/scripts/basic/vehicles/images.sql:49-51
Timestamp: 2025-10-06T17:41:16.475Z
Learning: In OpenStreetMap data structures for pgRouting workshop examples, when filtering the configuration table:
- Use `tag_key` to match any tag with that key (e.g., `tag_key IN ('cycleway')` excludes all roads with any cycleway key regardless of value)
- Use `tag_value` to match specific values of tags (e.g., `tag_value IN ('primary', 'secondary')` matches roads classified as primary or secondary)
- Some terms like 'cycleway' appear both as tag keys (cycleway=lane, cycleway=track) and as tag values (highway=cycleway), requiring filtering on both: `WHERE tag_key IN ('cycleway') OR tag_value IN ('cycleway')`
Applied to files:
docs/scripts/basic/vehicles/vehicles.sql
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
Changes proposed in this pull request:
@pgRouting/admins
Summary by CodeRabbit
New Features
Documentation
Chores