Skip to content

Conversation

daniel-heppner-ibigroup
Copy link
Contributor

@daniel-heppner-ibigroup daniel-heppner-ibigroup commented Jun 25, 2025

This PR adds support for rendering the agency name, stop code, and stop name in the map popup used in otp2 tile overlay. It does this by accepting a prop containing a mapping of stop IDs to agencies, since this information is not available in the vector tile data. It also provides a callback prop so the component can tell its parent when a stop has been clicked on and the data is needed.

Paired with opentripplanner/otp-react-redux#1433

Copy link
Collaborator

@miles-grant-ibigroup miles-grant-ibigroup left a comment

Choose a reason for hiding this comment

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

Quick question about duplicated functionality

Comment on lines 61 to 65
/**
* A method to request the agency for a given stop ID. If this method is not passed, the agency
* for a given stop ID will not be displayed in the popup.
*/
requestAgencyForStop?: (stopId: string) => void
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we have this as well as the map. Would it be possible to just have this instead? Feels cleaner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not possible. In OTP-RR we are requesting this data from OTP and it gets stored in Redux, so we wouldn't be able to turn this into an async function that resolves when the request completes. (You could maybe do some hacky thing with a Promise + useEffect that resolves the promise when the redux state updates but... no)

Passing the stop/agency object in allows us to reactively update this component when the data is available.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we get rid of this line then? The method is never defined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@miles-grant-ibigroup miles-grant-ibigroup left a comment

Choose a reason for hiding this comment

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

I think this isn't as janky as you think

@daniel-heppner-ibigroup
Copy link
Contributor Author

Adding @alec-georgoff so he can take a look at how this PR accomplishes its goals. It's a good lesson in how confusing the data flow can be in OTP-RR...

Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

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

Add a story to illustrate the stop name rendering with agency name and stop code. Also, I think we could simply pass an agency id to the popup component, instead of passing an entire map.

entity.id in stopIdAgencyMap &&
"code" in entity
) {
stationName = `${stationName} (${stopIdAgencyMap[entity.id].name} ${
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to pass an entire map if the only important thing is the agency name of the stop? Can we just pass an agency id to the popup?

@daniel-heppner-ibigroup
Copy link
Contributor Author

Based on discussions a week ago about retrieving the agency name, it turns out what we actually want is the feed name. Turned out to be a major simplification!

Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

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

Should the stop code be duplicated?

Comment on lines +395 to +399
W Burnside & SW 2nd (TriMet 9526)
</header>
<p class="styled__PopupRow-sc-12kjso7-2 ckOOWr">
<strong>
Stop ID: 9526
Copy link
Collaborator

Choose a reason for hiding this comment

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

This story repeats the stop code in the title and the stop name, is that intended? In that case, should "TriMet 9526" only appear in Stop Code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's correct. The stop ID shows the stop code, which is correct. And the stop code exists in the title to match the geocoder output, so that's also correct. But maybe I don't understand your comment.

Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

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

After internal dicussion, I'm going to approve this and ignore the duplication of the stop code in the popup title and stop code lines.

@daniel-heppner-ibigroup daniel-heppner-ibigroup merged commit e75ac85 into opentripplanner:master Jul 29, 2025
2 checks passed
@daniel-heppner-ibigroup daniel-heppner-ibigroup deleted the agency-name-in-map-popup branch July 29, 2025 18:25
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.

5 participants