hackoregon / emergency-response

Simulations, Models, and Visualizations of Portland Fire and Rescue data
11 stars 10 forks source link

Plot # of incidents per FMA #60

Open hannahkane opened 7 years ago

hannahkane commented 7 years ago

Take calculations from #27 and plot on a map of FMAs. Allow user to select a time frame.

BrianHGrant commented 7 years ago

I have been working on building some geo based queries. An example endpoint I have is:

http://localhost:8000/fma/incidents/?lon=-122.677345&lat=45.520697&start_date=2016-10-19&end_date=2016-10-19

This will return incidents for the fma containing a certain point, filtered by the date range.

http://localhost:8000/fma/incidents/?lon=-122.677345&lat=45.520697

will return all incidents for the fma.

http://localhost:8000/fma/?lon=-122.677345&lat=45.520697

will return the geojson and fma number.

It sounds though that we would like to have a "totals" endpoint, ie:

http://localhost:8000/fma/incident_totals/?lon=-122.677345&lat=45.520697

that would give total counts for different categories of incidents for a given fma, that then could be filtered by date, ie:

http://localhost:8000/fma/incidents_totals/?lon=-122.677345&lat=45.520697&start_date=2016-10-19&end_date=2016-10-19

Would the separate endpoint structure make sense or would we want a single response object, something like:

http://localhost:8000/fma/incidents/?lon=-122.677345&lat=45.520697

returning

data : { incidents : { }, totals : { } }

futurechris commented 7 years ago

My inclination is towards separate endpoints for raw data and analytical results. Separating raw and processed data lets API users avoid having to download incident data they may not need just to access the FMA roll-up statistics.

That said, I'm not sure we want to extend that to separate endpoints per roll-up.

I expect the ratio of wanted:unwanted data is acceptable with a single "give me all the analytical results for this FMA" endpoint, for the time being. We might have a few dozen numbers passed back, given what we're anticipating implementing right now, but that doesn't seem bad.

As we get further along with those, we might be able to split them into separate categories and then provide endpoints per-category, but I don't think we have enough information/maturity with the analytics or product needs to decide that right now.

@kielejocain Thoughts?

kielejocain commented 7 years ago

Sorry for the delayed response. My inclination would be the opposite, but it may be better categorized as a first instinct; I don't know the impact on performance (for example). I'm not in a position to argue either side, and am happy to defer.

BrianHGrant commented 7 years ago

The api has implemented a query param on get('/fma/incidents/') endpoint, in addition to the 'lat' and 'lon' and 'start_date' and 'end_date' params, will also take a 'totals' param. If totals if false or not present, will return:

data : { incidents : { incident_1... }, total_incidents : number of incidents }

if totals == True

then will just return:

data : { total_incidents : number of incidents }

Thus gives the option to get everything or just the total number of incidents.