GreenInfo-Network / nyc-crash-mapper

React Redux web application for viewing, filtering, & comparing trends of automobile collision data published by the NYPD.
http://www.crashmapper.org
MIT License
16 stars 4 forks source link

Vehicle Type Filter #104

Closed danrademacher closed 4 years ago

danrademacher commented 4 years ago

Over in https://github.com/GreenInfo-Network/nyc-crash-mapper-etl-script/issues/22, we started pulling in and allocating Vehicle Type data. Now we need to add a filter for it.

Basically this: image

In context of the whole sidebar on the map: image

It fits between current "Filter by Type" and "Data", and then rename the label on "Filter by Type" to "Filter by Crash Type"

gregallensworth commented 4 years ago

Here is the panel, and its filtering behavior for the statistics and the map. This is currently implemented in the gda-vehiclefilter branch.

SCREENSHOTS

image

image

BEHAVIOR NOTES

When no options are selected, no vehicle-involvement filter is applied.

Like the crash type (injury/fatality) filter, this new vehicle-involvement filter is an OR clause. That is to say, adding options will expand the range of results. Crashes which involve a motorcycle AND/OR involve a bicycle AND/OR involve a scooter.

That's as opposed to ANDing them, by which adding options will narrow the range of results to find combinations. Crashes involving a bicycle AND a car. I could see an argument for preferring this behavior in order to find combinations. Of course, beyond 2 selections one approaches very specific and very few matches, e.g. Crashes involving a bicycle and a car and a motorcycle.

danrademacher commented 4 years ago

This is working well locally for me. I did add the word "Type" to the Vehicle Type panel title.

I do notice that the behavior of the Crash Type and Vehicle Type panels is slightly different, where the Crash Type is a true set of toggle, which load in the "ON" position and if you turn them all off, blank map.

Vehicle Type loads in the OFF position and as you describe, no filter is applied: image

While both approaches have their merits, since the Crash Type has been in the app and set the pattern, ideally we would make the Vehicle Type panel work the same way, so the loaded state would look like this: image

gregallensworth commented 4 years ago

⬆️ Per https://github.com/GreenInfo-Network/nyc-crash-mapper/issues/104#issuecomment-572820328 the Vehicle Type panel is now all-on by default, so applying a filter of "any of these 8" by default.

Note that at present 23,410 crash entries in the database which are false for all 8 flags, so would now be omitted from this default view. This may cause some discrepancies in a detailed count of records of CrashMapper vs Socrata. I will bring that up in https://github.com/GreenInfo-Network/nyc-crash-mapper-etl-script/issues/22 for further discussion at the ETL level.

gregallensworth commented 4 years ago

The data cleanup in https://github.com/GreenInfo-Network/nyc-crash-mapper-etl-script/issues/22 went well, and now we have 22,500-ish records with an empty vehicle_type array.

Per discussion, let's rework the Other button as "Other / Unspecified" The SQL clause would be hasvehicle_other = true OR no to the other 7

This would effectively "fill in the blank" of crashes with unspecified vehicle types, but would leave the underlying data intact for later evaluation, re-classification, or a change in behavior.

danrademacher commented 4 years ago

Reviewed and ready to deploy, but holding until matching filter in Chart view is also functional. (https://github.com/GreenInfo-Network/nyc-crash-mapper-chart-view/issues/108)

gregallensworth commented 4 years ago

e0dabcc -- The Trend, Compare, and Ranks hyperlinks at the top, now include the vehicle-type URL params. These match the format used in https://github.com/GreenInfo-Network/nyc-crash-mapper-chart-view/issues/108 and are confirmed to correctly load all three chart views with the same vehicle filter selected.

This is for the gda-vehiclefilter branch. Let's give it a test, and see whether #104 and https://github.com/GreenInfo-Network/nyc-crash-mapper-chart-view/issues/108 are working, so they may be deployed and closed.

gregallensworth commented 4 years ago

Deployed.