marleymarl / geotimeline

12 stars 10 forks source link

Create a CheckMapContainer Component for Users to View / Check Footprint Data On a Map #50

Closed marleymarl closed 4 years ago

marleymarl commented 4 years ago

The purpose of this component is to provide a way for people who don't have coronavirus to:

a. view the local data of footprint histories (within time ranges) on a map b. enter in their own footprint histories (which don't save to a db) and have it automatically check (after they hit 'check for matches') if they have come into contact with confirmed cases, and highlight any geotimeline footprint matches (i.e. were in proximity with each other based on datetime window and distance proximity).

The first step is to create the component and display some footprints on a map based on a date range of last 14 days and some radius (whatever the default google maps view provides) around the centerLat and centerLon of the map.

The function to push footprints into the footPrintMarkerViewArray based on radius should be something like:

function distance(lat1, lon2, lat2, long2) { var R = radiusDistance // (whatever the distance is of default map radius) return Math.acos(Math.sin(lat1)*Math.sin(lat2) + Math.cos(lat1)*Math.cos(lat2) * Math.cos(lon2-lon1)) * R; } if (distance(centerLat, centerLon, footprint.lat, footprint.lon) <= desiredRadiusInKm) { //i.e. desiredRadiusInKim = radiusDistance push the footprint into the array of markers to display on map i.e. footPrintMarkerViewArray } else { don't } Source: https://stackoverflow.com/questions/22108307/filter-to-only-show-data-within-the-radius-of-a-point-using-longitude-and-latitu/22112456

To get initial footPrints within a date range, do something like:

a. calculate starting date of 14 days ago as startDate using moment lib and endDate using Date.now() b. reformat each footprints date and time as a timestamp c. filter resulting footPrintMarkerViewArray (result of previous function) and push footprints into new footPrintMarkerViewArrayFinal whose timestamps fall between startDate and endDate.

Eventually a date range query will be available from backend API (and ditto for distance proximity) https://github.com/marleymarl/geotimeline-backend/issues/1 but the above gets the component up and running without waiting for that.

BaNazari commented 4 years ago

a. we don't need to set endDate as Date.now(). What if the user has gone out only once 5 days ago? It's better to end the time range to the last date and time of the user's footprint. It keeps the query smaller. b. I don't think that the idea of "radius" works here. Suppose the user has gone to buy milk in the shop A and it is 10x10 meters. Shop B is side by side with A but separated. At least we can check for the Google map's default value for radius not being too big.

marleymarl commented 4 years ago

a. we don't need to set endDate as Date.now(). What if the user has gone out only once 5 days ago? It's better to end the time range to the last date and time of the user's footprint. It keeps the query smaller.

I agree in general but this is for capturing the initial footprints that display on the map before a user has a chance to enter in their footprints. This is for when they first open the map at some initialCenter, we need to grab a set of footprints for that location for some arbitrary time range. After they enter their own footprints this will change the time and location range for the query of confirmed case footprints. If their last footprint was 5 days ago then it makes sense for that query to stop date range at that day for sure.

heldersepu commented 4 years ago

I have some concerns...

Showing local data of footprint histories might not be much in "rural areas" but metropolitan cities with high population density the map will be one big blob.

I very much like the idea of checking my own footprint histories against known cases, but.. All of these calculations should be done server-side, sending an entire data set to the browser for handling is inefficient, most modern databases have functions to calculate the distance between two coordinates.

The scenario Shop B is side by side with A but separated. I would consider that very high risk. I'm sure than more that one person goes to both stores, distance (radius on this case) is the only measure of infection risk

marleymarl commented 4 years ago

Getting rid of the map display and focusing on CheckFootprints only makes the initial feature spec much easier. That's how we had it initially and then UX added the 'browse case footprints by map' feature. I'm working on this feature now so will limit to the original spec and we can revisit later if necessary. 👍