Skip to content

Route indexing by date range - #600

Merged
Rub21 merged 18 commits into
stagingfrom
routes_indexed
Oct 14, 2025
Merged

Rub21 merged 18 commits into
stagingfrom
routes_indexed

Conversation

@Rub21

@Rub21 Rub21 commented Sep 18, 2025

Copy link
Copy Markdown
Member

From: OpenHistoricalMap/issues#1090

This PR introduces a strategy for route indexing and generalization to optimize map rendering performance (Mapbox/MapLibre style) and styling

How this works?

🔹 Database Changes

Added new columns (start_decdate, end_decdate) in both osm_route_multilines and osm_route_lines.
These columns store the decimal start/end dates and are automatically updated when the feature history changes. like we did for boundaries

🔹 Normalized route view
Created a new materialized view mv_routes_normalized which groups routes by start_decdate / end_decdate.
This view splits routes into temporal segments depending on overlap between different relations.

Case 1:

Route A is active from 1900–2000
Route B is active from 1990–2024

Result:

Segment 1: 1900–1990 → Route A only
Segment 2: 1990–2000 → Routes A + B
Segment 3: 2000–2024 → Route B only

Case 2:

Route A is active from 1900–2000
Route B is active from 2001-2024

Result:

Segment 1: 1900–2000 → Route A only
Segment 2: 2001–2024 → Route B only

This way we will have a line graph for each range that will contain the route information for that time range.

cc. @1ec5

@1ec5 1ec5 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is very exciting! It’s mostly working as I expected. I added some notes based on OpenHistoricalMap/issues#1090 (comment), focusing on things we’d probably want to address before launch to avoid having to coordinate style changes later.

'name', name,
'type', type,
'operator', operator,
'direction', direction,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should group by direction to avoid redundant labels.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This make sense, i have added the direction in the indexed attributes
image

@1ec5 1ec5 Sep 29, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That’s OK, but what if a roadway is a member of both the east and west directions of the same-numbered route? Technically a numbered route is supposed to have two different relations going in opposite directions. (For public transit routes, this is required by the PTv2 schema.) If the route follows a two-way road, then that roadway will be a member of both relations. In that case, we only want to show the route just once. Otherwise, there will be two identical-looking shields.

For example, Pacheco Pass is a member of both eastbound and westbound CA 152. In the route_lines layer, the feature has too many route properties:

Key Value
route_road_1_ref 152
route_road_1_network US:CA
route_road_1_direction west
route_road_2_ref 152
route_road_2_network US:CA
route_road_2_direction east

Ideally this would get collapsed down to:

Key Value
route_road_1_ref 152
route_road_1_network US:CA

If this would be challenging, I’m OK with splitting this off as a separate task. It just means duplicate shields for now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, I see, my comment in #600 (comment) was confusing. We should make sure to group the routes so that different direction=* values does not result in multiple features if everything else matches. So I guess that part of 59d73dc would unfortunately need to be undone. That seems to be the last thing before we land this feature.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@1ec5 Are you saying we should consider splitting relations that have a direction (e.g., east, west) into two separate ways? Currently, the indexed directions are shown on a single way. but won't be a much problem to split in diferente ways.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sounds good, I am going to revert the changes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

From : https://www.openhistoricalmap.org/way/199823764
Screenshot 2025-10-14 at 9 25 36 AM
https://tiler-compare.openhistoricalmap.org/check-properties/index.html#17.57/37.003715/-121.370645

It seems we don’t need to revert any changes, because the routes currently indexed as route_road_1_direction and route_road_2_direction —as shown in the image (purple)—actually correspond to a single way in the vector tiles, even though they appear as two separate relations in the OSM database. Since their date ranges (1965-04-29 and 1991-12-31) and attributes match, the algorithm determined they should be represented as just one feature, indexing the attributes

But the routes marked in red should indeed be merged into a single feature, since the start date of the first matches the end date of the second. I’ll double-check that point.

I think the direction handling is correct—it only displays as a single route. Regarding the commit 59d73dc
I initially tried separating them, but it didn’t make much sense, so I concluded that including the direction in the index . Or maybe I’m misunderstanding something?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There were some issues, that i fixed.. now seems better results
ScreenRecording2025-10-14at12 00 10PM-ezgif com-video-to-gif-converter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As noted in #600 (comment), it should be a single route_road_*_* – just one, not two.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fix routes direction

Fix column name for route lines

Update columns for route lines
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