Skip to content
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

Add color-coded routes and extremely basic route and station tooltips to map #103

Merged
merged 3 commits into from
May 14, 2024

Conversation

mbjackson-capp
Copy link
Contributor

@mbjackson-capp mbjackson-capp commented May 14, 2024

Resolves #84 . Gets the basics of #89 (which still need to be built out to include route information, ridership data if available, etc.)

Screenshots:
As of now, line names display when clicking on a transit line, and station names display when hovering over a station icon (at low enough zoom level, once cluster has fully declustered). Note that even for bus lines typically referred to by a number (as in Chicago's CTA) it displays the text name, not the number, of the route:
Screen Shot 2024-05-14 at 12 47 06 AM
.
The New York colors are wild!! We should look into whether these are substantively meaningful for buses and, if not, consider hard-coding over bus lines to be a more neutral color distinguished from the subway lines:
Screen Shot 2024-05-14 at 12 45 46 AM
.
We're having some display issues with Metra, which is not showing at all. (The other notable commuter rail line in our trial cities, the WES Commuter Rail, is displaying properly without issue on the Portland map.) TODO: Investigate what's going on (hypotheses: extra whitespace in the color strings, column names are slightly different so color column isn't read in)
Screen Shot 2024-05-14 at 12 44 51 AM

Also still TODO: figure out how to display overlapping lines side-by-side, which isn't implemented yet.

Matthew Jackson added 2 commits May 14, 2024 00:02
Some notes:
-Routes have a tooltip that displays on-click, showing the route's
long name.
-Colors are as-is (CTA bus routes are gray, Portland bus routes are
dark bluish/purplish, New York's bus and subway routes are a wild
mixture of colors, which we might want to set to a more neutral
tone).
-Metra routes are not showing up at all (and thus have no color);
investigate whether this is a data ingestion issue, a validation
issue (such as the color column needing .strip() to be 6 characters
long for hex code), or something else such as a non-standard
column name.
Copy link
Contributor

@meganhmoore meganhmoore left a comment

Choose a reason for hiding this comment

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

looking very cool so far, thanks Matt!

# work with it.
# to serialize into GeoJson, need to get out entire Django model object, not just
# the .values("geo_representation", "route_name", "color")
# with .values() you get "AttributeError: 'dict' has no component 'meta'"
Copy link
Contributor

Choose a reason for hiding this comment

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

great note, do you notice slowness from loading all of these routes? If so maybe this is a candidate for caching since this data will generally not be changing

Copy link
Contributor

@meganhmoore meganhmoore May 14, 2024

Choose a reason for hiding this comment

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

I tested this out and it took about a minute to load the chicago page the first time, we may need to look into ways to cache, or auto-load on initialization, or only load some layers at once to reduce how much is being pulled in at a time (but this can be a ticket for later).

Copy link
Contributor

Choose a reason for hiding this comment

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

This took a minute or two for me to load too. I'm also wondering if splitting this into two functions may be better the pins need to be dynamically loaded and the routes don't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it's taking maybe 30-45 seconds to load and this is probably why. Agree that refactoring to speed it up should be its own ticket

)

# stations
stations = TransitStation.objects.values().filter(
city=CITY_CONTEXT[city]["DB_Name"]
)
lst_coords = [[point["location"].x, point["location"].y] for point in stations]
# print(stations)
Copy link
Contributor

Choose a reason for hiding this comment

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

don't need print statements in production if I am reading this correctly (line 58 as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted in new commit

@lisette-solis
Copy link
Contributor

@mbjackson-capp look great! I wonder if we could lower the opacity of the colors to help with overlapping routes and making it less overwhelming

Copy link
Contributor

@lisette-solis lisette-solis left a comment

Choose a reason for hiding this comment

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

Very cool!

# work with it.
# to serialize into GeoJson, need to get out entire Django model object, not just
# the .values("geo_representation", "route_name", "color")
# with .values() you get "AttributeError: 'dict' has no component 'meta'"
Copy link
Contributor

Choose a reason for hiding this comment

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

This took a minute or two for me to load too. I'm also wondering if splitting this into two functions may be better the pins need to be dynamically loaded and the routes don't.

@mbjackson-capp mbjackson-capp merged commit 7922cb2 into main May 14, 2024
1 check passed
@mbjackson-capp mbjackson-capp deleted the new-color-code-routes-branch branch May 14, 2024 21:16
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.

Policy Maker Dashboard Maps: Add (color-coded) routes to map
3 participants