Skip to content

Conversation

cvvergara
Copy link
Member

@cvvergara cvvergara commented Oct 6, 2025

Changes proposed in this pull request:

  • Rewrite of chapter vehicle
  • updating images and using meaningful names
  • using configure_file for images on the build

@pgRouting/admins

Summary by CodeRabbit

  • New Features

    • Expanded vehicle routing: new vehicle visuals, time-based routing flows, penalty management and view-based route outputs.
  • Documentation

    • Major Vehicle chapter overhaul: updated images, examples, units (seconds), cross-references, exercises, and English translations/POT metadata.
  • Chores

    • Standardized image asset staging and debug messaging; made several views safe to reapply and updated script outputs/dependencies for vehicle workflows.

@cvvergara cvvergara added this to the FOSS4G 2025 milestone Oct 6, 2025
@cvvergara cvvergara requested a review from iosefa October 6, 2025 16:48
Copy link

coderabbitai bot commented Oct 6, 2025

Walkthrough

CMake 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

Cohort / File(s) Summary
Top-level CMake image orchestration
docs/images/CMakeLists.txt, docs/basic/images/CMakeLists.txt, docs/interactions/images/CMakeLists.txt, docs/un_sdg/images/CMakeLists.txt
Reworked directory iteration messaging to arrow style (-> / <-), moved/reordered add_subdirectory("${dir}"), removed per-dir FILE(COPY ...) loops and switched per-file handling to configure_file(... COPYONLY).
Per-subdir image CMakeLists (uniform edits)
docs/images/introduction/CMakeLists.txt, docs/images/logos/CMakeLists.txt, docs/images/osgeolive/CMakeLists.txt, docs/un_sdg/images/introduction/CMakeLists.txt, docs/un_sdg/images/sdg3/CMakeLists.txt, docs/un_sdg/images/sdg7/CMakeLists.txt, docs/un_sdg/images/sdg11/CMakeLists.txt, docs/basic/images/data/CMakeLists.txt, docs/basic/images/pedestrian/CMakeLists.txt, docs/basic/images/plpgsql_function/CMakeLists.txt, docs/basic/images/sql_function/CMakeLists.txt, docs/interactions/images/chap_QGIS/CMakeLists.txt
Standardized per-file copy to configure_file(${f} ${f} COPYONLY); changed verbose messages from "Adding file ..." to indented arrow -> ${f}; minor formatting/loop cleanup and occasional removal of unused subdir lists.
Basic vehicle images list
docs/basic/images/vehicle/CMakeLists.txt
Replaced image filename list with new vehicle_* PNG names; changed debug message formatting and switched file handling to configure_file(... COPYONLY).
Vehicle documentation content
docs/basic/vehicle.rst
Replaced image references and literalinclude anchors to route/time/penalty artifacts; adjusted wording/units (seconds), reorganized penalization and view-based workflows and renamed/reshuffled referenced route files.
Vehicle build script
docs/scripts/basic/vehicles/CMakeLists.txt
Replaced add_custom_command BYPRODUCTS with consolidated route/time/penalty outputs and added DEPENDS vehicles.sql images.sql.
Vehicle images SQL views
docs/scripts/basic/vehicles/images.sql
Renamed/adapted image views to vehicle_* names; switched Dijkstra inputs to vehicle_net/taxi_net; added new image views and adjusted SELECT outputs (seq/start_vid/end_vid/geom) and penalty application.
Vehicle routing SQL and flows
docs/scripts/basic/vehicles/vehicles.sql
Switched routing to vehicle_net; added configuration.penalty column; created penalized view and new flows/scripts (add_penalty, use_penalty, update_penalty, get_penalized_route, time_in_secs, penalized_view, using_view) to support penalty-aware routing.
CREATE → CREATE OR REPLACE VIEW updates
docs/scripts/basic/graphs/graphs.sql, docs/scripts/basic/pedestrian/images.sql, docs/scripts/basic/plpgsql_function/plpgsql_function.sql, docs/scripts/basic/sql_function/images.sql
Many views changed from CREATE VIEW to CREATE OR REPLACE VIEW to allow idempotent redefinition; underlying SELECTs largely unchanged (pedestrian Dijkstra calls standardized in places).
Localization / POT updates
locale/en/LC_MESSAGES/basic/vehicle.po, locale/pot/basic/vehicle.pot
Updated POT/PO headers, timestamps and numerous English strings to reflect vehicle chapter changes (terminology, seconds units, new anchors and phrases).

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
Loading
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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

administrative

Suggested reviewers

  • iosefa
  • sanak

Poem

A rabbit hops through build and view,
Arrows point the paths anew.
Penalties and routes align,
Files configured in a tidy line.
Thump-thump—committed! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “Vehicle chapter rewrite” succinctly and accurately captures the primary focus of the changeset, which centers on rewriting the vehicle chapter content and associated assets without introducing unrelated detail or verbosity. It is concise, specific to the main change, and easily understood when browsing commit history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c685bd9 and d4778a3.

📒 Files selected for processing (2)
  • docs/scripts/basic/vehicles/images.sql (3 hunks)
  • 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
  • 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

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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 the configuration 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

📥 Commits

Reviewing files that changed from the base of the PR and between e2224aa and 7a0f811.

⛔ 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:

Copy link

@coderabbitai coderabbitai bot left a 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 add IF NOT EXISTS (and keep double 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7a0f811 and 7294099.

📒 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

Copy link

@coderabbitai coderabbitai bot left a 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 to double precision (or a numeric precision) while keeping IF 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7294099 and c685bd9.

📒 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

@cvvergara cvvergara merged commit c0ddb6a into pgRouting:develop Oct 7, 2025
2 checks passed
@cvvergara cvvergara deleted the vehicle-chapter-rewrite branch October 7, 2025 14:38
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.

1 participant