jakecoppinger/better-intersections

Filter points by road or timing attributes (# lanes, cycle time)

Closed this issue · 2 comments

It would be very useful to be able to filter points by how many lanes are at the crossing, or only showing long cycle times.

This could be accomplished by adding another field into the state which is a subset of all pins.

Hi Jake, Hope moving isn't proving to be too stressful 🏠. To filter points using lanes I believe that we have to get the OsmWayKeys tags for each intersection and I have checked the openstreetmap API, it seems there is no api to fetch multiple ways. So, I was thinking of fetching the ways for each intersection at the beginning.

export interface IntersectionStats {
  osmId: string;
  lat: number,
  lon: number,
  reports: TrafficLightReport[];
  tags: Record<string, string>;
  way: Way;  /**  Here we add a way field in the IntersectionStats interface /
}

But I feel like it's a bit inefficient to send a fetch req for every single point, but I can't think of any other way?

Ah yes, that is correct. The lane attributes information is fetched when viewing details about an intersection and makes one OSM API request for that intersection.

I think making an extra request for every pin would be an unacceptable number of extra requests to the OSM API - I'm already uncomfortable with the number it current makes to get node positions.

Possibly in the short term we should only focus on filtering on cycle time? I'm thinking something like:

  • two textboxes, one a min and one a max cycle time to show on the map
  • a custom component with two sliders, allowing to set an interval (min/max).

Long term it probably makes sense to either:

  • pre-fetch all the data, make all the requests to the OSM API and statically render the site and data
  • set up a backend to cache requests for nodes

For simplicity's sake and for keeping the website responsive to new submissions I'm inclined to keep it live generated as long as possible! Open to suggestions though.